Search in sources :

Example 26 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports in project netvirt by opendaylight.

the class NeutronPortChangeListener method setExternalGwMac.

private void setExternalGwMac(Port routerGwPort, Uuid routerId) {
    // During full-sync networking-odl syncs routers before ports. As such,
    // the MAC of the router's gw port is not available to be set when the
    // router is written. We catch that here.
    InstanceIdentifier<Routers> routersId = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
    Optional<Routers> optionalRouter = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId);
    if (!optionalRouter.isPresent()) {
        return;
    }
    Routers extRouters = optionalRouter.get();
    if (extRouters.getExtGwMacAddress() != null) {
        return;
    }
    RoutersBuilder builder = new RoutersBuilder(extRouters);
    builder.setExtGwMacAddress(routerGwPort.getMacAddress().getValue());
    MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId, builder.build());
}
Also used : RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)

Example 27 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports in project netvirt by opendaylight.

the class ConfigurationClassifierImpl method buildEntries.

private Set<ClassifierRenderableEntry> buildEntries(String ruleName, @NonNull List<String> interfaces, @NonNull Matches matches, @NonNull RenderedServicePath rsp) {
    String rspName = rsp.getName().getValue();
    Long nsp = rsp.getPathId();
    Short nsi = rsp.getStartingIndex();
    Short nsl = rsp.getRenderedServicePathHop() == null ? null : (short) rsp.getRenderedServicePathHop().size();
    if (nsp == null || nsi == null || nsl == null) {
        LOG.warn("Ace {} RSP {} ignored: no valid NSI or NSP or length", ruleName, rspName);
        return Collections.emptySet();
    }
    DpnIdType firstHopDpn = sfcProvider.getFirstHopIngressInterfaceFromRsp(rsp).flatMap(geniusProvider::getDpnIdFromInterfaceName).orElse(null);
    if (firstHopDpn == null) {
        LOG.warn("Ace {} RSP {} ignored: no valid first hop DPN", ruleName, rspName);
        return Collections.emptySet();
    }
    String lastHopInterface = sfcProvider.getLastHopEgressInterfaceFromRsp(rsp).orElse(null);
    if (lastHopInterface == null) {
        LOG.warn("Ace {} RSP {} ignored: has no valid last hop interface", ruleName, rspName);
        return Collections.emptySet();
    }
    DpnIdType lastHopDpn = geniusProvider.getDpnIdFromInterfaceName(lastHopInterface).orElse(null);
    if (lastHopDpn == null) {
        LOG.warn("Ace {} RSP {} ignored: has no valid last hop DPN", ruleName, rspName);
        return Collections.emptySet();
    }
    Map<NodeId, List<InterfaceKey>> nodeToInterfaces = new HashMap<>();
    for (String iface : interfaces) {
        geniusProvider.getNodeIdFromLogicalInterface(iface).ifPresent(nodeId -> nodeToInterfaces.computeIfAbsent(nodeId, key -> new ArrayList<>()).add(new InterfaceKey(iface)));
    }
    LOG.trace("Ace {} RSP {}: got classifier nodes and interfaces: {}", ruleName, rspName, nodeToInterfaces);
    String firstHopIp = geniusProvider.getIpFromDpnId(firstHopDpn).orElse(null);
    Set<ClassifierRenderableEntry> entries = new HashSet<>();
    nodeToInterfaces.forEach((nodeId, ifaces) -> {
        // Get node info
        DpnIdType nodeDpn = new DpnIdType(OpenFlow13Provider.getDpnIdFromNodeId(nodeId));
        String nodeIp = geniusProvider.getIpFromDpnId(nodeDpn).orElse(LOCAL_HOST_IP);
        if (firstHopIp == null && !nodeDpn.equals(firstHopDpn)) {
            LOG.warn("Ace {} RSP {} classifier {} ignored: no IP to reach first hop DPN {}", ruleName, rspName, nodeId, firstHopDpn);
            return;
        }
        // Add entries that are not based on ingress or egress interface
        entries.add(ClassifierEntry.buildNodeEntry(nodeId));
        entries.add(ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, nodeDpn.equals(firstHopDpn) ? null : firstHopIp));
        // Add entries based on ingress interface
        ifaces.forEach(interfaceKey -> {
            entries.add(ClassifierEntry.buildIngressEntry(interfaceKey));
            entries.add(ClassifierEntry.buildMatchEntry(nodeId, geniusProvider.getNodeConnectorIdFromInterfaceName(interfaceKey.getName()).get(), matches, nsp, nsi));
        });
        // hand-off can happen through the dispatcher table
        if (nodeDpn.equals(lastHopDpn)) {
            entries.add(ClassifierEntry.buildIngressEntry(new InterfaceKey(lastHopInterface)));
        }
        // Egress services must bind to egress ports. Since we dont know before-hand what
        // the egress ports will be, we will bind on all switch ports. If the packet
        // doesnt have NSH, it will be returned to the the egress dispatcher table.
        List<Interfaces> interfaceUuidStrList = geniusProvider.getInterfacesFromNode(nodeId);
        interfaceUuidStrList.forEach(interfaceUuidStr -> {
            InterfaceKey interfaceKey = new InterfaceKey(interfaceUuidStr.getInterfaceName());
            Optional<String> remoteIp = geniusProvider.getRemoteIpAddress(interfaceUuidStr.getInterfaceName());
            entries.add(ClassifierEntry.buildEgressEntry(interfaceKey, remoteIp.orElse(nodeIp)));
        });
    });
    return entries;
}
Also used : HashMap(java.util.HashMap) DpnIdType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ClassifierRenderableEntry(org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry) ArrayList(java.util.ArrayList) List(java.util.List) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) HashSet(java.util.HashSet)

