Search in sources :

Example 1 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project netvirt by opendaylight.

the class NaptEventHandler method prepareAndSendPacketOut.

private void prepareAndSendPacketOut(NAPTEntryEvent naptEntryEvent, Long routerId) {
    // Send Packetout - tcp or udp packets which got punted to controller.
    BigInteger metadata = naptEntryEvent.getPacketReceived().getMatch().getMetadata().getMetadata();
    byte[] inPayload = naptEntryEvent.getPacketReceived().getPayload();
    Ethernet ethPkt = new Ethernet();
    if (inPayload != null) {
        try {
            ethPkt.deserialize(inPayload, 0, inPayload.length * NetUtils.NUM_BITS_IN_A_BYTE);
        } catch (PacketException e) {
            LOG.error("prepareAndSendPacketOut : Failed to decode Packet", e);
            return;
        }
    }
    long portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
    LOG.debug("prepareAndSendPacketOut : portTag from incoming packet is {}", portTag);
    String interfaceName = getInterfaceNameFromTag(portTag);
    LOG.debug("prepareAndSendPacketOut : interfaceName fetched from portTag is {}", interfaceName);
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = null;
    int vlanId = 0;
    iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
    if (iface == null) {
        LOG.error("prepareAndSendPacketOut : Unable to read interface {} from config DataStore", interfaceName);
        return;
    }
    List<ActionInfo> actionInfos = new ArrayList<>();
    IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
    if (ifL2vlan != null && ifL2vlan.getVlanId() != null) {
        vlanId = ifL2vlan.getVlanId().getValue() == null ? 0 : ifL2vlan.getVlanId().getValue();
    }
    InterfaceInfo infInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
    if (infInfo == null) {
        LOG.error("prepareAndSendPacketOut : error in getting interfaceInfo from Operation DS");
        return;
    }
    byte[] pktOut = buildNaptPacketOut(ethPkt);
    if (ethPkt.getEtherType() != (short) NwConstants.ETHTYPE_802_1Q) {
        // VLAN Access port
        LOG.debug("prepareAndSendPacketOut : vlanId is {}", vlanId);
        if (vlanId != 0) {
            // Push vlan
            actionInfos.add(new ActionPushVlan(0));
            actionInfos.add(new ActionSetFieldVlanVid(1, vlanId));
        } else {
            LOG.debug("prepareAndSendPacketOut : No vlanId {}, may be untagged", vlanId);
        }
    } else {
        // VLAN Trunk Port
        LOG.debug("prepareAndSendPacketOut : This is VLAN Trunk port case - need not do VLAN tagging again");
    }
    if (pktOut != null) {
        String routerName = NatUtil.getRouterName(dataBroker, routerId);
        long tunId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId, routerName);
        sendNaptPacketOut(pktOut, infInfo, actionInfos, tunId);
    } else {
        LOG.warn("prepareAndSendPacketOut : Unable to send Packet Out");
    }
}
Also used : ArrayList(java.util.ArrayList) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 2 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class ItmManagerRpcServiceTest method setUp.

