use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.
the class NatOverVxlanUtil method releaseVNI.
public static void releaseVNI(String vniKey, IdManagerService idManager) {
ReleaseIdInput releaseIdInput = new ReleaseIdInputBuilder().setPoolName(NatConstants.ODL_VNI_POOL_NAME).setIdKey(vniKey).build();
try {
Future<RpcResult<Void>> result = idManager.releaseId(releaseIdInput);
RpcResult<Void> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.warn("releaseVNI : Unable to release ID {} from OpenDaylight VXLAN VNI range pool. Error {}", vniKey, rpcResult.getErrors());
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("releaseVNI : Exception in release VNI for Key {}", vniKey, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.
the class ElanUtils method releaseId.
public static void releaseId(IdManagerService idManager, String poolName, String idKey) {
ReleaseIdInput releaseIdInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
JdkFutures.addErrorLogging(idManager.releaseId(releaseIdInput), LOG, "Release Id");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.
the class ElanUtils method retrieveNewElanTag.
/**
* Uses the IdManager to retrieve a brand new ElanTag.
*
* @param idManager
* the id manager
* @param idKey
* the id key
* @return the integer
*/
public static Long retrieveNewElanTag(IdManagerService idManager, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(ElanConstants.ELAN_ID_POOL_NAME).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return rpcResult.getResult().getIdValue();
} else {
LOG.warn("RPC Call to Allocate Id returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when Allocating Id", e);
}
return 0L;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project netvirt by opendaylight.
the class ArpResponderUtil method retrieveStandardArpResponderGroupId.
/**
* Uses the IdManager to retrieve ARP Responder GroupId from ELAN pool.
*
* @param idManager
* the id manager
* @return the integer
*/
public static Long retrieveStandardArpResponderGroupId(IdManagerService idManager) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(ArpResponderConstant.ELAN_ID_POOL_NAME.value()).setIdKey(ArpResponderConstant.ARP_RESPONDER_GROUP_ID.value()).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
LOG.trace("Retrieved Group Id is {}", rpcResult.getResult().getIdValue());
return rpcResult.getResult().getIdValue();
} else {
LOG.warn("RPC Call to Allocate Id returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when Allocating Id", e);
}
return 0L;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService in project genius by opendaylight.
the class ItmExternalTunnelDeleteTest method setupMocks.
private void setupMocks() {
ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
ipAddress3 = IpAddressBuilder.getDefaultInstance(tepIp3);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
deviceVteps1 = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
deviceVteps2 = new DeviceVtepsBuilder().setIpAddress(ipAddress2).setKey(new DeviceVtepsKey(ipAddress2, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
deviceVtepsList.add(deviceVteps1);
deviceVtepsList.add(deviceVteps2);
hwVtep1 = new HwVtep();
hwVtep1.setTransportZone(transportZone1);
hwVtep1.setGatewayIP(gtwyIp1);
hwVtep1.setHwIp(ipAddress2);
hwVtep1.setTunnelType(tunnelType1);
hwVtep1.setVlanID(vlanId);
hwVtep1.setTopoId("hwvtep:1");
hwVtep1.setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3");
hwVtep1.setIpPrefix(ipPrefixTest);
vteps = new VtepsBuilder().setDpnId(dpId2).setIpAddress(ipAddress1).setPortname(portName1).setKey(new VtepsKey(dpId2, portName1)).build();
vtepsList.add(vteps);
idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
idOutputOptional2 = RpcResultBuilder.success(expectedId2).buildFuture();
getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
idOutputOptional3 = RpcResultBuilder.success(expectedId3).buildFuture();
getIdInput3 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional3).when(idManagerService).allocateId(getIdInput3);
idOutputOptional4 = RpcResultBuilder.success(expectedId4).buildFuture();
getIdInput4 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.40:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional4).when(idManagerService).allocateId(getIdInput4);
idOutputOptional5 = RpcResultBuilder.success(expectedId5).buildFuture();
getIdInput5 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional5).when(idManagerService).allocateId(getIdInput5);
idOutputOptional6 = RpcResultBuilder.success(expectedId6).buildFuture();
getIdInput6 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional6).when(idManagerService).allocateId(getIdInput6);
idOutputOptional7 = RpcResultBuilder.success(expectedId7).buildFuture();
getIdInput7 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional7).when(idManagerService).allocateId(getIdInput7);
idOutputOptional8 = RpcResultBuilder.success(expectedId8).buildFuture();
getIdInput8 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.30:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional8).when(idManagerService).allocateId(getIdInput8);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress3).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId2).setUp(true).setKey(new DPNTEPsInfoKey(dpId2)).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
dpnTepsList.add(dpntePsInfoVxlan);
cfgdHwVtepsList.add(hwVtep1);
subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
subnetsList.add(subnets);
transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
externalTunnel = new ExternalTunnelBuilder().setTunnelInterfaceName(parentInterfaceName).setTransportType(tunnelType1).setDestinationDevice("hwvtep:1").setSourceDevice(dpId2.toString()).setKey(new ExternalTunnelKey(dpId2.toString(), hwVtep1.getNodeId(), tunnelType1)).build();
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(parentInterfaceName, String.valueOf(tunnelEndPointsVxlan.getIpAddress().getValue()), String.valueOf(ipAddress1.getValue()), tunnelType1.getName());
trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(ipAddress1.getValue()), dpId2.toString(), tunnelType1));
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
Aggregations