@SuppressWarnings("unchecked") @Test public void testAddOfOverlayExternalPort() throws Exception { NodeId nodeId = mock(NodeId.class); NodeConnectorId ncId = mock(NodeConnectorId.class); ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); when(dataBroker.newWriteOnlyTransaction()).thenReturn(transaction); CheckedFuture<Void, TransactionCommitFailedException> submitFuture = mock(CheckedFuture.class); when(transaction.submit()).thenReturn(submitFuture); InventoryHelper.addOfOverlayExternalPort(nodeId, ncId, dataBroker); verify(submitFuture).checkedGet(); }
public static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId, DataBroker dataBroker) { InstanceIdentifier<ExternalInterfaces> nodeExternalInterfacesIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .augmentation(OfOverlayNodeConfig.class) .child(ExternalInterfaces.class, new ExternalInterfacesKey(ncId)) .build(); ExternalInterfaces externalInterfaces = new ExternalInterfacesBuilder().setKey(new ExternalInterfacesKey(ncId)) .setNodeConnectorId(ncId) .build(); WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, nodeExternalInterfacesIid, externalInterfaces, true); DataStoreHelper.submitToDs(transaction); LOG.trace("Added external interface node connector {} to node {}", ncId.getValue(), nodeId.getValue()); return nodeExternalInterfacesIid; }
InventoryHelper { public static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId, DataBroker dataBroker) { InstanceIdentifier<ExternalInterfaces> nodeExternalInterfacesIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .augmentation(OfOverlayNodeConfig.class) .child(ExternalInterfaces.class, new ExternalInterfacesKey(ncId)) .build(); ExternalInterfaces externalInterfaces = new ExternalInterfacesBuilder().setKey(new ExternalInterfacesKey(ncId)) .setNodeConnectorId(ncId) .build(); WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, nodeExternalInterfacesIid, externalInterfaces, true); DataStoreHelper.submitToDs(transaction); LOG.trace("Added external interface node connector {} to node {}", ncId.getValue(), nodeId.getValue()); return nodeExternalInterfacesIid; } }
InventoryHelper { public static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId, DataBroker dataBroker) { InstanceIdentifier<ExternalInterfaces> nodeExternalInterfacesIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .augmentation(OfOverlayNodeConfig.class) .child(ExternalInterfaces.class, new ExternalInterfacesKey(ncId)) .build(); ExternalInterfaces externalInterfaces = new ExternalInterfacesBuilder().setKey(new ExternalInterfacesKey(ncId)) .setNodeConnectorId(ncId) .build(); WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, nodeExternalInterfacesIid, externalInterfaces, true); DataStoreHelper.submitToDs(transaction); LOG.trace("Added external interface node connector {} to node {}", ncId.getValue(), nodeId.getValue()); return nodeExternalInterfacesIid; }  }
InventoryHelper { public static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId, DataBroker dataBroker) { InstanceIdentifier<ExternalInterfaces> nodeExternalInterfacesIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .augmentation(OfOverlayNodeConfig.class) .child(ExternalInterfaces.class, new ExternalInterfacesKey(ncId)) .build(); ExternalInterfaces externalInterfaces = new ExternalInterfacesBuilder().setKey(new ExternalInterfacesKey(ncId)) .setNodeConnectorId(ncId) .build(); WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, nodeExternalInterfacesIid, externalInterfaces, true); DataStoreHelper.submitToDs(transaction); LOG.trace("Added external interface node connector {} to node {}", ncId.getValue(), nodeId.getValue()); return nodeExternalInterfacesIid; }  static Long getLongFromDpid(String dpid); static String getInventoryNodeIdString(OvsdbBridgeAugmentation ovsdbBridge,
            InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid, DataBroker dataBroker); static String getInventoryNodeConnectorIdString(String inventoryNodeId,
            OvsdbTerminationPointAugmentation ovsdbTp, InstanceIdentifier<OvsdbTerminationPointAugmentation> tpIid,
            DataBroker dataBroker); static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes,
            DataBroker dataBroker); static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId,
        DataBroker dataBroker); static OfOverlayNodeConfig getOfOverlayConfig(String nodeIdString, DataBroker dataBroker); static void updateOfOverlayConfig(IpAddress ip, String nodeIdString, String nodeConnectorIdString,
            AbstractTunnelType tunnelType, DataBroker dataBroker); static void removeTunnelsOfOverlayConfig(String nodeIdString,
                                                    List<AbstractTunnelType> tunnels,
                                                    DataBroker dataBroker); }
InventoryHelper { public static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId, DataBroker dataBroker) { InstanceIdentifier<ExternalInterfaces> nodeExternalInterfacesIid = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(nodeId)) .augmentation(OfOverlayNodeConfig.class) .child(ExternalInterfaces.class, new ExternalInterfacesKey(ncId)) .build(); ExternalInterfaces externalInterfaces = new ExternalInterfacesBuilder().setKey(new ExternalInterfacesKey(ncId)) .setNodeConnectorId(ncId) .build(); WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); transaction.put(LogicalDatastoreType.CONFIGURATION, nodeExternalInterfacesIid, externalInterfaces, true); DataStoreHelper.submitToDs(transaction); LOG.trace("Added external interface node connector {} to node {}", ncId.getValue(), nodeId.getValue()); return nodeExternalInterfacesIid; }  static Long getLongFromDpid(String dpid); static String getInventoryNodeIdString(OvsdbBridgeAugmentation ovsdbBridge,
            InstanceIdentifier<OvsdbTerminationPointAugmentation> ovsdbTpIid, DataBroker dataBroker); static String getInventoryNodeConnectorIdString(String inventoryNodeId,
            OvsdbTerminationPointAugmentation ovsdbTp, InstanceIdentifier<OvsdbTerminationPointAugmentation> tpIid,
            DataBroker dataBroker); static boolean checkOfOverlayConfig(String nodeIdString, List<AbstractTunnelType> requiredTunnelTypes,
            DataBroker dataBroker); static InstanceIdentifier<ExternalInterfaces> addOfOverlayExternalPort(NodeId nodeId, NodeConnectorId ncId,
        DataBroker dataBroker); static OfOverlayNodeConfig getOfOverlayConfig(String nodeIdString, DataBroker dataBroker); static void updateOfOverlayConfig(IpAddress ip, String nodeIdString, String nodeConnectorIdString,
            AbstractTunnelType tunnelType, DataBroker dataBroker); static void removeTunnelsOfOverlayConfig(String nodeIdString,
                                                    List<AbstractTunnelType> tunnels,
                                                    DataBroker dataBroker);  }