Search in sources :

Example 11 with VlanBindings

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings in project netvirt by opendaylight.

the class L2GwValidateCli method verifyVlanBindings.

private boolean verifyVlanBindings(InstanceIdentifier<Node> nodeIid, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
    boolean valid = true;
    NodeId nodeId = nodeIid.firstKeyOf(Node.class).getNodeId();
    if (hwVtepDevice.getInterfaces() == null) {
        return false;
    }
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
        NodeId switchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, hwVtepDevice.getDeviceName());
        InstanceIdentifier<Node> physicalSwitchNodeIid = topoIid.child(Node.class, new NodeKey(switchNodeId));
        InstanceIdentifier<TerminationPoint> terminationPointIid = getPhysicalPortTerminationPointIid(switchNodeId, deviceInterface.getInterfaceName());
        TerminationPoint operationalTerminationPoint = (TerminationPoint) getData(operationalNodesData, physicalSwitchNodeIid, terminationPointIid);
        if (operationalTerminationPoint == null) {
            valid = false;
            pw.println("Failed to find the operational port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " nodeid " + nodeId.getValue());
            continue;
        }
        TerminationPoint configTerminationPoint = (TerminationPoint) getData(configNodesData, physicalSwitchNodeIid, terminationPointIid);
        if (configTerminationPoint == null) {
            valid = false;
            pw.println("Failed to find the configurational port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
            continue;
        }
        List<VlanBindings> expectedVlans = new ArrayList<>();
        if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
            for (Integer vlanId : deviceInterface.getSegmentationIds()) {
                expectedVlans.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
            }
        } else {
            expectedVlans.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
        }
        HwvtepPhysicalPortAugmentation portAugmentation = configTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class);
        if (portAugmentation == null || HwvtepHAUtil.isEmptyList(portAugmentation.getVlanBindings())) {
            pw.println("Failed to find the config vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
            valid = false;
            continue;
        }
        portAugmentation = operationalTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class);
        if (portAugmentation == null || HwvtepHAUtil.isEmptyList(portAugmentation.getVlanBindings())) {
            pw.println("Failed to find the operational vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
            valid = false;
            continue;
        }
        VlanBindings expectedBindings = !expectedVlans.isEmpty() ? expectedVlans.get(0) : null;
        boolean foundBindings = false;
        List<VlanBindings> vlanBindingses = configTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class).getVlanBindings();
        for (VlanBindings actual : vlanBindingses) {
            if (actual.equals(expectedBindings)) {
                foundBindings = true;
                break;
            }
        }
        if (!foundBindings) {
            pw.println("Mismatch in vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
            pw.println("Failed to find the vlan bindings " + expectedBindings);
            pw.println("Actual bindings present in config are ");
            for (VlanBindings actual : vlanBindingses) {
                pw.println(actual.toString());
            }
            valid = false;
        }
    }
    return true;
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 12 with VlanBindings

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings in project netvirt by opendaylight.

the class NetworkL2gwDeviceInfoCli method printVlanBindings.

@SuppressWarnings("checkstyle:HiddenField")
void printVlanBindings(Node psNode, String elanName) {
    session.getConsole().println("Vlan Bindings :");
    session.getConsole().println(HEADINGVLAN);
    if (psNode == null) {
        return;
    }
    List<TerminationPoint> terminationPoints = psNode.getTerminationPoint();
    if (terminationPoints == null || terminationPoints.isEmpty()) {
        return;
    }
    for (TerminationPoint terminationPoint : terminationPoints) {
        HwvtepPhysicalPortAugmentation aug = terminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class);
        if (aug == null || aug.getVlanBindings() == null) {
            continue;
        }
        for (VlanBindings vlanBindings : aug.getVlanBindings()) {
            String lsFromremoteMac = getLogicalSwitchValue(vlanBindings.getLogicalSwitchRef());
            if (elanName.equals(lsFromremoteMac)) {
                session.getConsole().println(terminationPoint.getTpId().getValue() + GAP + vlanBindings.getVlanIdKey().toString());
            }
        }
    }
}
Also used : VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)

Example 13 with VlanBindings

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings in project genius by opendaylight.

the class HwvtepSouthboundUtils method createVlanBinding.

/**
 * Create vlan binding.
 *
 * @param nodeId
 *            the node id
 * @param vlanId
 *            the vlan id
 * @param logicalSwitchName
 *            the logical switch name
 * @return the vlan bindings
 */
public static VlanBindings createVlanBinding(NodeId nodeId, int vlanId, String logicalSwitchName) {
    VlanBindingsBuilder vbBuilder = new VlanBindingsBuilder();
    VlanBindingsKey vbKey = new VlanBindingsKey(new VlanId(vlanId));
    vbBuilder.setKey(vbKey);
    vbBuilder.setVlanIdKey(vbKey.getVlanIdKey());
    final InstanceIdentifier<LogicalSwitches> lSwitchIid = createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName));
    HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(lSwitchIid);
    vbBuilder.setLogicalSwitchRef(lsRef);
    return vbBuilder.build();
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) VlanBindingsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsKey) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) VlanBindingsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder)

Example 14 with VlanBindings

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings in project genius by opendaylight.

the class HwvtepUtils method mergeVlanBindings.

/**
 * Merge vlan bindings in the transaction.
 *
 * @param transaction
 *            the transaction
 * @param physicalSwitchNodeId
 *            the physical switch node id
 * @param phyPortName
 *            the phy port name
 * @param vlanBindings
 *            the vlan bindings
 */
public static void mergeVlanBindings(final WriteTransaction transaction, final NodeId physicalSwitchNodeId, final String phyPortName, final List<VlanBindings> vlanBindings) {
    HwvtepPhysicalPortAugmentation phyPortAug = new HwvtepPhysicalPortAugmentationBuilder().setHwvtepNodeName(new HwvtepNodeName(phyPortName)).setVlanBindings(vlanBindings).build();
    final InstanceIdentifier<HwvtepPhysicalPortAugmentation> iid = HwvtepSouthboundUtils.createPhysicalPortInstanceIdentifier(physicalSwitchNodeId, phyPortName);
    transaction.merge(LogicalDatastoreType.CONFIGURATION, iid, phyPortAug, true);
}
Also used : HwvtepPhysicalPortAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)

Aggregations

VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)8 HwvtepPhysicalPortAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)7 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)6 ArrayList (java.util.ArrayList)5 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)5 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 L2gatewayConnection (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)3 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)3 VlanBindingsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder)3 BigInteger (java.math.BigInteger)2 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)2 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)2 HwvtepNodeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName)2 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1