Search in sources :

Example 86 with Extension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.

the class OpenFlow13ProviderTest method checkMatchTunDstIp.

private void checkMatchTunDstIp(Match match, Ipv4Address value) {
    GeneralAugMatchNodesNodeTableFlow genAug = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
    assertNotNull(genAug);
    List<ExtensionList> extensions = genAug.getExtensionList();
    for (ExtensionList extensionList : extensions) {
        Extension extension = extensionList.getExtension();
        NxAugMatchNodesNodeTableFlow nxAugMatch = extension.getAugmentation(NxAugMatchNodesNodeTableFlow.class);
        if (nxAugMatch.getNxmNxTunIpv4Dst() != null) {
            assertEquals(nxAugMatch.getNxmNxTunIpv4Dst().getIpv4Address(), value);
        }
    }
}
Also used : Extension(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension) GeneralAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow) NxAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList)

Example 87 with Extension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.

the class OpenFlow13ProviderTest method checkMatchC2.

private void checkMatchC2(Match match, long c2) {
    GeneralAugMatchNodesNodeTableFlow genAug = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
    assertNotNull(genAug);
    List<ExtensionList> extensions = genAug.getExtensionList();
    for (ExtensionList extensionList : extensions) {
        Extension extension = extensionList.getExtension();
        NxAugMatchNodesNodeTableFlow nxAugMatch = extension.getAugmentation(NxAugMatchNodesNodeTableFlow.class);
        if (nxAugMatch.getNxmNxNshc2() != null) {
            assertEquals(nxAugMatch.getNxmNxNshc2().getValue().longValue(), c2);
        }
    }
}
Also used : Extension(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension) GeneralAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow) NxAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList)

Example 88 with Extension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.

the class NeutronvpnUtils method getProviderNetworkType.

static ProviderTypes getProviderNetworkType(Network network) {
    if (network == null) {
        LOG.error("Error in getting provider network type since network is null");
        return null;
    }
    NetworkProviderExtension npe = network.getAugmentation(NetworkProviderExtension.class);
    if (npe != null) {
        Class<? extends NetworkTypeBase> networkTypeBase = npe.getNetworkType();
        if (networkTypeBase != null) {
            if (networkTypeBase.isAssignableFrom(NetworkTypeFlat.class)) {
                return ProviderTypes.FLAT;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeVlan.class)) {
                return ProviderTypes.VLAN;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeVxlan.class)) {
                return ProviderTypes.VXLAN;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeGre.class)) {
                return ProviderTypes.GRE;
            }
        }
    }
    LOG.error("Error in getting provider network type since network provider extension is null for network " + "{}", network.getUuid().getValue());
    return null;
}
Also used : NetworkTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeGre) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 89 with Extension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project netvirt by opendaylight.

the class NeutronPortChangeListener method update.

@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
    // in order to validate the supported vnic types from the hostconfig
    if (isPortTypeSwitchdev(original) && !isPortBound(original) && isPortBound(update)) {
        handleNeutronPortCreated(update);
    }
    final String portName = update.getUuid().getValue();
    Network network = neutronvpnUtils.getNeutronNetwork(update.getNetworkId());
    LOG.info("Update port {} from network {}", portName, update.getNetworkId().toString());
    if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
        LOG.error("neutron vpn received a port update() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
        return;
    }
    neutronvpnUtils.addToPortCache(update);
    if ((Strings.isNullOrEmpty(original.getDeviceOwner()) || Strings.isNullOrEmpty(original.getDeviceId()) || NeutronConstants.FLOATING_IP_DEVICE_ID_PENDING.equalsIgnoreCase(original.getDeviceId())) && !Strings.isNullOrEmpty(update.getDeviceOwner()) && !Strings.isNullOrEmpty(update.getDeviceId())) {
        if (update.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
            handleRouterInterfaceAdded(update);
            return;
        }
        if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) {
            handleRouterGatewayUpdated(update);
        } else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(update.getDeviceOwner())) {
            handleFloatingIpPortUpdated(original, update);
        }
    } else {
        Set<FixedIps> oldIPs = getFixedIpSet(original.getFixedIps());
        Set<FixedIps> newIPs = getFixedIpSet(update.getFixedIps());
        if (!oldIPs.equals(newIPs)) {
            handleNeutronPortUpdated(original, update);
        }
    }
    // check if port security enabled/disabled as part of port update
    boolean origSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(original);
    boolean updatedSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(update);
    if (origSecurityEnabled || updatedSecurityEnabled) {
        InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
        jobCoordinator.enqueueJob("PORT- " + portName, () -> {
            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
            try {
                Optional<Interface> optionalInf = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
                if (optionalInf.isPresent()) {
                    InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
                    InterfaceAcl infAcl = handlePortSecurityUpdated(original, update, origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
                    interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
                    LOG.info("update: Of-port-interface updation for port {}", portName);
                    // Update OFPort interface for this neutron port
                    wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, interfaceBuilder.build());
                } else {
                    LOG.warn("update: Interface {} is not present", portName);
                }
            } catch (ReadFailedException e) {
                LOG.error("update: Failed to update interface {}", portName, e);
            }
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            futures.add(wrtConfigTxn.submit());
            return futures;
        });
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ArrayList(java.util.ArrayList) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)

Example 90 with Extension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.

the class ArpOpConvertor method convert.

@Override
public MatchEntry convert(Extension extension) {
    Optional<NxmOfArpOpGrouping> matchGrouping = MatchUtil.ARP_OP_RESOLVER.getExtension(extension);
    if (!matchGrouping.isPresent()) {
        throw new CodecPreconditionException(extension);
    }
    Integer value = matchGrouping.get().getNxmOfArpOp().getValue();
    ArpOpCaseValueBuilder arpOpCaseValueBuilder = new ArpOpCaseValueBuilder();
    arpOpCaseValueBuilder.setArpOpValues(new ArpOpValuesBuilder().setValue(value).build());
    return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpOp.class, Nxm0Class.class, arpOpCaseValueBuilder.build()).build();
}
Also used : ArpOpCaseValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpOpCaseValueBuilder) CodecPreconditionException(org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException) Nxm0Class(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class) ArpOpValuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.op.grouping.ArpOpValuesBuilder) NxmOfArpOpGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfArpOpGrouping) NxmOfArpOp(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.op.grouping.NxmOfArpOp)

Aggregations

Extension (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension)57 Test (org.junit.Test)46 CodecPreconditionException (org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException)32 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)26 NxAugMatchNodesNodeTableFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow)23 Augmentation (org.opendaylight.yangtools.yang.binding.Augmentation)23 Before (org.junit.Before)21 NxAugMatchNodesNodeTableFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder)18 Nxm1Class (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class)17 NxAugMatchNotifPacketIn (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn)14 NxAugMatchNotifSwitchFlowRemoved (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved)14 NxAugMatchRpcGetFlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats)14 ExtensionList (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList)11 GeneralAugMatchNodesNodeTableFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow)10 Consumer (java.util.function.Consumer)9 Nxm0Class (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class)7 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)7 ArrayList (java.util.ArrayList)5 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)5 NxAugMatchRpcAddFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcAddFlowBuilder)5