Exemple #1
0
void ANHProvider::_createAssociationInstances(
    Array<CIMInstance> nhrInst,
    Array<CIMInstance> rsapInst)
{
    PEG_METHOD_ENTER(TRC_PROVIDERAGENT,
        "ANHProvider::_createAssociationInstances()");

    for (Uint16 i = 0; i<nhrInst.size(); i++)  // Routes loop.
    {
        CIMInstance _nhrInst = nhrInst[i];

        for (Uint16 j = 0; j<rsapInst.size(); j++)  // Remote Services loop.
        {
            CIMInstance _rsapInst = rsapInst[j];

            String _accessInfo,
                _address,
                _destAddress;
            CIMProperty _rsapAccessInfo = _rsapInst.getProperty(
                _rsapInst.findProperty(PROPERTY_ACCESS_INFO));
            _rsapAccessInfo.getValue().get(_accessInfo);

            Uint32 index = _accessInfo.find('/');

            if (index == PEG_NOT_FOUND)
            {
                PEG_METHOD_EXIT();
                throw CIMOperationFailedException(
                    String("Property AccessInfo is not in the expected ") +
                    String("\"Address/DestinationAddress\" format."));
            }
            else
            {
                _address = _accessInfo.subString(0,index-1);
                _destAddress = _accessInfo.subString(
                    index+1,
                    _accessInfo.size()-1);
            }

            CIMProperty _nhrDestinationAddress = _nhrInst.getProperty(
                _nhrInst.findProperty(PROPERTY_DESTINATION_ADDRESS));

            if (!_nhrDestinationAddress.getValue().equal(
                CIMValue(_destAddress)))
            {
                continue;
            }

            // Build the CIMObjectPath from the instances matching
            CIMObjectPath _rsapObj = _rsapInst.getPath();
            CIMObjectPath _nhrObj = _nhrInst.getPath();

            CIMInstance assocInst(CLASS_PG_ASSOCIATED_NEXT_HOP);
            assocInst.addProperty(
                CIMProperty(
                    CIMName("Antecedent"),
                    _rsapObj,
                    0,
                    CLASS_CIM_REMOTE_SERVICE_ACCESS_POINT));
            assocInst.addProperty(
                CIMProperty(
                    CIMName("Dependent"),
                    _nhrObj,
                    0,
                    CLASS_CIM_NEXT_HOP_ROUTE));

            // Build CIMObjectPath from keybindings
            Array<CIMKeyBinding> keyBindings;
            CIMKeyBinding _rsapBinding(
                CIMName("Antecedent"),
                _rsapObj.toString(),
                CIMKeyBinding::REFERENCE);
            CIMKeyBinding _nhrBinding(
                CIMName("Dependent"),
                _nhrObj.toString(),
                CIMKeyBinding::REFERENCE);
            keyBindings.append (_rsapBinding);
            keyBindings.append (_nhrBinding);

            CIMObjectPath path(
                String::EMPTY,
                CIMNamespaceName(),
                CLASS_PG_ASSOCIATED_NEXT_HOP,
                keyBindings);

            assocInst.setPath(path);
            _AssociationInstances.append(assocInst);
            break;

        }  // Remote Services loop end.

    }  // Routes loop end.

    PEG_METHOD_EXIT();
}
Exemple #2
0
void RUEpProvider::_createAssociationInstances(
    Array<CIMInstance> nhrInst,
    Array<CIMInstance> ipifInst)
{
    PEG_METHOD_ENTER(TRC_PROVIDERAGENT,
        "RUEpProvider::_createAssociationInstances()");

    Uint16 nhrInstSize = nhrInst.size();
    Uint16 ipifInstSize = ipifInst.size();

    for (Uint16 i = 0; i < nhrInstSize; i++)  // Routes loop.
    {
        CIMInstance _nhrInstRet, _ipifInstRet;
        CIMInstance _nhrInst = nhrInst[i];

        CIMProperty _ipifAddress;
        CIMProperty _ipifSubnetMask_PrefixLength;
        CIMProperty _ipifProtocolIFType;
        CIMProperty _nhrInstanceID = _nhrInst.getProperty(
            _nhrInst.findProperty(PROPERTY_INSTANCE_ID));
        CIMProperty _nhrAddrType;
        CIMProperty _nhrDestMask_PrefixLength;


        for (Uint16 j = 0; j<ipifInstSize; j++)  // Interfaces loop.
        {
            CIMInstance _ipifInst = ipifInst[j];

            _ipifProtocolIFType = _ipifInst.getProperty(
                _ipifInst.findProperty(PROPERTY_PROTOCOL_IF_TYPE));

            Uint16 _pift;
            CIMValue _piftCIMValue = _ipifProtocolIFType.getValue();
            if ((_piftCIMValue.getType() == CIMTYPE_UINT16) &&
                (!_piftCIMValue.isNull ()))
            {
                _piftCIMValue.get(_pift);
            }
            else
            {
                throw CIMOperationFailedException(
                    "Can't determine CIMValue::TYPE of ProtocolIFType:" +
                    String(cimTypeToString(_piftCIMValue.getType())));
            }

            if (_pift == 4096)  // IPv4 address.
            {
                _ipifAddress = _ipifInst.getProperty(
                    _ipifInst.findProperty(
                        PROPERTY_IPV4ADDRESS));
                _ipifSubnetMask_PrefixLength = _ipifInst.getProperty(
                    _ipifInst.findProperty(
                    PROPERTY_SUBNET_MASK));
            }
            else
            {
                if (_pift == 4097)  // IPv6 address.
                {
                    _ipifAddress = _ipifInst.getProperty(
                        _ipifInst.findProperty(
                            PROPERTY_IPV6ADDRESS));
                    _ipifSubnetMask_PrefixLength = _ipifInst.getProperty(
                        _ipifInst.findProperty(
                            PROPERTY_IPV6ADDRESS));
                }
                else
                {
                    char buffer[22];
                    Uint32 sz;
                    String _piftStr = Uint16ToString(buffer, _pift, sz);
                    throw CIMOperationFailedException(
                        "ProtocolIFType == " +  _piftStr );
                }
            }

            // In this implementation, we choose InstanceID to be
            // equal DestinationAddress. So, if Address of interface
            // and InstanceID of route doesn't match, check if SubnetMask
            // of interface and DestinationMask route does.
            if (!_nhrInstanceID.getValue().equal(_ipifAddress.getValue()))
            {
                _nhrAddrType = _nhrInst.getProperty(
                    _nhrInst.findProperty(
                        PROPERTY_ADDRESS_TYPE));
                Uint16 _addrt;
                CIMValue _nhratCIMValue = _nhrAddrType.getValue();
                if ((_nhratCIMValue.getType() == CIMTYPE_UINT16) &&
                    (!_nhratCIMValue.isNull()))
                {
                    _nhratCIMValue.get(_addrt);
                }
                else
                {
                    throw CIMOperationFailedException(
                        "Can't determine CIMValue::TYPE of AddressType: " +
                        String(cimTypeToString(_piftCIMValue.getType())));
                }

                if (_addrt == 1)  // IPv4 address.
                {
                    _nhrDestMask_PrefixLength = _nhrInst.getProperty(
                       _nhrInst.findProperty(
                           PROPERTY_DESTINATION_MASK));
                }
                else
                {
                    if (_addrt == 2)  // IPv6 address.
                    {
                         _nhrDestMask_PrefixLength = _nhrInst.getProperty(
                             _nhrInst.findProperty(
                                 PROPERTY_PREFIX_LENGTH));
                    }
                    else
                    {
                        char buffer[22];
                        Uint32 sz;
                        String _addrtStr = Uint16ToString(buffer, _addrt, sz);
                        throw CIMOperationFailedException(
                            "Unknown AddressType = " + _addrtStr);
                    }
                }

                // If SubnetMask of interface and DestinationMask route
                // doesn't match, these instances are unrelated. So,
                // proceed to the next pair.
                if (!_nhrDestMask_PrefixLength.getValue().equal(
                    _ipifSubnetMask_PrefixLength.getValue()))
                {
                    continue;
                }
            }

            // Build the CIMObjectPath from the instances matching
            CIMObjectPath _ipifObj = _ipifInst.getPath();
            CIMObjectPath _nhrObj = _nhrInst.getPath();

            CIMInstance assocInst(CLASS_PG_ROUTE_USES_ENDPOINT);
            assocInst.addProperty(
                CIMProperty(
                    CIMName("Antecedent"),
                    _ipifObj,
                    0,
                    CLASS_CIM_PROTOCOL_ENDPOINT));
            assocInst.addProperty(
                CIMProperty(
                    CIMName("Dependent"),
                    _nhrObj,
                    0,
                    CLASS_CIM_NEXT_HOP_ROUTE));

            // Build CIMObjectPath from keybindings
            Array<CIMKeyBinding> keyBindings;
            CIMKeyBinding _ipifBinding(
                CIMName("Antecedent"),
                _ipifObj.toString(),
                CIMKeyBinding::REFERENCE);
            CIMKeyBinding _nhrBinding(
                CIMName("Dependent"),
                _nhrObj.toString(),
                CIMKeyBinding::REFERENCE);
            keyBindings.append (_ipifBinding);
            keyBindings.append (_nhrBinding);

            CIMObjectPath path(
                String::EMPTY,
                CIMNamespaceName(),
                CLASS_PG_ROUTE_USES_ENDPOINT,
                keyBindings);

            assocInst.setPath(path);
            _AssociationInstances.append(assocInst);
            break;
        }  // Interfaces loop end.

    }  // Routes loop end.

    PEG_METHOD_EXIT();
}