@Override public Row getRow(Node node, String tableName, String uuid) { return pluginOvsdbConfigurationService.getRow(NodeUtils.getMdsalNode(node), tableName, uuid); }
public String getBridgeUUID (Node ovsNode, String bridgeName) { String uuid = ""; if (ovsNode == null) { return uuid; } OvsdbConfigurationService ovsdbConfigurationService = getOvsdbConfigurationService(); if (ovsdbConfigurationService == null) { return uuid; } try { Map<String, Row> table = ovsdbConfigurationService. getRows(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, Bridge.class)); if (table != null) { for (String key : table.keySet()) { Bridge bridge = ovsdbConfigurationService.getTypedRow(ovsNode, Bridge.class, table.get(key)); if (bridge.getName().equals(bridgeName)) { uuid = key; } } } } catch (Exception e) { logger.error("Error getting Bridge Identifier for {} / {}", ovsNode, bridgeName, e); } logger.trace("\nOVSSFC {}\n uuid: {}", Thread.currentThread().getStackTrace()[1], uuid); return uuid; }
@Override public void deleteRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid, String parentColumn, UUID rowUuid) throws OvsdbPluginException { pluginOvsdbConfigurationService .deleteRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable, parentRowUuid, parentColumn, rowUuid); }
try { Row bridgeRow = ovsdbConfigurationService .getRow(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, Bridge.class), bridgeUuid); Bridge bridge = ovsdbConfigurationService.getTypedRow(ovsNode, Bridge.class, bridgeRow); Set<String> dpids = bridge.getDatapathIdColumn().getData(); if (dpids != null && !dpids.isEmpty()) {
@Override public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node, String databaseName, String tableName) throws OvsdbPluginException { return pluginOvsdbConfigurationService .getRows(NodeUtils.getMdsalNode(node), databaseName, tableName); }
@Override public Row<GenericTableSchema> updateRow(Node node, String databaseName, String tableName, UUID rowUuid, Row<GenericTableSchema> row, boolean overwrite) throws OvsdbPluginException { return pluginOvsdbConfigurationService .updateRow(NodeUtils.getMdsalNode(node), databaseName, tableName, rowUuid, row, overwrite); }
@Override public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid, String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException { return pluginOvsdbConfigurationService .insertRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable, parentUuid, parentColumn, row); }
@Override public Boolean setOFController(Node node, String bridgeUUID) throws InterruptedException, ExecutionException { return pluginOvsdbConfigurationService.setOFController(NodeUtils.getMdsalNode(node), bridgeUUID); }
@Override public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid, String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException { return pluginOvsdbConfigurationService .insertTree(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable, parentUuid, parentColumn, row); }
@Override public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) { return pluginOvsdbConfigurationService.getTableName(NodeUtils.getMdsalNode(node), typedClass); }
@Override public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) { return pluginOvsdbConfigurationService.getTypedRow(NodeUtils.getMdsalNode(node), typedClass, row); }
@Override public ConcurrentMap<String, Row> getRows(Node node, String tableName) { return pluginOvsdbConfigurationService.getRows(NodeUtils.getMdsalNode(node), tableName); }
@Override public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Row row) { return StatusConvertorUtil .convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService .updateRow(NodeUtils.getMdsalNode(node), tableName, parentUUID, rowUUID, row)); }
@Override public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row) { return StatusConvertorUtil.convertOvsdbStatusWithUuidToCompLayerStatusWithUuid(pluginOvsdbConfigurationService.insertRow(NodeUtils.getMdsalNode(node), tableName, parentUuid, row)); }
@Override public void run() { try { if (ovsdbConfigurationService != null) { ovsdbConfigurationService.setOFController(node, uuid.toString()); } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } };
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createRow(InputStream stream) throws IOException { OvsdbRow localRow = this.getOvsdbRow(stream); if (localRow == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } OvsdbConfigurationService ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class, this); if (ovsdbTable == null) { throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = NodeResource.getOvsdbNode(nodeId, this); Row row = ovsdbTable.insertTree(node, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName, localRow.getParentTable(), new UUID(localRow.getParentUuid()), localRow.getParentColumn(), localRow.getRow()); String response = objectMapper.writeValueAsString(row); return Response.status(Response.Status.CREATED) .entity(response) .build(); }
public String getSystemId (Node ovsNode) { String systemId = ""; if (ovsNode == null) { return systemId; } OvsdbConfigurationService ovsdbConfigurationService = getOvsdbConfigurationService(); if (ovsdbConfigurationService == null) { return systemId; } Map<String, Row> table = ovsdbConfigurationService.getRows(ovsNode, ovsdbConfigurationService.getTableName(ovsNode, OpenVSwitch.class)); if (table == null) { logger.error("OpenVSwitch table is null for Node {} ", ovsNode); return systemId; } // Loop through all the Open_vSwitch rows looking for the first occurrence of external_ids. // The specification does not restrict the number of rows so we choose the first we find. for (Row row : table.values()) { OpenVSwitch ovsRow = ovsdbConfigurationService.getTypedRow(ovsNode, OpenVSwitch.class, row); Map<String, String> externalIds = ovsRow.getExternalIdsColumn().getData(); if (externalIds == null) { continue; } systemId = externalIds.get("system-id"); } logger.trace("\nOVSSFC {}\n system-id: {}", Thread.currentThread().getStackTrace()[1], systemId); return systemId; }
@Override public Row<GenericTableSchema> getRow(Node node, String databaseName, String tableName, UUID uuid) throws OvsdbPluginException { return pluginOvsdbConfigurationService .getRow(NodeUtils.getMdsalNode(node), databaseName, tableName, uuid); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response getRows() throws JsonProcessingException { OvsdbConfigurationService ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class, this); if (ovsdbTable == null) { throw new ServiceUnavailableException("Ovsdb ConfigurationService " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = NodeResource.getOvsdbNode(nodeId, this); Map<UUID,Row<GenericTableSchema>> rows = null; try { rows = ovsdbTable.getRows(node, databaseName, tableName); } catch (Exception e) { throw new BadRequestException(e.getMessage()); } String response = objectMapper.writeValueAsString(rows); return Response.status(Response.Status.OK) .entity(response) .build(); }
@PUT @Path("{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateRow(@PathParam("id") String id, InputStream stream) throws IOException{ OvsdbRow localRow = this.getOvsdbRow(stream); if (localRow == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } OvsdbConfigurationService ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class, this); if (ovsdbTable == null) { throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString()); } Node node = NodeResource.getOvsdbNode(nodeId, this); Row<GenericTableSchema> row = ovsdbTable.updateRow(node, databaseName, tableName, new UUID(id), localRow.getRow(), true); String response = objectMapper.writeValueAsString(row); return Response.status(Response.Status.OK) .entity(response) .build(); }