Search in sources :

Example 11 with IdManagerService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project genius by opendaylight.

the class ItmInternalTunnelAddTest method testBuild_all_tunnels_VXLANtype.

@Test
public void testBuild_all_tunnels_VXLANtype() {
    AllocateIdInput getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.102:VXLAN").build();
    AllocateIdInput getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.102:192.168.56.101:VXLAN").build();
    doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    trunkInterfaceName1 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp1, tepIp2, tunnelType1.getName());
    trunkInterfaceName2 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp2, tepIp1, tunnelType1.getName());
    internalTunnel1 = ItmUtils.buildInternalTunnel(dpId1, dpId2, tunnelType1, trunkInterfaceName1);
    internalTunnel2 = ItmUtils.buildInternalTunnel(dpId2, dpId1, tunnelType1, trunkInterfaceName2);
    itmInternalTunnelAddWorker.buildAllTunnels(mdsalApiManager, cfgdDpnListVxlan, meshDpnListVxlan);
    // Add some verifications
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierVxlan1, internalTunnel1, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierVxlan2, internalTunnel2, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpointsVxlan);
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with IdManagerService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project genius by opendaylight.

the class ItmInternalTunnelAddTest method testBuild_all_tunnels_GREtype.

@Test
public void testBuild_all_tunnels_GREtype() {
    AllocateIdInput getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.102:GRE").build();
    AllocateIdInput getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.102:192.168.56.101:GRE").build();
    doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    trunkInterfaceName1 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp1, tepIp2, tunnelType2.getName());
    trunkInterfaceName2 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp2, tepIp1, tunnelType2.getName());
    internalTunnel1 = ItmUtils.buildInternalTunnel(dpId1, dpId2, tunnelType2, trunkInterfaceName1);
    internalTunnel2 = ItmUtils.buildInternalTunnel(dpId2, dpId1, tunnelType2, trunkInterfaceName2);
    itmInternalTunnelAddWorker.buildAllTunnels(mdsalApiManager, cfgdDpnListGre, meshDpnListGre);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierGre1, internalTunnel1, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierGre2, internalTunnel2, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpointsGre);
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with IdManagerService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project genius by opendaylight.

the class IfmUtil method allocateId.

public static Integer allocateId(IdManagerService idManager, String poolName, String idKey) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            return rpcResult.getResult().getIdValue().intValue();
        } else {
            LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when getting Unique Id", e);
    }
    return INVALID_ID;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 14 with IdManagerService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.

the class ElanUtils method updateOperationalDataStore.

/**
 * Updates the Elan information in the Operational DS. It also updates the
 * ElanInstance in the Config DS by setting the adquired elanTag.
 *
 * @param idManager
 *            the id manager
 * @param elanInstanceAdded
 *            the elan instance added
 * @param elanInterfaces
 *            the elan interfaces
 * @param tx
 *            transaction
 *
 * @return the updated ELAN instance.
 */
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, WriteTransaction tx) {
    String elanInstanceName = elanInstanceAdded.getElanInstanceName();
    Long elanTag = elanInstanceAdded.getElanTag();
    if (elanTag == null || elanTag == 0L) {
        elanTag = retrieveNewElanTag(idManager, elanInstanceName);
    }
    Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).setKey(new ElanKey(elanInstanceName)).build();
    // Add the ElanState in the elan-state operational data-store
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanInstanceOperationalDataPath(elanInstanceName), elanInfo, WriteTransaction.CREATE_MISSING_PARENTS);
    // Add the ElanMacTable in the elan-mac-table operational data-store
    MacTable elanMacTable = new MacTableBuilder().setKey(new MacTableKey(elanInstanceName)).build();
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
    ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).setKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
    long etreeLeafTag = -1;
    if (isEtreeInstance(elanInstanceAdded)) {
        etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
        EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
        elanTagNameBuilder.addAugmentation(EtreeLeafTagName.class, etreeLeafTagName);
        addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, tx);
    }
    ElanTagName elanTagName = elanTagNameBuilder.build();
    // Add the ElanTag to ElanName in the elan-tag-name Operational
    // data-store
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
    // Updates the ElanInstance Config DS by setting the just acquired
    // elanTag
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Long.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).setKey(elanInstanceAdded.getKey()).setElanTag(elanTag);
    if (isEtreeInstance(elanInstanceAdded)) {
        EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
        elanInstanceBuilder.addAugmentation(EtreeInstance.class, etreeInstance);
    }
    ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
    tx.merge(LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag, WriteTransaction.CREATE_MISSING_PARENTS);
    return elanInstanceWithTag;
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey) MacTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableBuilder) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable) EtreeLeafTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName) ElanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder) ElanTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameBuilder) MacTableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey) ElanTagNameKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) EtreeInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder) EtreeLeafTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagNameBuilder) EtreeLeafTag(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTag)

Example 15 with IdManagerService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.

the class VpnUtil method releaseId.

public static void releaseId(IdManagerService idManager, String poolName, String idKey) {
    ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
    try {
        Future<RpcResult<Void>> result = idManager.releaseId(idInput);
        RpcResult<Void> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.error("releaseId: RPC Call to release Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("releaseId: Exception when releasing Id for key {} from pool {}", idKey, poolName, e);
    }
}
Also used : ReleaseIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)15 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)15 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)13 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)11 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)8 ReleaseIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput)6 ReleaseIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder)6 Test (org.junit.Test)3 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)2 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)2 TunnelEndPointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder)2 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)2 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)2 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)2 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)2 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)2 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)2 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)2 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)2