@Before
public void setUp() throws Exception {
    deviceVteps = new DeviceVtepsBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setKey(new DeviceVtepsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.SOURCE_DEVICE)).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deviceVtepsList.add(deviceVteps);
    stringList.add(ItmTestConstants.SOURCE_DEVICE);
    dpId1List.add(ItmTestConstants.DP_ID_1);
    stringList.add(ItmTestConstants.SOURCE_DEVICE_2);
    trunkInterfaceName = ItmUtils.getTrunkInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME, String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), ItmTestConstants.TUNNEL_TYPE_VXLAN.getName());
    interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
    tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(ItmTestConstants.VLAN_ID).setPortname(ItmTestConstants.PORT_NAME_1).setIpAddress(ItmTestConstants.IP_ADDRESS_3).setGwIpAddress(ItmTestConstants.GTWY_IP_1).setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).setTzMembership(ItmUtils.createTransportZoneMembership(ItmTestConstants.TZ_NAME)).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnetMask(ItmTestConstants.IP_PREFIX_TEST).setKey(new TunnelEndPointsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.PORT_NAME_1, ItmTestConstants.TUNNEL_TYPE_VXLAN, ItmTestConstants.VLAN_ID)).build();
    tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
    dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(ItmTestConstants.DP_ID_1).setKey(new DPNTEPsInfoKey(ItmTestConstants.DP_ID_1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
    cfgdDpnListVxlan.add(dpntePsInfoVxlan);
    dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
    internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(ItmTestConstants.PARENT_INTERFACE_NAME)).setDestinationDPN(ItmTestConstants.DP_ID_2).setSourceDPN(ItmTestConstants.DP_ID_1).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new InternalTunnelKey(ItmTestConstants.DP_ID_2, ItmTestConstants.DP_ID_1, ItmTestConstants.TUNNEL_TYPE_VXLAN)).build();
    getExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
    getInternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
    addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
    addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
    removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
    removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
    getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSourceDpid(ItmTestConstants.DP_ID_1).setDestinationDpid(ItmTestConstants.DP_ID_2).build();
    getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationNode(ItmTestConstants.DESTINATION_DEVICE).setSourceNode(ItmTestConstants.SOURCE_DEVICE).build();
    iface = ItmUtils.buildTunnelInterface(ItmTestConstants.DP_ID_1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(ItmTestConstants.TUNNEL_TYPE_VXLAN), "Trunk Interface"), true, ItmTestConstants.TUNNEL_TYPE_VXLAN, tunnelEndPointsVxlan.getIpAddress(), ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.GTWY_IP_1, tunnelEndPointsVxlan.getVLANID(), false, false, ItmTestConstants.MONITOR_PROTOCOL, null, false, null);
    subnetsTest = new SubnetsBuilder().setGatewayIp(ItmTestConstants.GTWY_IP_1).setVlanId(ItmTestConstants.VLAN_ID).setKey(new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST)).setDeviceVteps(deviceVtepsList).build();
    subnetsList.add(subnetsTest);
    transportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).setSubnets(subnetsList).build();
    transportZoneList.add(transportZone);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    // build external tunnel objects
    externalTunnel = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.DP_ID_1.toString()).setDestinationDevice(String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue())).setTransportType(TunnelTypeMplsOverGre.class).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    externalTunnel2 = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.SOURCE_DEVICE).setDestinationDevice(ItmTestConstants.DESTINATION_DEVICE).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    getInternalOrExternalInterfaceNameOutput = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    // commit external tunnel into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier, externalTunnel, dataBroker);
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, dataBroker);
    // commit internal tunnel into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifier, internalTunnel, dataBroker);
    // commit dpnEndpoints into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpoints, dataBroker);
    // commit TZ into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier, transportZones, dataBroker);
}
Also used : BuildExternalTunnelFromDpnsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.BuildExternalTunnelFromDpnsInputBuilder) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) GetInternalOrExternalInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInputBuilder) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) GetExternalTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder) RemoveExternalTunnelFromDpnsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelFromDpnsInputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) 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) AddL2GwMlagDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwMlagDeviceInputBuilder) TunnelEndPointsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsKey) DPNTEPsInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder) InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) AddExternalTunnelEndpointInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInputBuilder) TunnelEndPointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder) DeleteL2GwMlagDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.DeleteL2GwMlagDeviceInputBuilder) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) ExternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder) DeleteL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.DeleteL2GwDeviceInputBuilder) GetInternalOrExternalInterfaceNameOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder) 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) RemoveExternalTunnelEndpointInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelEndpointInputBuilder) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey) Before(org.junit.Before)

Example 3 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class ItmInternalTunnelDeleteWorker method removeTrunkInterface.

