Search in sources :

Example 1 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project netvirt by opendaylight.

the class TransportZoneNotificationUtil method addVtep.

/**
 * Tries to add a vtep for a transport zone.
 *
 * @return Whether a vtep was added or not.
 */
private boolean addVtep(TransportZone zone, String subnetIp, BigInteger dpnId, @Nullable String localIp) {
    List<Subnets> zoneSubnets = zone.getSubnets();
    if (zoneSubnets == null) {
        return false;
    }
    Subnets subnets = getOrAddSubnet(zoneSubnets, subnetIp);
    for (Vteps existingVtep : subnets.getVteps()) {
        if (existingVtep.getDpnId().equals(dpnId)) {
            return false;
        }
    }
    if (localIp != null) {
        IpAddress nodeIp = new IpAddress(localIp.toCharArray());
        VtepsBuilder vtepsBuilder = new VtepsBuilder().setDpnId(dpnId).setIpAddress(nodeIp).setPortname(TUNNEL_PORT).setOptionOfTunnel(elanConfig.isUseOfTunnels());
        subnets.getVteps().add(vtepsBuilder.build());
        return true;
    }
    return false;
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)

Example 2 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder 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 3 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.

the class TepCommandHelperTest method setupMocks.

private void setupMocks() {
    System.setOut(new PrintStream(outContent));
    instanceIdentifierList.add(transportZoneIdentifier);
    instanceIdentifierList.add(vtepsIdentifier);
    instanceIdentifierList.add(subnetsIdentifier);
    DeviceVteps deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, sourceDevice)).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
    vteps = new VtepsBuilder().setPortname(portName1).setDpnId(dpId2).setIpAddress(ipAddress1).setKey(new VtepsKey(dpId2, portName1)).build();
    vtepsTest = new VtepsBuilder().build();
    deviceVtepsList.add(deviceVteps);
    vtepsList.add(vteps);
    subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
    subnetsList.add(subnetsTest);
    transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
    transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
    transportZoneList.add(transportZone);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    transportZonesNew = new TransportZonesBuilder().setTransportZone(transportZoneListNew).build();
    tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(10000).build();
    tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
    InternalTunnel internalTunnelTest = new InternalTunnelBuilder().setSourceDPN(dpId1).setDestinationDPN(dpId2).setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setKey(new InternalTunnelKey(dpId1, dpId2, tunnelType1)).setTransportType(tunnelType1).build();
    internalTunnelList.add(internalTunnelTest);
    StateTunnelList stateTunnelListTest = new StateTunnelListBuilder().setTunnelInterfaceName(tunnelInterfaceName).setOperState(TunnelOperStatus.Up).build();
    stateTunnelList.add(stateTunnelListTest);
    lowerLayerIfList.add(dpId1.toString());
    interfaceTest = new InterfaceBuilder().setOperStatus(Interface.OperStatus.Up).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA")).setIfIndex(100).setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).build();
    interfaceTestNew = ItmUtils.buildTunnelInterface(dpId1, tunnelInterfaceName, destinationDevice, enabled, TunnelTypeVxlan.class, ipAddress1, ipAddress2, gtwyIp1, vlanId, true, enabled, monitorProtocol, interval, false, null);
    doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
    doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
    doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) PrintStream(java.io.PrintStream) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) 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) TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) TunnelMonitorIntervalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) 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) 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) InternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder) 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 4 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.

the class ItmExternalTunnelAddTest method setupMocks.

