Search in sources :

Example 6 with AllocateIdInputBuilder

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

the class DhcpAllocationPoolManager method createIdAllocation.

private long createIdAllocation(String groupIdKey, String idKey) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(groupIdKey).setIdKey(idKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        return rpcResult.getResult().getIdValue();
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.trace("Failed to allocate id for DHCP Allocation Pool Service", e);
    }
    return 0;
}
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 7 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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;
}
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 8 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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();
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) DPNTEPsInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) TunnelEndPointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) ExternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 9 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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 10 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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)

Aggregations

AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)30 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)26 ExecutionException (java.util.concurrent.ExecutionException)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)18 Test (org.junit.Test)8 CreateIdPoolInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput)5 CreateIdPoolInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 IdPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)3 IdPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder)3 IdPoolKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey)3 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)3 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)3 TunnelEndPointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder)3 ArrayList (java.util.ArrayList)2 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)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