Example 28 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports in project netvirt by opendaylight.

the class GeniusProvider method getInterfacesFromNode.

public List<Interfaces> getInterfacesFromNode(NodeId nodeId) {
    // getPortsOnBridge() only returns Tunnel ports, so instead using getDpnInterfaceList.
    GetDpnInterfaceListInputBuilder inputBuilder = new GetDpnInterfaceListInputBuilder();
    inputBuilder.setDpid(BigInteger.valueOf(Long.parseLong(nodeId.getValue().split(":")[1])));
    GetDpnInterfaceListInput input = inputBuilder.build();
    try {
        LOG.debug("getInterfacesFromNode: invoking rpc");
        RpcResult<GetDpnInterfaceListOutput> output = interfaceManagerRpcService.getDpnInterfaceList(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getInterfacesFromNode({}) failed: {}", input, output);
            return Collections.emptyList();
        }
        LOG.debug("getInterfacesFromNode({}) succeeded: {}", input, output);
        return output.getResult().getInterfaces();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getInterfacesFromNode failed to retrieve target interface name: ", e);
    }
    return Collections.emptyList();
}
Also used : GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) GetDpnInterfaceListInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 29 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports in project netvirt by opendaylight.

the class NetvirtProvider method getLogicalInterfacesFromNeutronNetwork.

public List<String> getLogicalInterfacesFromNeutronNetwork(NeutronNetwork nw) {
    InstanceIdentifier<NetworkMap> networkMapIdentifier = getNetworkMapIdentifier(new Uuid(nw.getNetworkUuid()));
    NetworkMap networkMap = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier).orNull();
    if (networkMap == null) {
        LOG.warn("getLogicalInterfacesFromNeutronNetwork cant get NetworkMap for NW UUID [{}]", nw.getNetworkUuid());
        return Collections.emptyList();
    }
    List<String> interfaces = new ArrayList<>();
    List<Uuid> subnetUuidList = networkMap.getSubnetIdList();
    if (subnetUuidList != null) {
        for (Uuid subnetUuid : subnetUuidList) {
            InstanceIdentifier<Subnetmap> subnetId = getSubnetMapIdentifier(subnetUuid);
            Subnetmap subnet = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetId).orNull();
            if (subnet == null) {
                LOG.warn("getLogicalInterfacesFromNeutronNetwork cant get Subnetmap for NW UUID [{}] Subnet UUID " + "[{}]", nw.getNetworkUuid(), subnetUuid.getValue());
                continue;
            }
            if (subnet.getPortList() == null || subnet.getPortList().isEmpty()) {
                LOG.warn("getLogicalInterfacesFromNeutronNetwork No ports on Subnet: NW UUID [{}] Subnet UUID [{}]", nw.getNetworkUuid(), subnetUuid.getValue());
                continue;
            }
            subnet.getPortList().forEach(portId -> interfaces.add(portId.getValue()));
        }
    }
    return interfaces;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) NetworkMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMap)

Example 30 with Ports

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports in project bgpcep by opendaylight.

the class NumericOperandParserTest method testSerializeOneByte.

@Test
public void testSerializeOneByte() {
    final ByteBuf nlriByteBuf = Unpooled.buffer();
    final List<Codes> codes = new ArrayList<>();
    // create 3 ports without end-of-list bit set
    for (int i = 0; i < 3; i++) {
        codes.add(new CodesBuilder().setOp(new NumericOperand(false, false, true, false, false)).setValue((short) (100 + i)).build());
    }
    NumericOneByteOperandParser.INSTANCE.serialize(codes, nlriByteBuf);
    assertArrayEquals(ONE_BYTE_CODE_LIST, ByteArray.readAllBytes(nlriByteBuf));
}
Also used : NumericOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.NumericOperand) Codes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) CodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.icmp.code._case.CodesBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)21 BigInteger (java.math.BigInteger)16 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)13 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)12 Test (org.junit.Test)11 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)11 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)8 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)7 ExecutionException (java.util.concurrent.ExecutionException)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 ByteBuf (io.netty.buffer.ByteBuf)5 HashSet (java.util.HashSet)4 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)4 RouterPortsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPortsKey)4 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports)4