use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method removed.
@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
NodeId nodeId = getNodeId(identifier);
String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
l2GatewayCache.remove(psName);
LOG.debug("{} details removed from L2Gateway Cache", psName);
MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
} else {
LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
}
l2GwDevice.setConnected(false);
// ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
} else {
LOG.error("Unable to find L2 Gateway details for {}", psName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.
the class HwvtepHAUtil method deletePSNodesOfNode.
/**
* Delete PS data of HA node of Config Data tree.
*
* @param key Node object
* @param haNode Ha Node from which to be deleted
* @param tx Transaction
* @throws ReadFailedException Exception thrown if read fails
*/
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, ReadWriteTransaction tx) throws ReadFailedException {
// read from switches attribute and clean up them
HwvtepGlobalAugmentation globalAugmentation = haNode.getAugmentation(HwvtepGlobalAugmentation.class);
if (globalAugmentation == null) {
return;
}
HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
List<Switches> switches = globalAugmentation.getSwitches();
if (switches != null) {
for (Switches switche : switches) {
InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
deleteNodeIfPresent(tx, CONFIGURATION, psId);
deleted.put(psId, Boolean.TRUE);
}
}
// also read from managed by attribute of switches and cleanup them as a back up if the above cleanup fails
Optional<Topology> topologyOptional = tx.read(CONFIGURATION, key.firstIdentifierOf(Topology.class)).checkedGet();
String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
if (topologyOptional.isPresent()) {
Topology topology = topologyOptional.get();
if (topology.getNode() != null) {
for (Node psNode : topology.getNode()) {
PhysicalSwitchAugmentation ps = psNode.getAugmentation(PhysicalSwitchAugmentation.class);
if (ps != null) {
InstanceIdentifier<Node> iid = (InstanceIdentifier<Node>) ps.getManagedBy().getValue();
String nodeIdVal = iid.firstKeyOf(Node.class).getNodeId().getValue();
if (deletedNodeId.equals(nodeIdVal)) {
InstanceIdentifier<Node> psNodeId = convertToInstanceIdentifier(psNode.getNodeId().getValue());
if (deleted.containsKey(psNodeId)) {
deleteNodeIfPresent(tx, CONFIGURATION, psNodeId);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.
the class NodeConnectedHandler method copyChildPSOpToHAPS.
/**
* Copy child physical switch node data to HA physical switch data of Operational data tree.
*
* @param childPsNode HA child PS node
* @param haPath HA node path
* @param haPspath Ha Physical Switch Node path
* @param tx Transaction
* @throws ReadFailedException Exception thrown if read fails
*/
public void copyChildPSOpToHAPS(Node childPsNode, InstanceIdentifier<Node> haPath, InstanceIdentifier<Node> haPspath, ReadWriteTransaction tx) throws ReadFailedException {
NodeBuilder haPSNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haPspath);
PhysicalSwitchAugmentationBuilder dstBuilder = new PhysicalSwitchAugmentationBuilder();
PhysicalSwitchAugmentation src = childPsNode.getAugmentation(PhysicalSwitchAugmentation.class);
Node existingHAPSNode = HwvtepHAUtil.readNode(tx, OPERATIONAL, haPspath);
PhysicalSwitchAugmentation existingHAPSAugumentation = HwvtepHAUtil.getPhysicalSwitchAugmentationOfNode(existingHAPSNode);
psAugmentationMerger.mergeOperationalData(dstBuilder, existingHAPSAugumentation, src, haPath);
psNodeMerger.mergeOperationalData(haPSNodeBuilder, existingHAPSNode, childPsNode, haPath);
mergeOpManagedByAttributes(src, dstBuilder, haPath);
haPSNodeBuilder.addAugmentation(PhysicalSwitchAugmentation.class, dstBuilder.build());
Node haPsNode = haPSNodeBuilder.build();
tx.merge(OPERATIONAL, haPspath, haPsNode, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.
the class NodeConnectedHandler method mergeOpManagedByAttributes.
/**
* Merge data to Physical switch from HA node path .
*
* @param psAugmentation Physical Switch Augmation of Node
* @param builder Physical Switch Augmentation Builder
* @param haNodePath HA node Path
*/
public void mergeOpManagedByAttributes(PhysicalSwitchAugmentation psAugmentation, PhysicalSwitchAugmentationBuilder builder, InstanceIdentifier<Node> haNodePath) {
builder.setManagedBy(new HwvtepGlobalRef(haNodePath));
builder.setHwvtepNodeName(psAugmentation.getHwvtepNodeName());
builder.setHwvtepNodeDescription(psAugmentation.getHwvtepNodeDescription());
builder.setTunnelIps(psAugmentation.getTunnelIps());
builder.setPhysicalSwitchUuid(HwvtepHAUtil.getUUid(psAugmentation.getHwvtepNodeName().getValue()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation in project netvirt by opendaylight.
the class NodeCopier method mergeOpManagedByAttributes.
public void mergeOpManagedByAttributes(PhysicalSwitchAugmentation psAugmentation, PhysicalSwitchAugmentationBuilder builder, InstanceIdentifier<Node> haNodePath) {
builder.setManagedBy(new HwvtepGlobalRef(haNodePath));
if (psAugmentation != null) {
builder.setHwvtepNodeName(psAugmentation.getHwvtepNodeName());
builder.setHwvtepNodeDescription(psAugmentation.getHwvtepNodeDescription());
builder.setTunnelIps(psAugmentation.getTunnelIps());
if (psAugmentation.getHwvtepNodeName() != null) {
builder.setPhysicalSwitchUuid(HwvtepHAUtil.getUUid(psAugmentation.getHwvtepNodeName().getValue()));
}
}
}
Aggregations