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;
}
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());
}
}
}
}
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);
}
Aggregations