Search in sources :

Example 21 with TransportZoneKey

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

the class ItmExternalTunnelAddTest method testBuildHwVtepsTunnels.

@Test
public void testBuildHwVtepsTunnels() {
    final Interface extTunnelIf1 = ItmUtils.buildTunnelInterface(dpId1, "tun030025bd04f", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
    final Interface hwTunnelIf2 = ItmUtils.buildHwTunnelInterface("tun9a55a9c38f2", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
    final Interface extTunnelIf3 = ItmUtils.buildTunnelInterface(dpId1, "tun17c6e20c283", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress2, gtwyIp1, vlanId, false, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL, false, null);
    final Interface hwTunnelIf4 = ItmUtils.buildHwTunnelInterface("tunaa109b6c8c5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress3, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
    final Interface hwTunnelIf5 = ItmUtils.buildHwTunnelInterface("tund903ed434d5", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), hwVtep1.getNodeId(), tunnelType1, ipAddress1, ipAddress2, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
    final Interface hwTunnelIf6 = ItmUtils.buildHwTunnelInterface("tunc3315b110a6", String.format("%s %s", tunnelType1.getName(), "Trunk Interface"), true, hwVtep1.getTopoId(), destination, tunnelType1, ipAddress2, ipAddress1, gtwyIp1, false, monitorProtocol, ITMConstants.BFD_DEFAULT_MONITOR_INTERVAL);
    final ExternalTunnel externalTunnel1 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1, "tun030025bd04f");
    final ExternalTunnel externalTunnel2 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tun9a55a9c38f2");
    final ExternalTunnel externalTunnel3 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1, "tun17c6e20c283");
    final ExternalTunnel externalTunnel4 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1, "tunaa109b6c8c5");
    final ExternalTunnel externalTunnel5 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1, "tund903ed434d5");
    final ExternalTunnel externalTunnel6 = ItmUtils.buildExternalTunnel(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1, "tunc3315b110a6");
    InstanceIdentifier<TransportZone> transportZoneIdentifier = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone1)).build();
    final InstanceIdentifier<Interface> ifIID1 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun030025bd04f")).build();
    final InstanceIdentifier<Interface> ifIID2 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun9a55a9c38f2")).build();
    final InstanceIdentifier<Interface> ifIID3 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tun17c6e20c283")).build();
    final InstanceIdentifier<Interface> ifIID4 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunaa109b6c8c5")).build();
    final InstanceIdentifier<Interface> ifIID5 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tund903ed434d5")).build();
    final InstanceIdentifier<Interface> ifIID6 = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey("tunc3315b110a6")).build();
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(dpId1.toString()), tunnelType1));
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier2 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(source), tunnelType1));
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier3 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(dpId1.toString()), tunnelType1));
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier4 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dpId1.toString()), getExternalTunnelKey(destination), tunnelType1));
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier5 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(destination), getExternalTunnelKey(source), tunnelType1));
    final InstanceIdentifier<ExternalTunnel> externalTunnelIdentifier6 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(source), getExternalTunnelKey(destination), tunnelType1));
    Optional<TransportZone> optionalTransportZone = Optional.of(transportZone);
    doReturn(Futures.immediateCheckedFuture(optionalTransportZone)).when(mockReadTx).read(LogicalDatastoreType.CONFIGURATION, transportZoneIdentifier);
    externalTunnelAddWorker.buildHwVtepsTunnels(cfgdDpnListVxlan, null);
    externalTunnelAddWorker.buildHwVtepsTunnels(null, cfgdHwVtepsList);
    verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID1, extTunnelIf1, true);
    verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier1, externalTunnel1, true);
    verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, ifIID2, hwTunnelIf2, true);
    verify(mockWriteTx, times(2)).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID3, extTunnelIf3, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier3, externalTunnel3, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID4, hwTunnelIf4, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier4, externalTunnel4, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID5, hwTunnelIf5, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier5, externalTunnel5, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, ifIID6, hwTunnelIf6, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier6, externalTunnel6, true);
}
Also used : ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) 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) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey) Test(org.junit.Test)

Example 22 with TransportZoneKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey 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 23 with TransportZoneKey

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

the class OvsdbTepRemoveConfigHelper method removeVtepFromTZConfig.

