Search in sources :

Example 6 with OvsdbTerminationPointAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation in project netvirt by opendaylight.

the class ElanBridgeManager method copyBridgeToConfig.

private void copyBridgeToConfig(Node brIntNode) {
    NodeBuilder bridgeNodeBuilder = new NodeBuilder(brIntNode);
    // termination points need to be masssaged to remove the ifindex field
    // which are not allowed in the config data store
    List<TerminationPoint> terminationPoints = brIntNode.getTerminationPoint();
    if (terminationPoints != null) {
        List<TerminationPoint> newTerminationPoints = new ArrayList<>();
        for (TerminationPoint tp : terminationPoints) {
            OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
            TerminationPointBuilder tpBuilder = new TerminationPointBuilder(tp);
            if (ovsdbTerminationPointAugmentation != null) {
                OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(ovsdbTerminationPointAugmentation);
                tpAugmentationBuilder.setIfindex(null);
                tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
            }
            newTerminationPoints.add(tpBuilder.build());
        }
        bridgeNodeBuilder.setTerminationPoint(newTerminationPoints);
    }
    InstanceIdentifier<Node> brNodeIid = SouthboundUtils.createInstanceIdentifier(brIntNode.getNodeId());
    this.mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, brNodeIid, bridgeNodeBuilder.build());
}
Also used : OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 7 with OvsdbTerminationPointAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation in project netvirt by opendaylight.

the class TestInterfaceManager method getTunnelPortsOnBridge.

@Override
public List<OvsdbTerminationPointAugmentation> getTunnelPortsOnBridge(BigInteger dpnId) {
    if (dpnId == GeniusProviderTestParams.DPN_ID_NO_EXIST) {
        // Unfortunately, the getTunnelPortsOnBridge() method may return null
        return null;
    }
    if (dpnId == GeniusProviderTestParams.DPN_ID_NO_PORTS) {
        return Collections.emptyList();
    }
    OvsdbTerminationPointAugmentationBuilder tpAug = new OvsdbTerminationPointAugmentationBuilder();
    tpAug.setOfport(GeniusProviderTestParams.OF_PORT);
    if (dpnId == GeniusProviderTestParams.DPN_ID_NO_VXGPE_PORTS) {
        // Tunnel Termination Point that is NOT of type VXGPE
        tpAug.setInterfaceType(InterfaceTypeGre.class);
    } else {
        // Tunnel Termination Point that IS of type VXGPE
        tpAug.setInterfaceType(InterfaceTypeVxlan.class);
    }
    List<Options> opsList = new ArrayList<>();
    if (dpnId != GeniusProviderTestParams.DPN_ID_NO_OPTIONS) {
        OptionsBuilder opsBuilder = new OptionsBuilder();
        opsBuilder.setKey(new OptionsKey(GeniusProvider.OPTION_KEY_EXTS));
        opsBuilder.setValue(GeniusProvider.OPTION_VALUE_EXTS_GPE);
        opsList.add(opsBuilder.build());
    }
    tpAug.setOptions(opsList);
    List<OvsdbTerminationPointAugmentation> tpAugList = new ArrayList<>();
    tpAugList.add(tpAug.build());
    return tpAugList;
}
Also used : Options(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options) OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) ArrayList(java.util.ArrayList) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) OptionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder) OptionsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey)

Example 8 with OvsdbTerminationPointAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation in project netvirt by opendaylight.

