use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation in project netvirt by opendaylight.
the class TerminationPointCmd method transform.
@Override
public TerminationPoint transform(InstanceIdentifier<Node> nodePath, TerminationPoint src) {
HwvtepPhysicalPortAugmentation augmentation = src.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (augmentation == null) {
return new TerminationPointBuilder(src).build();
}
String nodeIdVal = nodePath.firstKeyOf(Node.class).getNodeId().getValue();
int idx = nodeIdVal.indexOf("/physicalswitch");
if (idx > 0) {
nodeIdVal = nodeIdVal.substring(0, idx);
nodePath = HwvtepHAUtil.convertToInstanceIdentifier(nodeIdVal);
}
final InstanceIdentifier<Node> path = nodePath;
TerminationPointBuilder tpBuilder = new TerminationPointBuilder(src);
tpBuilder.removeAugmentation(HwvtepPhysicalPortAugmentation.class);
HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalPortAugmentationBuilder(augmentation);
if (augmentation.getVlanBindings() != null && augmentation.getVlanBindings().size() > 0) {
tpAugmentationBuilder.setVlanBindings(augmentation.getVlanBindings().stream().map(vlanBindings -> {
VlanBindingsBuilder vlanBindingsBuilder = new VlanBindingsBuilder(vlanBindings);
vlanBindingsBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(vlanBindings.getLogicalSwitchRef(), path));
return vlanBindingsBuilder.build();
}).collect(Collectors.toList()));
}
tpBuilder.addAugmentation(HwvtepPhysicalPortAugmentation.class, tpAugmentationBuilder.build());
return tpBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation in project netvirt by opendaylight.
the class TerminationPointCmd method areEqual.
@Override
public boolean areEqual(TerminationPoint updated, TerminationPoint orig) {
if (!updated.getKey().equals(orig.getKey())) {
return false;
}
HwvtepPhysicalPortAugmentation updatedAugmentation = updated.getAugmentation(HwvtepPhysicalPortAugmentation.class);
HwvtepPhysicalPortAugmentation origAugmentation = orig.getAugmentation(HwvtepPhysicalPortAugmentation.class);
List<VlanBindings> up = updatedAugmentation != null ? updatedAugmentation.getVlanBindings() : null;
List<VlanBindings> or = origAugmentation != null ? origAugmentation.getVlanBindings() : null;
if (!areSameSize(up, or)) {
return false;
}
List<VlanBindings> added = diffOf(up, or, bindingsComparator);
if (added.size() != 0) {
return false;
}
List<VlanBindings> removed = diffOf(or, up, bindingsComparator);
if (removed.size() != 0) {
return 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 TestComparators method assertTerminationPoint.
public static void assertTerminationPoint(List<String> terminationPointNames, InstanceIdentifier<Node> d1ps, InstanceIdentifier<Node> haPsa, ReadWriteTransaction readWriteTransaction, Node nodeD, Node nodeHa) throws ReadFailedException {
for (String portName : terminationPointNames) {
InstanceIdentifier<TerminationPoint> tpPathd = d1ps.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
TerminationPoint tpNoded = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathd).checkedGet().get();
HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationD = tpNoded.getAugmentation(HwvtepPhysicalPortAugmentation.class);
InstanceIdentifier<TerminationPoint> tpPathha = haPsa.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
TerminationPoint tpNodeha = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathha).checkedGet().get();
HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationHa = tpNodeha.getAugmentation(HwvtepPhysicalPortAugmentation.class);
assertEquals("Termination point hwvtep-node-name should be same", hwvtepPhysicalPortAugmentationD.getHwvtepNodeName(), hwvtepPhysicalPortAugmentationHa.getHwvtepNodeName());
List<VlanBindings> vlanBindingsesD = hwvtepPhysicalPortAugmentationD.getVlanBindings();
List<VlanBindings> vlanBindingsesHa = hwvtepPhysicalPortAugmentationHa.getVlanBindings();
assertEquals("Size of VlanBindings should be same", vlanBindingsesD.size(), vlanBindingsesHa.size());
List<Integer> vlanKeysD = new ArrayList<>();
List<Integer> vlanKeysHa = new ArrayList<>();
String logicalSwitchRefD = new String();
String logicalSwitchRefHa = new String();
List<String> logicalSwitchNameD = new ArrayList<>();
List<String> logicalSwitchNameHa = new ArrayList<>();
if (vlanBindingsesD.size() == vlanBindingsesHa.size()) {
for (int i = 0; i < vlanBindingsesD.size(); i++) {
vlanKeysD.add(vlanBindingsesD.get(i).getVlanIdKey().getValue());
logicalSwitchRefD = vlanBindingsesD.get(i).getLogicalSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
logicalSwitchNameD.add(vlanBindingsesD.get(i).getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
vlanKeysHa.add(vlanBindingsesHa.get(i).getVlanIdKey().getValue());
logicalSwitchRefHa = vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
logicalSwitchNameHa.add(vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
}
assertTrue(vlanKeysD.containsAll(vlanKeysHa));
assertTrue(logicalSwitchRefD.equals(nodeD.getNodeId().getValue()));
assertTrue(logicalSwitchRefHa.equals(nodeHa.getNodeId().getValue()));
assertTrue(logicalSwitchNameD.containsAll(logicalSwitchNameHa));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method added.
@Override
protected void added(InstanceIdentifier<TerminationPoint> identifier, final TerminationPoint add) {
final HwvtepPhysicalPortAugmentation portAugmentation = add.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (portAugmentation != null) {
final NodeId nodeId = identifier.firstIdentifierOf(Node.class).firstKeyOf(Node.class).getNodeId();
elanClusterUtils.runOnlyInOwnerNode(HwvtepSouthboundConstants.ELAN_ENTITY_NAME, () -> handlePortAdded(add, nodeId));
return;
}
LOG.trace("physical locator available {}", identifier);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method removed.
@Override
protected void removed(InstanceIdentifier<TerminationPoint> identifier, TerminationPoint del) {
LOG.trace("physical locator removed {}", identifier);
final HwvtepPhysicalPortAugmentation portAugmentation = del.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (portAugmentation != null) {
elanClusterUtils.runOnlyInOwnerNode(HwvtepSouthboundConstants.ELAN_ENTITY_NAME, "Handling Physical port delete", () -> handlePortDeleted(identifier));
}
}
Aggregations