Search in sources :

Example 6 with Types

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types in project netvirt by opendaylight.

the class QosPolicyChangeListener method supportedQoSRuleTypes.

private void supportedQoSRuleTypes() {
    QosRuleTypesBuilder qrtBuilder = new QosRuleTypesBuilder();
    List<RuleTypes> value = new ArrayList<>();
    value.add(getRuleTypes("bandwidth_limit_rules"));
    value.add(getRuleTypes("dscp_marking_rules"));
    qrtBuilder.setRuleTypes(value);
    LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
        InstanceIdentifier instanceIdentifier = InstanceIdentifier.create(Neutron.class).child(QosRuleTypes.class);
        tx.merge(instanceIdentifier, qrtBuilder.build());
    }), LOG, "Error setting up supported QoS rule types");
}
Also used : QosRuleTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosRuleTypesBuilder) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) RuleTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.rule.types.RuleTypes) LoggerFactory(org.slf4j.LoggerFactory) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RuleTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.rule.types.RuleTypesBuilder) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) QosPolicies(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosPolicies) ArrayList(java.util.ArrayList) QosServiceRecoveryHandler(org.opendaylight.netvirt.qosservice.recovery.QosServiceRecoveryHandler) RecoverableListener(org.opendaylight.serviceutils.srm.RecoverableListener) QosRuleTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosRuleTypes) Inject(javax.inject.Inject) QosRuleTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosRuleTypesBuilder) PreDestroy(javax.annotation.PreDestroy) DscpmarkingRules(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.DscpmarkingRules) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) Logger(org.slf4j.Logger) AbstractClusteredAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ServiceRecoveryRegistry(org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy) Collections(java.util.Collections) NonNull(org.eclipse.jdt.annotation.NonNull) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) BandwidthLimitRules(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.qos.policy.BandwidthLimitRules) ArrayList(java.util.ArrayList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RuleTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.rule.types.RuleTypes) QosRuleTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosRuleTypes) QosRuleTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.QosRuleTypes)

Example 7 with Types

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types in project netvirt by opendaylight.

the class NeutronPortChangeListener method update.

@Override
public void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
    LOG.trace("Received port update event: original={}, update={}", original, update);
    if (Objects.equals(original, update)) {
        return;
    }
    // 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());
    if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
        LOG.warn("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 (NeutronConstants.DEVICE_OWNER_ROUTER_INF.equals(update.getDeviceOwner())) {
            handleRouterInterfaceAdded(update);
            return;
        }
        if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) {
            handleRouterGatewayUpdated(update, false);
        } else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(update.getDeviceOwner())) {
            handleFloatingIpPortUpdated(original, update);
        }
    } else {
        Set<FixedIps> oldIPs = getFixedIpSet(new ArrayList<>(original.nonnullFixedIps().values()));
        Set<FixedIps> newIPs = getFixedIpSet(new ArrayList<>(update.nonnullFixedIps().values()));
        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);
    boolean isDhcpServerPort = neutronvpnConfig.isLimitBumtrafficToDhcpserver() && NeutronvpnUtils.isDhcpServerPort(update);
    if (origSecurityEnabled || updatedSecurityEnabled || isDhcpServerPort) {
        InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
        jobCoordinator.enqueueJob("PORT- " + portName, () -> {
            ListenableFuture<?> future = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
                Optional<Interface> optionalInf = confTx.read(interfaceIdentifier).get();
                if (optionalInf.isPresent()) {
                    InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
                    if (origSecurityEnabled || updatedSecurityEnabled) {
                        InterfaceAcl infAcl = handlePortSecurityUpdated(original, update, origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
                        interfaceBuilder.addAugmentation(infAcl);
                    } else if (isDhcpServerPort) {
                        Set<FixedIps> oldIPs = getFixedIpSet(new ArrayList<>(original.nonnullFixedIps().values()));
                        Set<FixedIps> newIPs = getFixedIpSet(new ArrayList<>(update.nonnullFixedIps().values()));
                        if (!oldIPs.equals(newIPs)) {
                            InterfaceAcl infAcl = neutronvpnUtils.getDhcpInterfaceAcl(update);
                            interfaceBuilder.addAugmentation(infAcl);
                        }
                    }
                    LOG.info("update: Of-port-interface updation for port {}", portName);
                    // Update OFPort interface for this neutron port
                    confTx.put(interfaceIdentifier, interfaceBuilder.build());
                } else {
                    LOG.warn("update: Interface {} is not present", portName);
                }
            });
            LoggingFutures.addErrorLogging(future, LOG, "update: Failed to update interface {} with networkId {}", portName, network);
            return Collections.singletonList(future);
        });
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) 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) 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 8 with Types

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types in project bgpcep by opendaylight.

