From 2c2b63305708ae4ddccb092898c15a9a275c56a0 Mon Sep 17 00:00:00 2001 From: Gabriel Robitaille-Montpetit Date: Fri, 6 Nov 2015 18:59:19 -0500 Subject: [PATCH] Fixed EVC create Change-Id: I267a4508d3fc5966fad4bb114cdc8f7f7425f582 Signed-off-by: Gabriel Robitaille-Montpetit --- .../unimgr/command/EvcCreateCommand.java | 128 ++++++++++-------- .../unimgr/command/EvcDeleteCommand.java | 40 +++--- .../unimgr/command/UniCreateCommand.java | 2 +- .../unimgr/command/UniDeleteCommand.java | 15 +- .../unimgr/command/UniUpdateCommand.java | 4 +- .../unimgr/impl/UnimgrDataChangeListener.java | 18 ++- .../unimgr/impl/UnimgrMapper.java | 38 ++++-- .../opendaylight/unimgr/impl/UnimgrUtils.java | 48 +------ 8 files changed, 148 insertions(+), 145 deletions(-) diff --git a/impl/src/main/java/org/opendaylight/unimgr/command/EvcCreateCommand.java b/impl/src/main/java/org/opendaylight/unimgr/command/EvcCreateCommand.java index 295f338f..c5bf7ea5 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/command/EvcCreateCommand.java +++ b/impl/src/main/java/org/opendaylight/unimgr/command/EvcCreateCommand.java @@ -35,13 +35,12 @@ public class EvcCreateCommand extends AbstractCreateCommand { super.changes = changes; } - @SuppressWarnings("unchecked") @Override public void execute() { for (Entry, DataObject> created : changes.entrySet()) { if (created.getValue() != null && created.getValue() instanceof EvcAugmentation) { EvcAugmentation evc = (EvcAugmentation) created.getValue(); - LOG.info("New EVC created, source IP: {} destination IP {}.", + LOG.trace("New EVC created, source IP: {} destination IP {}.", evc.getUniSource().iterator().next().getIpAddress().getIpv4Address(), evc.getUniDest().iterator().next().getIpAddress().getIpv4Address()); // For now, we assume that there is 1 uni per source/destination @@ -56,17 +55,19 @@ public class EvcCreateCommand extends AbstractCreateCommand { InstanceIdentifier sourceUniIid; InstanceIdentifier destinationUniIid; if (evc.getUniSource().iterator().next().getUni() != null) { - sourceUniIid = (InstanceIdentifier) evc.getUniSource().iterator().next().getUni(); + sourceUniIid = evc.getUniSource().iterator().next().getUni().firstIdentifierOf(Node.class); } else { - sourceUniIid = UnimgrMapper.getUniIid(dataBroker, evc.getUniSource().iterator().next().getIpAddress()); + sourceUniIid = UnimgrMapper.getUniIid(dataBroker, + evc.getUniSource().iterator().next().getIpAddress(), + LogicalDatastoreType.OPERATIONAL); } if (evc.getUniDest().iterator().next().getUni() != null) { - destinationUniIid = UnimgrMapper.getUniIid(dataBroker, evc.getUniDest().iterator().next().getIpAddress());; + destinationUniIid = evc.getUniDest().iterator().next().getUni().firstIdentifierOf(Node.class); } else { - destinationUniIid = (InstanceIdentifier) evc.getUniDest().iterator().next().getUni(); + destinationUniIid = UnimgrMapper.getUniIid(dataBroker, + evc.getUniDest().iterator().next().getIpAddress(), + LogicalDatastoreType.OPERATIONAL); } - // The user has specified the instance identifier of the - // uni source and uni destination Optional optionalUniSource = UnimgrUtils.readNode(dataBroker, LogicalDatastoreType.CONFIGURATION, sourceUniIid); @@ -76,56 +77,73 @@ public class EvcCreateCommand extends AbstractCreateCommand { Node uniSource; Node uniDestination; // Retrieve the source and destination Unis - if (!optionalUniSource.isPresent() || !optionalUniDestination.isPresent()) { - LOG.info("Unable to retrieve the Source and/or Destination Unis."); - break; - } else { + if (optionalUniSource.isPresent() && optionalUniDestination.isPresent()) { uniSource = optionalUniSource.get(); uniDestination = optionalUniDestination.get(); - } - // Set source and destination - InstanceIdentifier sourceBridgeIid = - UnimgrMapper.getOvsdbBridgeNodeIid(uniSource.getNodeId(), - UnimgrConstants.DEFAULT_BRIDGE_NAME); - Optional optionalSourceBr = UnimgrUtils.readNode(dataBroker, - LogicalDatastoreType.CONFIGURATION, - sourceBridgeIid); - InstanceIdentifier destinationBridgeIid = - UnimgrMapper.getOvsdbBridgeNodeIid(uniSource.getNodeId(), - UnimgrConstants.DEFAULT_BRIDGE_NAME); - Optional optionalDestinationBr = UnimgrUtils.readNode(dataBroker, - LogicalDatastoreType.CONFIGURATION, - destinationBridgeIid); - if (!optionalSourceBr.isPresent() || !optionalDestinationBr.isPresent()) { - LOG.info("Unable to retrieve the source and/or destination bridge."); - break; + // Set source and destination + UniAugmentation sourceUniAugmentation = + uniSource.getAugmentation(UniAugmentation.class); + UniAugmentation destinationUniAugmentation = + uniDestination.getAugmentation(UniAugmentation.class); + Optional optionalSourceOvsdbNode = + UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + sourceUniAugmentation + .getOvsdbNodeRef() + .getValue()); + Optional optionalDestinationOvsdbNode = + UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + destinationUniAugmentation + .getOvsdbNodeRef() + .getValue()); + if (optionalSourceOvsdbNode.isPresent() && optionalDestinationOvsdbNode.isPresent()) { + InstanceIdentifier sourceBridgeIid = + UnimgrMapper.getOvsdbBridgeNodeIid(optionalSourceOvsdbNode.get()); + Optional optionalSourceBr = UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + sourceBridgeIid); + InstanceIdentifier destinationBridgeIid = + UnimgrMapper.getOvsdbBridgeNodeIid(optionalDestinationOvsdbNode.get()); + Optional optionalDestinationBr = UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + destinationBridgeIid); + Node sourceBr; + Node destinationBr; + if (optionalSourceBr.isPresent() && optionalDestinationBr.isPresent()) { + sourceBr = optionalSourceBr.get(); + destinationBr = optionalDestinationBr.get(); + UnimgrUtils.createTerminationPointNode(dataBroker, + uniSource.getAugmentation(UniAugmentation.class), + sourceBr, + UnimgrConstants.DEFAULT_BRIDGE_NAME, + UnimgrConstants.DEFAULT_TUNNEL_IFACE, + UnimgrConstants.DEFAULT_GRE_NAME); + UnimgrUtils.createGreTunnel(dataBroker, + uniSource.getAugmentation(UniAugmentation.class), + uniDestination.getAugmentation(UniAugmentation.class), + sourceBr, + UnimgrConstants.DEFAULT_BRIDGE_NAME, + "gre0"); + UnimgrUtils.createTerminationPointNode(dataBroker, + uniSource.getAugmentation(UniAugmentation.class), + destinationBr, + UnimgrConstants.DEFAULT_BRIDGE_NAME, + UnimgrConstants.DEFAULT_TUNNEL_IFACE, + UnimgrConstants.DEFAULT_GRE_NAME); + UnimgrUtils.createGreTunnel(dataBroker, + uniDestination.getAugmentation(UniAugmentation.class), + uniSource.getAugmentation(UniAugmentation.class), destinationBr, + UnimgrConstants.DEFAULT_BRIDGE_NAME, + "gre0"); + } else { + LOG.info("Unable to retrieve the source and/or destination bridge."); + } + } else { + LOG.info("Uname to retrieve the source and/or destination ovsdbNode."); + } } else { - Node sourceBr = optionalSourceBr.get(); - Node destinationBr = optionalDestinationBr.get(); - UnimgrUtils.createTerminationPointNode(dataBroker, - uniSource.getAugmentation(UniAugmentation.class), - sourceBr, - UnimgrConstants.DEFAULT_BRIDGE_NAME, - UnimgrConstants.DEFAULT_TUNNEL_IFACE, - UnimgrConstants.DEFAULT_GRE_NAME); - UnimgrUtils.createGreTunnel(dataBroker, - uniSource.getAugmentation(UniAugmentation.class), - uniDestination.getAugmentation(UniAugmentation.class), - sourceBr, - UnimgrConstants.DEFAULT_BRIDGE_NAME, - "gre0"); - UnimgrUtils.createTerminationPointNode(dataBroker, - uniSource.getAugmentation(UniAugmentation.class), - destinationBr, - UnimgrConstants.DEFAULT_BRIDGE_NAME, - UnimgrConstants.DEFAULT_TUNNEL_IFACE, - UnimgrConstants.DEFAULT_GRE_NAME); - UnimgrUtils.createGreTunnel(dataBroker, - uniDestination.getAugmentation(UniAugmentation.class), - uniSource.getAugmentation(UniAugmentation.class), - destinationBr, - UnimgrConstants.DEFAULT_BRIDGE_NAME, - "gre0"); + LOG.info("Unable to retrieve the source and/or destination Uni."); } } } diff --git a/impl/src/main/java/org/opendaylight/unimgr/command/EvcDeleteCommand.java b/impl/src/main/java/org/opendaylight/unimgr/command/EvcDeleteCommand.java index c02449e6..3a862e3e 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/command/EvcDeleteCommand.java +++ b/impl/src/main/java/org/opendaylight/unimgr/command/EvcDeleteCommand.java @@ -48,13 +48,13 @@ public class EvcDeleteCommand extends AbstractDeleteCommand { @Override public void execute() { Map, Evc> originalEvcs = UnimgrUtils.extractOriginal(changes, Evc.class); - Set> removedEvcs = UnimgrUtils.extractRemoved(changes, Evc.class); + //Set> removedEvcs = UnimgrUtils.extractRemoved(changes, Evc.class); Set> removedPaths = changes.getRemovedPaths(); if (!removedPaths.isEmpty()) { for (InstanceIdentifier removedPath: removedPaths) { Class type = removedPath.getTargetType(); - LOG.info("Removed paths instance identifier {}", type); + LOG.trace("Removed paths instance identifier {}", type); if (type.equals(Evc.class)) { LOG.info("Removed paths instance identifier {}", type); for (Entry, Evc> evc: originalEvcs.entrySet()) { @@ -63,20 +63,32 @@ public class EvcDeleteCommand extends AbstractDeleteCommand { List uniSourceLst = data.getUniSource(); for (UniSource uniSource : uniSourceLst) { InstanceIdentifier iidUni = uniSource.getUni(); - Node ovsdbNd = getUniOvsdbNode(iidUni); - List termPointList = ovsdbNd.getTerminationPoint(); - for(TerminationPoint termPoint : termPointList) { - deleteTerminationPoint(termPoint, ovsdbNd); + Optional optionalOvsdbNode = + UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + iidUni); + if (optionalOvsdbNode.isPresent()) { + Node ovsdbNode = optionalOvsdbNode.get(); + List termPointList = ovsdbNode.getTerminationPoint(); + for(TerminationPoint termPoint : termPointList) { + deleteTerminationPoint(termPoint, ovsdbNode); + } } } LOG.info("Removed EVC Source {}", data.getUniSource()); List uniDestLst = data.getUniDest(); for (UniDest uniDest : uniDestLst) { InstanceIdentifier iidUni = uniDest.getUni(); - Node ovsdbNd = getUniOvsdbNode(iidUni); - List termPointList = ovsdbNd.getTerminationPoint(); - for(TerminationPoint termPoint : termPointList) { - deleteTerminationPoint(termPoint, ovsdbNd); + Optional optionalOvsdbNode = + UnimgrUtils.readNode(dataBroker, + LogicalDatastoreType.OPERATIONAL, + iidUni); + if (optionalOvsdbNode.isPresent()) { + Node ovsdbNode = optionalOvsdbNode.get(); + List termPointList = ovsdbNode.getTerminationPoint(); + for(TerminationPoint termPoint : termPointList) { + deleteTerminationPoint(termPoint, ovsdbNode); + } } } LOG.info("Removed EVC Destination {}", data.getUniDest()); @@ -87,14 +99,6 @@ public class EvcDeleteCommand extends AbstractDeleteCommand { } } - private Node getUniOvsdbNode(InstanceIdentifier iidUni) { - Optional nodeOpt = UnimgrUtils.readNode(dataBroker, iidUni); - if (nodeOpt.isPresent()) { - return nodeOpt.get(); - } - return null; - } - private boolean deleteTerminationPoint(TerminationPoint termPoint, Node ovsdbNode) { boolean result = false; InstanceIdentifier terminationPointPath = InstanceIdentifier diff --git a/impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java b/impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java index b41975c7..0ffa5d4b 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java +++ b/impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java @@ -43,7 +43,7 @@ public class UniCreateCommand extends AbstractCreateCommand { if (created.getValue() != null && created.getValue() instanceof UniAugmentation) { UniAugmentation uni = (UniAugmentation) created.getValue(); InstanceIdentifier uniKey = created.getKey(); - LOG.info("New UNI created {}.", uni.getIpAddress().getIpv4Address()); + LOG.trace("New UNI created {}.", uni.getIpAddress().getIpv4Address()); /* We assume that when the user specifies the * ovsdb-node-ref that the node already exists in * the controller and that the OVS instance is in diff --git a/impl/src/main/java/org/opendaylight/unimgr/command/UniDeleteCommand.java b/impl/src/main/java/org/opendaylight/unimgr/command/UniDeleteCommand.java index 6522c562..9d06ba27 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/command/UniDeleteCommand.java +++ b/impl/src/main/java/org/opendaylight/unimgr/command/UniDeleteCommand.java @@ -14,7 +14,6 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.unimgr.impl.UnimgrConstants; import org.opendaylight.unimgr.impl.UnimgrMapper; import org.opendaylight.unimgr.impl.UnimgrUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef; @@ -46,17 +45,17 @@ public class UniDeleteCommand extends AbstractDeleteCommand { for (InstanceIdentifier removedUniIid: removedUnis) { UniAugmentation uniAug = UnimgrUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION, removedUniIid); if(uniAug != null){ - LOG.info("Uni Augmentation present."); - OvsdbNodeRef ovsNdRef = uniAug.getOvsdbNodeRef(); - InstanceIdentifier iidNode = (InstanceIdentifier) ovsNdRef.getValue(); - Optional optNode = UnimgrUtils.readNode(dataBroker, LogicalDatastoreType.CONFIGURATION, iidNode); + LOG.trace("Uni Augmentation present."); + OvsdbNodeRef ovsdbNodeRef = uniAug.getOvsdbNodeRef(); + InstanceIdentifier ovsdbIid = ovsdbNodeRef.getValue().firstIdentifierOf(Node.class); + Optional optNode = UnimgrUtils.readNode(dataBroker, LogicalDatastoreType.CONFIGURATION, ovsdbIid); if (optNode.isPresent()) { Node ovsdbNode = optNode.get(); - InstanceIdentifier iidBridgeNode = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode.getNodeId(), UnimgrConstants.DEFAULT_BRIDGE_NAME); + InstanceIdentifier iidBridgeNode = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode); deleteNode(iidBridgeNode); LOG.info("Received a request to remove a UNI BridgeNode ", iidBridgeNode); } - deleteNode(iidNode); + deleteNode(ovsdbIid); LOG.info("Received a request to remove an UNI ", removedUniIid); } } @@ -68,7 +67,7 @@ public class UniDeleteCommand extends AbstractDeleteCommand { Optional optNode = UnimgrUtils.readNode(dataBroker, LogicalDatastoreType.CONFIGURATION, iidNode); if (optNode.isPresent()) { Node ovsdbNode = optNode.get(); - InstanceIdentifier iidBridgeNode = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode.getNodeId(), UnimgrConstants.DEFAULT_BRIDGE_NAME); + InstanceIdentifier iidBridgeNode = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode); deleteNode(iidBridgeNode); LOG.info("Received a request to remove a BridgeNode ", iidBridgeNode); } diff --git a/impl/src/main/java/org/opendaylight/unimgr/command/UniUpdateCommand.java b/impl/src/main/java/org/opendaylight/unimgr/command/UniUpdateCommand.java index 351a9307..60762501 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/command/UniUpdateCommand.java +++ b/impl/src/main/java/org/opendaylight/unimgr/command/UniUpdateCommand.java @@ -38,13 +38,13 @@ public class UniUpdateCommand extends AbstractUpdateCommand { OvsdbNodeAugmentation ovsdbNodeAugmentation = (OvsdbNodeAugmentation) created .getValue(); if (ovsdbNodeAugmentation != null) { - LOG.info("Received an OVSDB node create {}", + LOG.trace("Received an OVSDB node create {}", ovsdbNodeAugmentation.getConnectionInfo() .getRemoteIp().getIpv4Address().getValue()); final List managedNodeEntries = ovsdbNodeAugmentation.getManagedNodeEntry(); if (managedNodeEntries != null) { for (ManagedNodeEntry managedNodeEntry : managedNodeEntries) { - LOG.info("Received an update from an OVSDB node {}.", managedNodeEntry.getKey()); + LOG.trace("Received an update from an OVSDB node {}.", managedNodeEntry.getKey()); // We received a node update from the southbound plugin // so we have to check if it belongs to the UNI } diff --git a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrDataChangeListener.java b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrDataChangeListener.java index 9441ed8f..299b3cdc 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrDataChangeListener.java +++ b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrDataChangeListener.java @@ -71,8 +71,10 @@ public class UnimgrDataChangeListener implements IUnimgrDataChangeListener { DataObject> changes) { if (changes != null) { List commands = new ArrayList(); - commands.add(new UniCreateCommand(dataBroker, changes)); - commands.add(new EvcCreateCommand(dataBroker, changes)); + Command uniCreate = new UniCreateCommand(dataBroker, changes); + Command evcCreate = new EvcCreateCommand(dataBroker, changes); + commands.add(uniCreate); + commands.add(evcCreate); invoker.setCommands(commands); invoker.invoke(); } @@ -83,8 +85,10 @@ public class UnimgrDataChangeListener implements IUnimgrDataChangeListener { DataObject> changes) { if (changes != null) { List commands = new ArrayList(); - commands.add(new UniUpdateCommand(dataBroker, changes)); - commands.add(new EvcUpdateCommand(dataBroker, changes)); + Command uniUpdate = new UniUpdateCommand(dataBroker, changes); + Command evcUpdate = new EvcUpdateCommand(dataBroker, changes); + commands.add(uniUpdate); + commands.add(evcUpdate); invoker.setCommands(commands); invoker.invoke(); } @@ -95,8 +99,10 @@ public class UnimgrDataChangeListener implements IUnimgrDataChangeListener { DataObject> changes) { if (changes != null) { List commands = new ArrayList(); - commands.add(new UniDeleteCommand(dataBroker, changes)); - commands.add(new EvcDeleteCommand(dataBroker, changes)); + Command uniDelete = new UniDeleteCommand(dataBroker, changes); + Command evcDelete = new EvcDeleteCommand(dataBroker, changes); + commands.add(uniDelete); + commands.add(evcDelete); invoker.setCommands(commands); invoker.invoke(); } diff --git a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrMapper.java b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrMapper.java index 5223f1ab..dc94694f 100755 --- a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrMapper.java +++ b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrMapper.java @@ -12,6 +12,7 @@ import java.util.List; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; @@ -29,7 +30,21 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class UnimgrMapper { - public static InstanceIdentifier getEvcLinkIID(LinkId id) { + public static InstanceIdentifier createOvsdbBridgeNodeIid(Node ovsdbNode, + String bridgeName) { + String bridgeNodeName = ovsdbNode.getNodeId().getValue() + + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + + bridgeName; + NodeId bridgeNodeId = new NodeId(bridgeNodeName); + InstanceIdentifier bridgeNodePath = InstanceIdentifier + .create(NetworkTopology.class) + .child(Topology.class, + new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID)) + .child(Node.class, new NodeKey(bridgeNodeId)); + return bridgeNodePath; + } + + public static InstanceIdentifier getEvcLinkIid(LinkId id) { InstanceIdentifier linkPath = InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, @@ -56,18 +71,15 @@ public class UnimgrMapper { return nodePath; } - public static InstanceIdentifier getOvsdbBridgeNodeIid(NodeId ovsdbNode, - String bridgeName) { - String ovsdbNodeId = ovsdbNode.getValue(); - NodeId bridgeNodeId = new NodeId(ovsdbNodeId - + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX - + bridgeName); - InstanceIdentifier nodePath = InstanceIdentifier - .create(NetworkTopology.class) - .child(Topology.class, - new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID)) - .child(Node.class, - new NodeKey(bridgeNodeId)); + public static InstanceIdentifier getOvsdbBridgeNodeIid(Node ovsdbNode) { + OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class); + InstanceIdentifier nodePath = ovsdbNodeAugmentation + .getManagedNodeEntry() + .iterator() + .next() + .getBridgeRef() + .getValue() + .firstIdentifierOf(Node.class); return nodePath; } diff --git a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java index 78f3efbb..09c49a26 100644 --- a/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java +++ b/impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java @@ -77,52 +77,16 @@ public class UnimgrUtils { private static final Logger LOG = LoggerFactory.getLogger(UnimgrUtils.class); - @Deprecated - public static void createBridgeNode(DataBroker dataBroker, - NodeId ovsdbNodeId, - Uni uni, - String bridgeName) { - LOG.info("Creating a bridge on node {}", ovsdbNodeId); - InstanceIdentifier ovsdbNodeIid = UnimgrMapper - .getOvsdbNodeIid(uni.getIpAddress()); - ConnectionInfo connectionInfo = UnimgrUtils.getConnectionInfo(dataBroker, ovsdbNodeId); - if (connectionInfo != null) { - NodeBuilder bridgeNodeBuilder = new NodeBuilder(); - InstanceIdentifier bridgeIid = UnimgrMapper - .getOvsdbBridgeNodeIid(ovsdbNodeId, bridgeName); - NodeId bridgeNodeId = new NodeId(ovsdbNodeId - + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX - + bridgeName); - bridgeNodeBuilder.setNodeId(bridgeNodeId); - OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder(); - ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName)); - ovsdbBridgeAugmentationBuilder.setProtocolEntry(UnimgrUtils - .createMdsalProtocols()); - OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid); - ovsdbBridgeAugmentationBuilder.setManagedBy(ovsdbNodeRef); - bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, - ovsdbBridgeAugmentationBuilder.build()); - WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - transaction.put(LogicalDatastoreType.CONFIGURATION, - bridgeIid, - bridgeNodeBuilder.build()); - transaction.submit(); - } else { - LOG.error("The OVSDB node is not connected {}", ovsdbNodeId); - } - } - public static void createBridgeNode(DataBroker dataBroker, Node ovsdbNode, UniAugmentation uni, String bridgeName) { - LOG.info("Creating a bridge on node {}", ovsdbNode.getNodeId()); - @SuppressWarnings("unchecked") - InstanceIdentifier ovsdbNodeIid = (InstanceIdentifier) uni.getOvsdbNodeRef().getValue(); + LOG.info("Creating a bridge on node {}", ovsdbNode.getNodeId().getValue()); + InstanceIdentifier ovsdbNodeIid = uni.getOvsdbNodeRef().getValue().firstIdentifierOf(Node.class); if (ovsdbNodeIid != null) { NodeBuilder bridgeNodeBuilder = new NodeBuilder(); - InstanceIdentifier bridgeIid = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode.getNodeId(), - bridgeName); + InstanceIdentifier bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode, + bridgeName); NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId() + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + bridgeName); @@ -153,8 +117,8 @@ public class UnimgrUtils { ovsdbNodeIid); if (optionalOvsdbNode.isPresent()) { Node ovsdbNode = optionalOvsdbNode.get(); - InstanceIdentifier bridgeIid = UnimgrMapper.getOvsdbBridgeNodeIid(ovsdbNode.getNodeId(), - bridgeName); + InstanceIdentifier bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode, + bridgeName); NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId().getValue() + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + bridgeName); -- 2.36.6