the class QosNeutronUtils method setPortBandwidthLimits.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void setPortBandwidthLimits(Port port, BandwidthLimitRules bwLimit, WriteTransaction writeConfigTxn) {
    if (!qosEosHandler.isQosClusterOwner()) {
        LOG.trace("Not Qos Cluster Owner. Ignoring setting bandwidth limits");
        return;
    }
    LOG.trace("Setting bandwidth limits {} on Port {}", port, bwLimit);
    BigInteger dpId = getDpnForInterface(port.getUuid().getValue());
    if (dpId.equals(BigInteger.ZERO)) {
        LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
        return;
    }
    OvsdbBridgeRef bridgeRefEntry = getBridgeRefEntryFromOperDS(dpId);
    Optional<Node> bridgeNode = MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntry.getValue().firstIdentifierOf(Node.class), dataBroker);
    TerminationPoint tp = SouthboundUtils.getTerminationPointByExternalId(bridgeNode.get(), port.getUuid().getValue());
    OvsdbTerminationPointAugmentation ovsdbTp = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
    OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
    tpAugmentationBuilder.setName(ovsdbTp.getName());
    tpAugmentationBuilder.setIngressPolicingRate(bwLimit.getMaxKbps().longValue());
    tpAugmentationBuilder.setIngressPolicingBurst(bwLimit.getMaxBurstKbps().longValue());
    TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
    tpBuilder.setKey(tp.getKey());
    tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
    try {
        if (writeConfigTxn != null) {
            writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), tpBuilder.build());
        } else {
            MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(SouthboundUtils.OVSDB_TOPOLOGY_ID)).child(Node.class, bridgeNode.get().getKey()).child(TerminationPoint.class, new TerminationPointKey(tp.getKey())), tpBuilder.build());
        }
    } catch (Exception e) {
        LOG.error("Failure while setting BwLimitRule {} to port {}", bwLimit, port, e);
    }
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) BigInteger(java.math.BigInteger) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) OvsdbBridgeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with OvsdbTerminationPointAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation in project netvirt by opendaylight.

the class GeniusProvider method getEgressVxlanPortForNode.

public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
    List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(dpnId);
    if (tpList == null) {
        // Most likely the bridge doesnt exist for this dpnId
        LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]", dpnId);
        return Optional.empty();
    }
    for (OvsdbTerminationPointAugmentation tp : tpList) {
        if (tp == null) {
            // Technically we should never have a list with NULL entries, but
            // in a preliminary version of interfaceMgr.getTunnelPortsOnBridge()
            // we were getting a list where all termination point entries were
            // null. Leaving this check for now for protection.
            LOG.error("getEgressVxlanPortForNode received a NULL termination point from tpList on dpnId [{}]", dpnId);
            continue;
        }
        Class<? extends InterfaceTypeBase> ifType = tp.getInterfaceType();
        if (ifType.equals(InterfaceTypeVxlan.class)) {
            List<Options> tpOptions = tp.getOptions();
            for (Options tpOption : tpOptions) {
                // From the VXLAN Tunnels, we want the one with the GPE option set
                if (tpOption.getKey().getOption().equals(OPTION_KEY_EXTS)) {
                    if (tpOption.getValue().equals(OPTION_VALUE_EXTS_GPE)) {
                        return Optional.ofNullable(tp.getOfport());
                    }
                }
            }
        }
    }
    LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
    return Optional.empty();
}
Also used : Options(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)

Example 10 with OvsdbTerminationPointAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation in project genius by opendaylight.

the class InterfacemgrProvider method getTunnelPortsOnBridge.

/**
 * Get all termination points of type tunnel on a given DPN.
 *
 * @param dpnId
 *            Datapath Node Identifier
 *
 * @return If the data at the supplied path exists, returns a list of all termination point
 *         Augmentations of type tunnel
 */
@Override
public List<OvsdbTerminationPointAugmentation> getTunnelPortsOnBridge(BigInteger dpnId) {
    List<OvsdbTerminationPointAugmentation> tunnelPorts = new ArrayList<>();
    List<TerminationPoint> portList = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
    for (TerminationPoint ovsPort : portList) {
        OvsdbTerminationPointAugmentation portAug = ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class);
        if (portAug != null && SouthboundUtils.isInterfaceTypeTunnel(portAug.getInterfaceType())) {
            tunnelPorts.add(portAug);
        }
    }
    LOG.debug("Found {} tunnel ports on bridge {}", tunnelPorts.size(), dpnId);
    return tunnelPorts;
}
Also used : ArrayList(java.util.ArrayList) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Aggregations

OvsdbTerminationPointAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)11 ArrayList (java.util.ArrayList)6 BigInteger (java.math.BigInteger)4 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)4 List (java.util.List)3 Inject (javax.inject.Inject)3 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 InterfaceMetaUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils)3 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)3 OvsdbTerminationPointAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder)3 Options (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 Future (java.util.concurrent.Future)2 Singleton (javax.inject.Singleton)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 CONFIGURATION (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION)2 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)2