Search in sources :

Example 1 with NeutronNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork in project netvirt by opendaylight.

the class ConfigurationClassifierImpl method getEntriesForAce.

private Set<ClassifierRenderableEntry> getEntriesForAce(Ace ace) {
    String ruleName = ace.getRuleName();
    LOG.debug("Generating classifier entries for Ace: {}", ruleName);
    LOG.trace("Ace details: {}", ace);
    Optional<NetvirtsfcAclActions> sfcActions = Optional.ofNullable(ace.getActions()).map(actions -> actions.getAugmentation(RedirectToSfc.class));
    String rspName = sfcActions.map(NetvirtsfcAclActions::getRspName).map(Strings::emptyToNull).orElse(null);
    String sfpName = sfcActions.map(NetvirtsfcAclActions::getSfpName).map(Strings::emptyToNull).orElse(null);
    if (rspName == null && sfpName == null) {
        LOG.debug("Ace {} ignored: no valid SFC redirect action", ruleName);
        return Collections.emptySet();
    }
    if (rspName != null && sfpName != null) {
        LOG.warn("Ace {} ignored: both SFP and a RSP as redirect actions not supported", ruleName);
        return Collections.emptySet();
    }
    Matches matches = ace.getMatches();
    if (matches == null) {
        LOG.warn("Ace {} ignored: no matches", ruleName);
        return Collections.emptySet();
    }
    NeutronNetwork network = matches.getAugmentation(NeutronNetwork.class);
    if (sfpName != null && network != null) {
        LOG.warn("Ace {} ignored: SFP redirect action with neutron network match not supported", ruleName);
        return Collections.emptySet();
    }
    String sourcePort = Optional.ofNullable(matches.getAugmentation(NeutronPorts.class)).map(NeutronPorts::getSourcePortUuid).map(Strings::emptyToNull).orElse(null);
    String destinationPort = Optional.ofNullable(matches.getAugmentation(NeutronPorts.class)).map(NeutronPorts::getDestinationPortUuid).map(Strings::emptyToNull).orElse(null);
    if (rspName != null) {
        return getEntriesForRspRedirect(ruleName, sourcePort, destinationPort, network, rspName, matches);
    }
    return getEntriesForSfpRedirect(ruleName, sourcePort, destinationPort, sfpName, matches);
}
Also used : NetvirtsfcAclActions(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NetvirtsfcAclActions) NeutronNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork) Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) AclMatches(org.opendaylight.netvirt.sfc.classifier.utils.AclMatches) RedirectToSfc(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfc) NeutronPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPorts)

Example 2 with NeutronNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork in project netvirt by opendaylight.

the class ConfigurationClassifierImpl method getEntriesForRspRedirect.

private Set<ClassifierRenderableEntry> getEntriesForRspRedirect(String ruleName, String sourcePort, String destinationPort, NeutronNetwork neutronNetwork, String rspName, Matches matches) {
    RenderedServicePath rsp = sfcProvider.getRenderedServicePath(rspName).orElse(null);
    if (rsp == null) {
        LOG.debug("Ace {} ignored: RSP {} not yet available", ruleName, rspName);
        return Collections.emptySet();
    }
    if (destinationPort != null) {
        LOG.warn("Ace {}: destination port is ignored combined with RSP redirect");
    }
    List<String> interfaces = new ArrayList<>();
    if (neutronNetwork != null) {
        interfaces.addAll(netvirtProvider.getLogicalInterfacesFromNeutronNetwork(neutronNetwork));
    }
    if (sourcePort != null) {
        interfaces.add(sourcePort);
    }
    if (interfaces.isEmpty()) {
        LOG.debug("Ace {} ignored: no interfaces to match against", ruleName);
        return Collections.emptySet();
    }
    return this.buildEntries(ruleName, interfaces, matches, rsp);
}
Also used : ArrayList(java.util.ArrayList) RenderedServicePath(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath)

Example 3 with NeutronNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork 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)

Aggregations

ArrayList (java.util.ArrayList)2 AclMatches (org.opendaylight.netvirt.sfc.classifier.utils.AclMatches)1 RenderedServicePath (org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath)1 Matches (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1 NetworkMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMap)1 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)1 NetvirtsfcAclActions (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NetvirtsfcAclActions)1 NeutronNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork)1 NeutronPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronPorts)1 RedirectToSfc (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.RedirectToSfc)1