Search in sources :

Example 6 with HwvtepPhysicalPortAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation 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 7 with HwvtepPhysicalPortAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation 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 8 with HwvtepPhysicalPortAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation 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

HwvtepPhysicalPortAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)8 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)4 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)4 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)4 ArrayList (java.util.ArrayList)2 HwvtepPhysicalPortAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)2 HwvtepNodeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName)1 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)1 VlanBindingsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder)1 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)1 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)1 TerminationPointBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder)1 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)1