Search in sources :

Example 11 with InternalTunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel 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 12 with InternalTunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel 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 13 with InternalTunnel

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel in project genius by opendaylight.

the class ItmInternalTunnelAddWorker method createInternalTunnel.

private static void createInternalTunnel(BigInteger srcDpnId, BigInteger dstDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName, WriteTransaction transaction) {
    InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, tunType));
    InternalTunnel tnl = ItmUtils.buildInternalTunnel(srcDpnId, dstDpnId, tunType, trunkInterfaceName);
    // Switching to individual transaction submit as batching latencies is causing ELAN failures.
    // Will revert when ELAN can handle this.
    // ITMBatchingUtils.update(path, tnl, ITMBatchingUtils.EntityType.DEFAULT_CONFIG);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
    ItmUtils.ITM_CACHE.addInternalTunnel(tnl);
}
Also used : InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) TunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel)

Aggregations

InternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel)11 InternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey)7 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)5 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 TunnelTypeLogicalGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup)3 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)3 InternalTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder)3 TransportZonesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder)3 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)3 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)3 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)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 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)2 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)2 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)2 DpnEndpointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder)2 TunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList)2 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)2