public static Connection getOvsdbConnection(String nodeId, Object bundleClassRef) { OvsdbConnectionService connectionService = (OvsdbConnectionService)ServiceHelper. getGlobalInstance(OvsdbConnectionService.class, bundleClassRef); if (connectionService == null) { throw new ServiceUnavailableException("Ovsdb ConnectionService " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = connectionService.getNode(nodeId); if (node == null) { throw new ResourceNotFoundException("Node "+nodeId+" not found"); } Connection connection = connectionService.getConnection(node); if (connection == null) { throw new ResourceNotFoundException("Connection for "+nodeId+" not available"); } return connection; }
@Override public List<Node> getNodes() { return NodeUtils.getSalNodes(pluginOvsdbConnectionService.getNodes()); }
@Override public Node connect(String identifier, Map<ConnectionConstants, String> params) { return NodeUtils.getSalNode(pluginOvsdbConnectionService.connect(identifier, params)); }
@Override public Connection getConnection(Node node) { return pluginOvsdbConnectionService.getConnection(NodeUtils.getMdsalNode(node)); }
@Override public Node getNode (String identifier) { return NodeUtils.getSalNode(pluginOvsdbConnectionService.getNode(identifier)); }
@Override public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); return (T)client.getTypedRowWrapper(typedClass, row); }
public static Node getOvsdbNode(String nodeId, Object bundleClassRef) { OvsdbConnectionService connectionService = (OvsdbConnectionService)ServiceHelper. getGlobalInstance(OvsdbConnectionService.class, bundleClassRef); if (connectionService == null) { throw new ServiceUnavailableException("Ovsdb ConnectionService " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = connectionService.getNode(nodeId); if (node == null) { throw new ResourceNotFoundException("Node "+nodeId+" not found"); } return node; }
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName); OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
private Connection getConnection (Node node) { Connection connection = connectionService.getConnection(node); if (connection == null || !connection.getClient().isActive()) { return null; } return connection; } /*
@GET @Produces(MediaType.APPLICATION_JSON) public Response getNodes() throws JsonProcessingException { OvsdbConnectionService connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this); List<Node> nodes = connectionService.getNodes(); if (nodes == null) { return Response.noContent().build(); } List<String> nodeIds = Lists.newArrayList(); for (Node node : nodes) { nodeIds.add(node.getId().getValue()); } Collections.sort(nodeIds); String response = objectMapper.writeValueAsString(nodeIds); return Response.status(Response.Status.OK) .entity(response) .build(); }
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
@Override public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); return client.createTypedRowWrapper(typedClass); }
public Node getNodeFromSystemId (String systemId) { Node node = null; OvsdbConnectionService connectionService = getOvsdbConnectionService(); Preconditions.checkNotNull(connectionService); List<Node> ovsNodes = connectionService.getNodes(); if (ovsNodes != null) { for (Node ovsNode : ovsNodes) { if (systemId.equals(getSystemId(ovsNode))) { node = ovsNode; } } } logger.trace("\nOVSSFC {}\n ovsNode: {}", Thread.currentThread().getStackTrace()[1], node != null ? node.toString() : ""); return node; }
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
public String getSpecialCaseParentUUID(Node node, String databaseName, String childTableName) { if (!databaseName.equals(OvsVswitchdSchemaConstants.DATABASE_NAME)) return null; String[] parentColumn = OvsVswitchdSchemaConstants.getParentColumnToMutate(childTableName); if (parentColumn != null && parentColumn[0].equals(OvsVswitchdSchemaConstants.DATABASE_NAME)) { Connection connection = connectionService.getConnection(node); OpenVSwitch openVSwitch = connection.getClient().getTypedRowWrapper(OpenVSwitch.class, null); ConcurrentMap<String, Row> row = this.getRows(node, openVSwitch.getSchema().getName()); if (row == null || row.size() == 0) return null; return (String)row.keySet().toArray()[0]; } return null; }
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName); Map<String, Row> rows = null;
@Override public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) { Connection connection = connectionService.getConnection(node); if (connection == null) { return null; } OvsdbClient client = connection.getClient(); TypedBaseTable<?> typedTable = client.getTypedRowWrapper(typedClass, null); if (typedTable == null) { return null; } return typedTable.getSchema().getName(); }
Node node = connectionService.getNode(nodeId); OvsdbClient client = connectionService.getConnection(node).getClient(); OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson); String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
public Boolean setBridgeOFController(Node node, String bridgeIdentifier) { if (connectionService == null) { logger.error("Couldn't refer to the ConnectionService"); return false; } try{ Connection connection = connectionService.getConnection(node); Bridge bridge = connection.getClient().getTypedRowWrapper(Bridge.class, null); Map<String, Row> brTableCache = ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME, bridge.getSchema().getName()); for (String uuid : brTableCache.keySet()) { bridge = connection.getClient().getTypedRowWrapper(Bridge.class, brTableCache.get(uuid)); if (bridge.getName().contains(bridgeIdentifier)) { return setOFController(node, uuid); } } } catch(Exception e) { logger.error("Error in setBridgeOFController()",e); } return false; }
public Status deleteRow(Node node, String tableName, String uuid) { String databaseName = OvsVswitchdSchemaConstants.DATABASE_NAME; Connection connection = connectionService.getConnection(node); OvsdbClient client = connection.getClient();