/**
 * Removes the TEP from subnet list in the transport zone list
 * from ITM configuration Datastore by delete operation with write transaction.
 *
 * @param subnetMaskObj subnet mask in IpPrefix object
 * @param dpnId bridge datapath ID in BigInteger
 * @param tzName transport zone name in string
 * @param portName port name as a part of VtepsKey
 * @param wrTx WriteTransaction object
 */
private static void removeVtepFromTZConfig(IpPrefix subnetMaskObj, String tzName, BigInteger dpnId, String portName, WriteTransaction wrTx) {
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    VtepsKey vtepkey = new VtepsKey(dpnId, portName);
    InstanceIdentifier<Vteps> vtepPath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).child(Subnets.class, subnetsKey).child(Vteps.class, vtepkey).build();
    LOG.trace("Removing TEP from (TZ: {} Subnet: {} DPN-ID: {}) inside ITM Config DS.", tzName, subnetMaskObj, dpnId);
    // remove vtep
    wrTx.delete(LogicalDatastoreType.CONFIGURATION, vtepPath);
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) 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) 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) 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)

Example 24 with TransportZoneKey

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

the class ItmUtils method getTunnelsofTzone.

public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker, Boolean hwVtepsExist) {
    List<String> tunnels = new ArrayList<>();
    InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
    Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (transportZoneOptional.isPresent()) {
        TransportZone transportZone = transportZoneOptional.get();
        Class<? extends TunnelTypeBase> tunType = transportZone.getTunnelType();
        if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
            for (Subnets sub : transportZone.getSubnets()) {
                if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
                    for (Vteps vtepLocal : sub.getVteps()) {
                        for (Vteps vtepRemote : sub.getVteps()) {
                            if (!vtepLocal.equals(vtepRemote)) {
                                InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(), tunType);
                                InstanceIdentifier<InternalTunnel> intIID = InstanceIdentifier.builder(TunnelList.class).child(InternalTunnel.class, key).build();
                                Optional<InternalTunnel> tunnelsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
                                if (tunnelsOptional.isPresent()) {
                                    List<String> tunnelInterfaceNames = tunnelsOptional.get().getTunnelInterfaceNames();
                                    if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
                                        String tunnelInterfaceName = tunnelInterfaceNames.get(0);
                                        LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
                                        tunnels.add(tunnelInterfaceName);
                                    }
                                }
                            }
                        }
                        if (hwVteps != null && !hwVteps.isEmpty()) {
                            for (HwVtep hwVtep : hwVteps) {
                                tunnels.add(getExtTunnel(hwVtep.getNodeId(), vtepLocal.getDpnId().toString(), tunType, dataBroker));
                                tunnels.add(getExtTunnel(vtepLocal.getDpnId().toString(), hwVtep.getNodeId(), tunType, dataBroker));
                            }
                        }
                    }
                }
            }
        }
        if (hwVtepsExist) {
            for (HwVtep hwVtep : hwVteps) {
                for (HwVtep hwVtepOther : hwVteps) {
                    if (!hwVtep.getHwIp().equals(hwVtepOther.getHwIp())) {
                        tunnels.add(getExtTunnel(hwVtep.getNodeId(), hwVtepOther.getNodeId(), tunType, dataBroker));
                        tunnels.add(getExtTunnel(hwVtepOther.getNodeId(), hwVtep.getNodeId(), tunType, dataBroker));
                    }
                }
            }
        }
    }
    return tunnels;
}
Also used : InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) ArrayList(java.util.ArrayList) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) 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) 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) 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)

Example 25 with TransportZoneKey

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

the class ItmUtils method deleteTransportZoneFromConfigDS.

/**
 * Deletes the transport zone from Configuration datastore.
 *
 * @param tzName transport zone name
 * @param dataBroker data broker handle to perform operations on datastore
 */
public static void deleteTransportZoneFromConfigDS(String tzName, DataBroker dataBroker) {
    // check whether transport-zone exists in config DS.
    TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
    if (transportZoneFromConfigDS != null) {
        // it exists, delete default-TZ now
        InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
        LOG.debug("Removing {} transport-zone from config DS.", tzName);
        try {
            SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
        } catch (TransactionCommitFailedException e) {
            LOG.error("deleteTransportZoneFromConfigDS failed. {} could not be deleted.", tzName, e);
        }
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) 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

TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)30 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)23 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)15 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)11 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)11 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)10 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)9 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)9 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)9 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)7 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)7 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)7 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)7 ArrayList (java.util.ArrayList)6 TransportZonesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder)6 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)5 InternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey)5 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)5