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 StaleVlanBindingsCleaner method cleanupStaleBindings.
private void cleanupStaleBindings(final String globalNodeId, final Map<String, List<InstanceIdentifier<VlanBindings>>> vlans, final String staleLogicalSwitch) {
LOG.trace("CleanupStaleBindings for logical switch {}", staleLogicalSwitch);
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
if (vlans.containsKey(staleLogicalSwitch)) {
vlans.get(staleLogicalSwitch).forEach((vlanIid) -> tx.delete(LogicalDatastoreType.CONFIGURATION, vlanIid));
}
}), LOG, "Failed to delete stale vlan bindings from node {}", globalNodeId);
elanL2GatewayUtils.scheduleDeleteLogicalSwitch(new NodeId(globalNodeId), staleLogicalSwitch, true);
}
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 PhysicalSwitchHelper method updatePort.
public static void updatePort(String portName, HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder, Map<Long, String> vlanBindings) {
updateVlanBindings(vlanBindings, tpAugmentationBuilder);
tpAugmentationBuilder.setPhysicalPortUuid(new Uuid(UUID.randomUUID().toString()));
}
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 PhysicalSwitchHelper method createVlanBinding.
public static VlanBindings createVlanBinding(Long key, String logicalSwitch) {
VlanBindingsBuilder vbBuilder = new VlanBindingsBuilder();
VlanBindingsKey vbKey = new VlanBindingsKey(new VlanId(key.intValue()));
vbBuilder.setKey(vbKey);
vbBuilder.setVlanIdKey(vbKey.getVlanIdKey());
HwvtepLogicalSwitchRef hwvtepLogicalSwitchRef = new HwvtepLogicalSwitchRef(createInstanceIdentifier(logicalSwitch));
vbBuilder.setLogicalSwitchRef(hwvtepLogicalSwitchRef);
return vbBuilder.build();
}
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 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.hwvtep.physical.port.attributes.VlanBindings in project netvirt by opendaylight.
the class ElanL2GatewayUtils method updateVlanBindingsInL2GatewayDevice.
/**
* Update vlan bindings in l2 gateway device.
*
* @param nodeId
* the node id
* @param logicalSwitchName
* the logical switch name
* @param hwVtepDevice
* the hardware device
* @param defaultVlanId
* the default vlan id
* @return the listenable future
*/
public ListenableFuture<Void> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
if (hwVtepDevice == null || hwVtepDevice.getInterfaces() == null || hwVtepDevice.getInterfaces().isEmpty()) {
String errMsg = "HwVtepDevice is null or interfaces are empty.";
LOG.error(errMsg);
return Futures.immediateFailedFuture(new RuntimeException(errMsg));
}
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
// Removed the check for checking terminationPoint present in OP or not
// for coniguring vlan bindings
// As we are not any more dependent on it , plugin takes care of this
// with port reconcilation.
List<VlanBindings> vlanBindings = new ArrayList<>();
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
}
HwvtepUtils.mergeVlanBindings(tx, nodeId, hwVtepDevice.getDeviceName(), deviceInterface.getInterfaceName(), vlanBindings);
}
LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}, LogicalSwitch: {}", nodeId.getValue(), logicalSwitchName);
});
}
Aggregations