private void setupMocks() {
    ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
    ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
    ipAddress3 = IpAddressBuilder.getDefaultInstance(tepIp3);
    gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
    gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
    ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
    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(dpId1).setUp(true).setKey(new DPNTEPsInfoKey(dpId1)).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
    deviceVteps1 = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, source)).setNodeId(source).setTopologyId("hwvtep:1").build();
    deviceVteps2 = new DeviceVtepsBuilder().setIpAddress(ipAddress2).setKey(new DeviceVtepsKey(ipAddress2, destination)).setNodeId(destination).setTopologyId("hwvtep:1").build();
    hwVtep1 = new HwVtep();
    hwVtep1.setTransportZone(transportZone1);
    hwVtep1.setGatewayIP(gtwyIp1);
    hwVtep1.setHwIp(ipAddress1);
    hwVtep1.setTunnelType(tunnelType1);
    hwVtep1.setVlanID(vlanId);
    hwVtep1.setTopoId("hwvtep:1");
    hwVtep1.setNodeId(source);
    hwVtep1.setIpPrefix(ipPrefixTest);
    cfgdDpnListVxlan.add(dpntePsInfoVxlan);
    cfgdHwVtepsList.add(hwVtep1);
    bigIntegerList.add(dpId1);
    deviceVtepsList.add(deviceVteps1);
    deviceVtepsList.add(deviceVteps2);
    vtepsTest = new VtepsBuilder().setDpnId(dpId1).setIpAddress(ipAddress3).setPortname(portName1).setKey(new VtepsKey(dpId1, portName1)).build();
    vtepsList.add(vtepsTest);
    dpnEndpointsVxlan = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
    transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
    idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
    getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.40:VXLAN").build();
    doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    idOutputOptional2 = RpcResultBuilder.success(expectedId2).buildFuture();
    getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.30:VXLAN").build();
    doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    idOutputOptional3 = RpcResultBuilder.success(expectedId3).buildFuture();
    getIdInput3 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/s3:192.168.56.30:192.168.56.101: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://192.168.101.40:6640/physicalswitch/s4: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.30:192.168.56.40: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.40:6640/physicalswitch/s4:192.168.56.40:192.168.56.30:VXLAN").build();
    doReturn(idOutputOptional6).when(idManagerService).allocateId(getIdInput6);
    tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
    tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(interval).build();
    trunkInterfaceName = ItmUtils.getTrunkInterfaceName(parentInterfaceName, String.valueOf(tunnelEndPointsVxlan.getIpAddress().getValue()), String.valueOf(ipAddress2.getValue()), tunnelType1.getName());
    interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
    externalTunnelIdentifier = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(ipAddress2.getValue()), dpId1.toString(), tunnelType1));
    iface = ItmUtils.buildTunnelInterface(dpId1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, ipAddress3, ipAddress2, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false, null);
    externalTunnel = ItmUtils.buildExternalTunnel(dpId1.toString(), String.valueOf(ipAddress2.getValue()), tunnelType1, trunkInterfaceName);
    subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setVteps(vtepsList).setDeviceVteps(deviceVtepsList).build();
    subnetsList.add(subnets);
    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) TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) TunnelMonitorIntervalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder) 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) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) 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) DpnEndpointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder) 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 5 with VtepsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder in project genius by opendaylight.

the class OvsdbTepAddConfigHelper method addVtepInITMConfigDS.

/**
 * Adds the TEP into Vtep list in the subnet list in the transport zone list
 * from ITM configuration Datastore by merge operation with write transaction.
 *
 * @param subnetList subnets list object
 * @param subnetMaskObj subnet mask in IpPrefix object
 * @param updatedVtepList updated Vteps list object which will have new TEP for addition
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param tzName transport zone name in string
 * @param dpid bridge datapath ID in BigInteger
 * @param portName port name as a part of VtepsKey
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param wrTx WriteTransaction object
 */
public static void addVtepInITMConfigDS(List<Subnets> subnetList, IpPrefix subnetMaskObj, List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid, String portName, boolean ofTunnel, WriteTransaction wrTx) {
    // Create TZ node path
    InstanceIdentifier<TransportZone> tranzportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
    // when VTEP is moved from TepsNotHosted list to TZ configured from Northbound.
    if (dpid.compareTo(BigInteger.ZERO) > 0) {
        // create vtep
        VtepsKey vtepkey = new VtepsKey(dpid, portName);
        Vteps vtepObj = new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).setKey(vtepkey).setPortname(portName).setOptionOfTunnel(ofTunnel).build();
        // Add vtep obtained from bridge into list
        updatedVtepList.add(vtepObj);
        LOG.trace("Adding TEP (TZ: {} Subnet: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName, subnetMaskObj, tepIpAddress, dpid, ofTunnel);
    } else {
        // corresponding TZ is configured from northbound.
        for (Vteps vtep : updatedVtepList) {
            LOG.trace("Moving TEP (TEP IP: {} DPID: {}, of-tunnel: {})" + "from not-hosted-transport-zone {} into  ITM Config DS.", vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
        }
    }
    // Create subnet object
    SubnetsKey subKey = new SubnetsKey(subnetMaskObj);
    IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
    int vlanID = ITMConstants.DUMMY_VLANID;
    Subnets subnet = new SubnetsBuilder().setGatewayIp(gatewayIP).setKey(subKey).setPrefix(subnetMaskObj).setVlanId(vlanID).setVteps(updatedVtepList).build();
    // add subnet into subnet list
    subnetList.add(subnet);
    // create TZ node with updated subnet having new vtep
    TransportZone updatedTzone = new TransportZoneBuilder().setKey(new TransportZoneKey(tzName)).setSubnets(subnetList).setZoneName(tzName).build();
    // Update TZ in Config DS to add vtep in TZ
    wrTx.merge(LogicalDatastoreType.CONFIGURATION, tranzportZonePath, updatedTzone, true);
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TepsInNotHostedTransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder) UnknownVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

VtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)8 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)7 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)6 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)4 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)4 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)4 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)3 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)3 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)2 TunnelMonitorIntervalBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder)2 TunnelMonitorParamsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder)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