private void removeTrunkInterface(TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId, WriteTransaction transaction) {
    String trunkfwdIfName = ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(), new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
    LOG.trace("Removing forward Trunk Interface {}", trunkfwdIfName);
    InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
    LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkfwdIfName, trunkIdentifier);
    transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
    ItmUtils.ITM_CACHE.removeInterface(trunkfwdIfName);
    // also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
    InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, srcTep.getTunnelType()));
    transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
    ItmUtils.ITM_CACHE.removeInternalTunnel(trunkfwdIfName);
    // Release the Ids for the forward trunk interface Name
    ItmUtils.releaseIdForTrunkInterfaceName(srcTep.getInterfaceName(), new String(srcTep.getIpAddress().getValue()), new String(dstTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
    removeLogicalGroupTunnel(srcDpnId, dstDpnId);
    String trunkRevIfName = ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(), new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()), srcTep.getTunnelType().getName());
    LOG.trace("Removing Reverse Trunk Interface {}", trunkRevIfName);
    trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
    LOG.debug(" Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkRevIfName, trunkIdentifier);
    transaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
    ItmUtils.ITM_CACHE.removeInternalTunnel(trunkRevIfName);
    // also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
    path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(srcDpnId, dstDpnId, dstTep.getTunnelType()));
    transaction.delete(LogicalDatastoreType.CONFIGURATION, path);
    // Release the Ids for the reverse trunk interface Name
    ItmUtils.releaseIdForTrunkInterfaceName(dstTep.getInterfaceName(), new String(dstTep.getIpAddress().getValue()), new String(srcTep.getIpAddress().getValue()), dstTep.getTunnelType().getName());
    removeLogicalGroupTunnel(dstDpnId, srcDpnId);
}
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) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 4 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class ItmExternalTunnelAddWorker method wireUp.

// for tunnels from OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
    IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
    IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
    String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
    String tunTypeStr = tunType.getName();
    String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
    LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
    Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
    InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
    LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true);
    ItmUtils.ITM_CACHE.addInterface(extTunnelIf);
    InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType));
    ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
    ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
    return 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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)

Example 5 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class ItmExternalTunnelAddWorker method buildTunnelsToExternalEndPoint.

public List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(Collection<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
    if (null != cfgDpnList) {
        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
        for (DPNTEPsInfo teps : cfgDpnList) {
            // CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
            TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
            String interfaceName = firstEndPt.getInterfaceName();
            String tunTypeStr = tunType.getName();
            String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunTypeStr);
            char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue();
            boolean useOfTunnel = ItmUtils.falseIfNull(firstEndPt.isOptionOfTunnel());
            List<TunnelOptions> tunOptions = ItmUtils.buildTunnelOptions(firstEndPt, itmConfig);
            String subnetMaskStr = String.valueOf(subnetMaskArray);
            SubnetUtils utils = new SubnetUtils(subnetMaskStr);
            String dcGwyIpStr = String.valueOf(extIp.getValue());
            IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
            IpAddress gwyIpAddress = utils.getInfo().isInRange(dcGwyIpStr) ? gatewayIpObj : firstEndPt.getGwIpAddress();
            LOG.debug(" Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}," + " source IP - {}, DC Gateway IP - {} gateway IP - {}", trunkInterfaceName, interfaceName, firstEndPt.getIpAddress(), extIp, gwyIpAddress);
            Interface iface = ItmUtils.buildTunnelInterface(teps.getDPNID(), trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunType), "Trunk Interface"), true, tunType, firstEndPt.getIpAddress(), extIp, gwyIpAddress, firstEndPt.getVLANID(), false, false, ITMConstants.DEFAULT_MONITOR_PROTOCOL, null, useOfTunnel, tunOptions);
            LOG.debug(" Trunk Interface builder - {} ", iface);
            InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
            LOG.debug(" Trunk Interface Identifier - {} ", trunkIdentifier);
            LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface);
            transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true);
            // update external_tunnel_list ds
            InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
            ExternalTunnel tnl = ItmUtils.buildExternalTunnel(teps.getDPNID().toString(), String.valueOf(extIp.getValue()), tunType, trunkInterfaceName);
            transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
        }
        return Collections.singletonList(transaction.submit());
    }
    return Collections.emptyList();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) SubnetUtils(org.apache.commons.net.util.SubnetUtils) 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) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Aggregations

Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)14 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)7 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)7 ArrayList (java.util.ArrayList)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 BigInteger (java.math.BigInteger)4 List (java.util.List)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)4 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)4 Collections (java.util.Collections)3 Objects (java.util.Objects)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)3 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)3 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)3 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 Preconditions (com.google.common.base.Preconditions)2