@Override public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException { ConcurrentMap<String, ConcurrentMap<String, Row>> cache = ovsdbInventoryService.getCache(node, databaseName); if (cache == null) return null; return new ArrayList<String>(cache.keySet()); } }
@Override @Deprecated public ConcurrentMap<String, Row> getRows(Node node, String tableName) { ConcurrentMap<String, Row> ovsTable = ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName); return ovsTable; }
@Override public void notifyNodeAdded(Node node, InetAddress address, int port) { pluginOvsdbInventoryService.notifyNodeAdded(NodeUtils.getMdsalNode(node), address, port); }
private void initializeInventoryForNewNode (Connection connection) throws InterruptedException, ExecutionException, IOException { OvsdbClient client = connection.getClient(); InetAddress address = client.getConnectionInfo().getRemoteAddress(); int port = client.getConnectionInfo().getRemotePort(); List<String> databases = client.getDatabases().get(); if (databases == null) { logger.error("Unable to get Databases for the ovsdb connection : {}", client.getConnectionInfo()); return; } for (String database : databases) { DatabaseSchema dbSchema = client.getSchema(database).get(); TableUpdates updates = this.monitorTables(connection.getNode(), dbSchema); ovsdbInventoryService.processTableUpdates(connection.getNode(), dbSchema.getName(), updates); } logger.info("Notifying Inventory Listeners for Node Added: {}", connection.getNode().toString()); ovsdbInventoryService.notifyNodeAdded(connection.getNode(), address, port); }
public void channelClosed(Node node) throws Exception { logger.info("Connection to Node : {} closed", node); disconnect(node); ovsdbInventoryService.removeNode(node); }
@Override public void printCache(Node n) { pluginOvsdbInventoryService.printCache(NodeUtils.getMdsalNode(n)); }
@Override public void update(TableUpdates result, DatabaseSchema dbSchema) { ovsdbInventoryService.processTableUpdates(node, dbSchema.getName(), result); }
@Override public void removeRow(Node n, String databaseName, String tableName, String uuid) { pluginOvsdbInventoryService.removeRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid); }
@Override public Row getRow(Node n, String databaseName, String tableName, String uuid) { return pluginOvsdbInventoryService.getRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid); }
@Override public void updateRow(Node n, String databaseName, String tableName, String uuid, Row row) { pluginOvsdbInventoryService.updateRow(NodeUtils.getMdsalNode(n), databaseName, tableName, uuid, row); }
@Override public void removeNode(Node node) { pluginOvsdbInventoryService.removeNode(NodeUtils.getMdsalNode(node)); }
@Override protected Object doExecute() throws Exception { NodeId nodeId = new NodeId(nodeName); NodeKey nodeKey = new NodeKey(nodeId); Node node = new NodeBuilder() .setId(nodeId) .setKey(nodeKey) .build(); ovsdbInventory.printCache(node); return null; }
@Override public void processTableUpdates(Node n, String databaseName, TableUpdates tableUpdates) { pluginOvsdbInventoryService.processTableUpdates(NodeUtils.getMdsalNode(n), databaseName, tableUpdates); }
@Override @Deprecated public Row getRow(Node node, String tableName, String uuid) { Map<String, Row> ovsTable = ovsdbInventoryService.getTableCache(node, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName); if (ovsTable == null) return null; return ovsTable.get(uuid); }
public Status disconnect(Node node) { Connection connection = getConnection(node); if (connection != null) { ovsdbConnections.remove(normalizeId(node.getId().getValue())); connection.disconnect(); ovsdbInventoryService.removeNode(node); return new Status(StatusCode.SUCCESS); } else { return new Status(StatusCode.NOTFOUND); } }
private String getTableNameForRowUuid(Node node, String databaseName, UUID rowUuid) { ConcurrentMap<String, ConcurrentMap<String, Row>> cache = ovsdbInventoryService.getCache(node, databaseName); if (cache == null) { return null; } for (String tableName : cache.keySet()) { ConcurrentMap<String, Row> rows = cache.get(tableName); if (rows.get(rowUuid.toString()) != null) { return tableName; } } return null; }
@Override public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName) throws OvsdbPluginException { ConcurrentMap<String, Row> ovsTable = ovsdbInventoryService.getTableCache(node, databaseName, tableName); if (ovsTable == null) return null; ConcurrentMap<UUID, Row<GenericTableSchema>> tableDB = Maps.newConcurrentMap(); for (String uuidStr : ovsTable.keySet()) { tableDB.put(new UUID(uuidStr), ovsTable.get(uuidStr)); } return tableDB; }
@Override public ConcurrentMap<String, ConcurrentMap<String, Row>> getCache(Node n, String databaseName) { return pluginOvsdbInventoryService.getCache(NodeUtils.getMdsalNode(n), databaseName); }
@Override public ConcurrentMap<String, Row> getTableCache(Node n, String databaseName, String tableName) { return pluginOvsdbInventoryService.getTableCache(NodeUtils.getMdsalNode(n), databaseName, 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; }