the class CreateTunnelInstructionExecutor method buildAddressFamily.

private static AddressFamily buildAddressFamily(final TerminationPoint sp, final TerminationPoint dp) {
    // We need the IGP augmentation -- it has IP addresses
    final TerminationPoint1 sp1 = requireNonNull(sp.augmentation(TerminationPoint1.class));
    final TerminationPoint1 dp1 = requireNonNull(dp.augmentation(TerminationPoint1.class));
    // Get the types
    final TerminationPointType spt = sp1.getIgpTerminationPointAttributes().getTerminationPointType();
    final TerminationPointType dpt = dp1.getIgpTerminationPointAttributes().getTerminationPointType();
    // The types have to match
    Preconditions.checkArgument(spt.implementedInterface().equals(dpt.implementedInterface()));
    // And they have to actually be Ip
    final Ip sips = (Ip) spt;
    final Ip dips = (Ip) dpt;
    /*
         * Now a bit of magic. We need to find 'like' addresses, e.g. both
         * IPv4 or both IPv6. We are in IPv6-enabled world now, so let's
         * prefer that.
         */
    Optional<AddressFamily> ret = findIpv6(sips.getIpAddress(), dips.getIpAddress());
    if (!ret.isPresent()) {
        ret = findIpv4(sips.getIpAddress(), dips.getIpAddress());
    }
    // We need to have a ret now
    Preconditions.checkArgument(ret != null, "Failed to find like Endpoint addresses");
    return ret.get();
}
Also used : TerminationPoint1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1) Ip(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.Ip) AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily) TerminationPointType(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.TerminationPointType)

Example 9 with Types

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types in project bgpcep by opendaylight.

the class RouteDistinguisherUtil method parseRouteDistinguisher.

/**
 * Parses three types of route distinguisher from given ByteBuf.
 */
public static RouteDistinguisher parseRouteDistinguisher(final ByteBuf buffer) {
    Preconditions.checkState(buffer != null && buffer.isReadable(RD_LENGTH), "Cannot read Route Distinguisher from provided buffer.");
    final int type = buffer.readUnsignedShort();
    final RDType rdType = RDType.valueOf(type);
    switch(rdType) {
        case AS_2BYTE:
            return new RouteDistinguisher(new RdTwoOctetAs(new StringBuilder().append(type).append(SEPARATOR).append(buffer.readUnsignedShort()).append(SEPARATOR).append(buffer.readUnsignedInt()).toString()));
        case IPV4:
            return new RouteDistinguisher(new RdIpv4(new StringBuilder().append(Ipv4Util.addressForByteBuf(buffer).getValue()).append(SEPARATOR).append(buffer.readUnsignedShort()).toString()));
        case AS_4BYTE:
            return new RouteDistinguisher(new RdAs(new StringBuilder().append(buffer.readUnsignedInt()).append(SEPARATOR).append(buffer.readUnsignedShort()).toString()));
        default:
            // now that this RD type is not supported, we want to read the remain 6 bytes
            // in order to get the byte index correct
            final StringBuilder routeDistiguisher = new StringBuilder();
            for (int i = 0; i < 6; i++) {
                routeDistiguisher.append("0x").append(Integer.toHexString(buffer.readByte() & 0xFF)).append(' ');
            }
            LOG.debug("Invalid Route Distinguisher: type={}, rawRouteDistinguisherValue={}", type, routeDistiguisher);
            throw new IllegalArgumentException("Invalid Route Distinguisher type " + type);
    }
}
Also used : RdTwoOctetAs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdTwoOctetAs) RdAs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdAs) RdIpv4(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdIpv4) RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher)

Example 10 with Types

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createTypes.

private static List<Types> createTypes(final UnkeyedListNode typesData) {
    final List<Types> types = new ArrayList<>();
    for (final UnkeyedListEntryNode node : typesData.body()) {
        final TypesBuilder typesBuilder = new TypesBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> typesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> typesBuilder.setValue((Uint8) dataContainerChild.body()));
        types.add(typesBuilder.build());
    }
    return types;
}
Also used : Types(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types) Uint8(org.opendaylight.yangtools.yang.common.Uint8) TypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.TypesBuilder) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Network (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)3 HashSet (java.util.HashSet)2 Types (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.Types)2 TypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.type._case.TypesBuilder)2 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 PreDestroy (javax.annotation.PreDestroy)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)1 Executors (org.opendaylight.infrautils.utils.concurrent.Executors)1 LoggingFutures (org.opendaylight.infrautils.utils.concurrent.LoggingFutures)1 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)1 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)1 OPERATIONAL (org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL)1