Update, Delete and Read support for base tables. 30/2730/1
authorMadhu Venugopal <mavenugo@gmail.com>
Thu, 14 Nov 2013 02:30:47 +0000 (18:30 -0800)
committerMadhu Venugopal <mavenugo@gmail.com>
Thu, 14 Nov 2013 10:04:07 +0000 (02:04 -0800)
Change-Id: I1c5f6fb8d2d6f0dee952542ad9d41866cf0d3077
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
northbound/ovsdb/pom.xml
northbound/ovsdb/src/main/java/org/opendaylight/ovsdb/northbound/OVSDBNorthbound.java
northbound/ovsdb/src/main/java/org/opendaylight/ovsdb/northbound/OVSDBRow.java
northbound/ovsdb/src/main/java/org/opendaylight/ovsdb/northbound/OVSDBRows.java [new file with mode: 0644]
ovsdb/src/main/java/org/opendaylight/ovsdb/lib/message/operations/UpdateOperation.java
ovsdb/src/main/java/org/opendaylight/ovsdb/plugin/ConfigurationService.java
ovsdb/src/main/java/org/opendaylight/ovsdb/plugin/OVSDBConfigService.java

index 6d4807f70708ca7ad672d29ad74747ae8978bbb7..b2be260d447ce8336557beb7e61ca49557dac731 100644 (file)
@@ -52,6 +52,7 @@
               org.apache.catalina.filters,
               org.codehaus.jackson.jaxrs,
               org.codehaus.jackson.annotate,
+              org.codehaus.jackson.map.annotate,
               !org.codehaus.enunciate.jaxrs
             </Import-Package>
             <Export-Package>
index aea65dff53ab8d9572951ee04786be84dc7db11e..47c6fde9e55fcb967759911791fab0ed16d63a76 100644 (file)
@@ -7,8 +7,11 @@
  */
 package org.opendaylight.ovsdb.northbound;
 
+import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -32,6 +35,9 @@ import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.ovsdb.lib.table.internal.Table;
+import org.opendaylight.ovsdb.lib.table.internal.Tables;
 import org.opendaylight.ovsdb.plugin.OVSDBConfigService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -72,6 +78,17 @@ public class OVSDBNorthbound {
                 + " : Table Name in URL does not match the row name in request body");
     }
 
+    private String getOVSTableName(String tableName) {
+        List<Table> tables = Tables.getTables();
+        for (Table table : tables) {
+            if (table.getTableName().getName().equalsIgnoreCase(tableName)) {
+                return table.getTableName().getName();
+            }
+        }
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     /**
      * Create a Row
      *
@@ -101,16 +118,22 @@ public class OVSDBNorthbound {
             throw new UnauthorizedException("User is not authorized to perform this operation");
         }
 
+        String ovsTableName = getOVSTableName(tableName);
+        if (ovsTableName == null) {
+            Status status = new Status(StatusCode.NOTFOUND, "Table "+tableName+" is not currently supported");
+            return NorthboundUtils.getResponse(status);
+        }
+
         OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class,
                                                                                             this);
         if (ovsdbTable == null) {
-            throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
+            throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
         if (row != null && row.getRow() != null) {
             handleNameMismatch(tableName, row.getRow().getTableName().getName());
             Node node = Node.fromString(nodeType, nodeId);
-            Status statusWithUUID = ovsdbTable.insertRow(node, tableName, row.getParent_uuid(), row.getRow());
+            Status statusWithUUID = ovsdbTable.insertRow(node, ovsTableName, row.getParent_uuid(), row.getRow());
 
             if (statusWithUUID.isSuccess()) {
                 return Response.status(Response.Status.CREATED)
@@ -125,6 +148,108 @@ public class OVSDBNorthbound {
         return Response.status(Response.Status.BAD_REQUEST).build();
     }
 
+    /**
+     * Read a Row
+     *
+     * @param node OVSDB Node identifier
+     * @param tableName name of the ovsdb table
+     * @param rowUuid UUID of the row being read
+     *
+     * @return Row corresponding to the UUID.
+     *
+     * <pre>
+     * Example:
+     *
+     * Request URL:
+     * https://localhost/controller/nb/v2/ovsdb/tables/bridge/rows/6f4c602c-026f-4390-beea-d50d6d448100
+     * </pre>
+     */
+
+    @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows/{rowUuid}")
+    @GET
+    @StatusCodes({ @ResponseCode(code = 200, condition = "Row Updated successfully"),
+        @ResponseCode(code = 400, condition = "Invalid data passed"),
+        @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
+    @Consumes({ MediaType.APPLICATION_JSON})
+    @TypeHint(String.class)
+    public String getRow(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
+                           @PathParam("tableName") String tableName, @PathParam("rowUuid") String rowUuid) {
+
+        if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
+            throw new UnauthorizedException("User is not authorized to perform this operation");
+        }
+
+        String ovsTableName = getOVSTableName(tableName);
+        if (ovsTableName == null) return null;
+
+        OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class,
+                                                                                            this);
+        if (ovsdbTable == null) {
+            throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        Node node = Node.fromString(nodeType, nodeId);
+        //Table<?> row = null;
+        String row = null;
+        try {
+            row = ovsdbTable.getRow(node, ovsTableName, rowUuid);
+        } catch (Exception e) {
+            throw new BadRequestException(e.getMessage());
+        }
+        //return new OVSDBRow(null, row);
+        return row;
+    }
+
+    /**
+     * Read all Rows of a table
+     *
+     * @param node OVSDB Node identifier
+     * @param tableName name of the ovsdb table
+     *
+     * @return All the Rows of a table
+     *
+     * <pre>
+     * Example:
+     *
+     * Request URL:
+     * https://localhost/controller/nb/v2/ovsdb/tables/bridge/rows
+     * </pre>
+     */
+
+    @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows")
+    @GET
+    @StatusCodes({ @ResponseCode(code = 200, condition = "Row Updated successfully"),
+        @ResponseCode(code = 400, condition = "Invalid data passed"),
+        @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
+    @Consumes({ MediaType.APPLICATION_JSON})
+    @TypeHint(String.class)
+    public String getAllRows(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
+                               @PathParam("tableName") String tableName) {
+        if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
+            throw new UnauthorizedException("User is not authorized to perform this operation");
+        }
+
+        String ovsTableName = getOVSTableName(tableName);
+        if (ovsTableName == null) return null;
+
+        OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class,
+                                                                                            this);
+        if (ovsdbTable == null) {
+            throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        Node node = Node.fromString(nodeType, nodeId);
+        //Map<String, Table<?>> rows = null;
+        String rows = null;
+        try {
+            rows = ovsdbTable.getRows(node, ovsTableName);
+        } catch (Exception e) {
+            throw new BadRequestException(e.getMessage());
+        }
+        //return new OVSDBRows(rows);
+        return rows;
+    }
+
     /**
      * Update a Row
      *
@@ -139,7 +264,16 @@ public class OVSDBNorthbound {
      * Example:
      *
      * Request URL:
-     * https://localhost/controller/nb/v2/ovsdb/tables/bridge/rows
+     * PUT https://localhost/controller/nb/v2/ovsdb/tables/bridge/rows/6f4c602c-026f-4390-beea-d50d6d448100
+     * BODY
+     * {
+     *    "row":{
+     *       "Bridge":{
+     *          "datapath_type":"OPENFLOWv1.3",
+     *          "stp_enable":true
+     *        }
+     *     }
+     * }
      * </pre>
      */
 
@@ -157,6 +291,12 @@ public class OVSDBNorthbound {
             throw new UnauthorizedException("User is not authorized to perform this operation");
         }
 
+        String ovsTableName = getOVSTableName(tableName);
+        if (ovsTableName == null) {
+            Status status = new Status(StatusCode.NOTFOUND, "Table "+tableName+" is not currently supported");
+            return NorthboundUtils.getResponse(status);
+        }
+
         OVSDBConfigService ovsdbTable = (OVSDBConfigService)ServiceHelper.getGlobalInstance(OVSDBConfigService.class,
                                                                                             this);
         if (ovsdbTable == null) {
@@ -166,7 +306,7 @@ public class OVSDBNorthbound {
         if (row != null && row.getRow() != null) {
             handleNameMismatch(tableName, row.getRow().getTableName().getName());
             Node node = Node.fromString(nodeType, nodeId);
-            Status status = ovsdbTable.updateRow(node, rowUuid, row.getRow());
+            Status status = ovsdbTable.updateRow(node, ovsTableName, row.getParent_uuid(), rowUuid, row.getRow());
             return NorthboundUtils.getResponse(status);
         }
         return Response.status(Response.Status.BAD_REQUEST).build();
@@ -200,12 +340,18 @@ public class OVSDBNorthbound {
             throw new UnauthorizedException("User is not authorized to perform this operation");
         }
 
+        String ovsTableName = getOVSTableName(tableName);
+        if (ovsTableName == null) {
+            Status status = new Status(StatusCode.NOTFOUND, "Table "+tableName+" is not currently supported");
+            return NorthboundUtils.getResponse(status);
+        }
+
         OVSDBConfigService ovsdbTable = (OVSDBConfigService) ServiceHelper.getGlobalInstance(OVSDBConfigService.class, this);
         if (ovsdbTable == null) {
             throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
         Node node = Node.fromString(nodeType, nodeId);
-        Status status = ovsdbTable.deleteRow(node, tableName, uuid);
+        Status status = ovsdbTable.deleteRow(node, ovsTableName, uuid);
         if (status.isSuccess()) {
             return Response.noContent().build();
         }
index 24e849a1871b830c86e5497e930575443152663f..403b2739d58b2e188cbc7f043e95a09c5a1dc6f1 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.ovsdb.northbound;
 
 import org.codehaus.jackson.annotate.JsonSubTypes;
 import org.codehaus.jackson.annotate.JsonTypeInfo;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
 import org.opendaylight.ovsdb.lib.table.Bridge;
 import org.opendaylight.ovsdb.lib.table.Capability;
 import org.opendaylight.ovsdb.lib.table.Controller;
@@ -17,6 +18,7 @@ import org.opendaylight.ovsdb.lib.table.SFlow;
 import org.opendaylight.ovsdb.lib.table.SSL;
 import org.opendaylight.ovsdb.lib.table.internal.Table;
 
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
 public class OVSDBRow {
     String parent_uuid;
     /*
@@ -53,6 +55,12 @@ public class OVSDBRow {
 
     public OVSDBRow() {
     }
+
+    public OVSDBRow(String parent_uuid, Table row) {
+        this.parent_uuid = parent_uuid;
+        this.row = row;
+    }
+
     public String getParent_uuid() {
         return parent_uuid;
     }
diff --git a/northbound/ovsdb/src/main/java/org/opendaylight/ovsdb/northbound/OVSDBRows.java b/northbound/ovsdb/src/main/java/org/opendaylight/ovsdb/northbound/OVSDBRows.java
new file mode 100644 (file)
index 0000000..2235358
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.ovsdb.northbound;
+
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.table.internal.Table;
+
+public class OVSDBRows {
+    Map<String, Table<?>> rows;
+
+    public OVSDBRows(Map<String, Table<?>> rows) {
+        super();
+        this.rows = rows;
+    }
+
+    public Map<String, Table<?>> getRows() {
+        return rows;
+    }
+
+    public void setRows(Map<String, Table<?>> rows) {
+        this.rows = rows;
+    }
+}
index c78aaacfe285cb79c39700e3cdc7fec1b72dca7d..5a89ef95afdeeb198de44075c1a64b6d3c7f5337 100644 (file)
@@ -3,14 +3,14 @@ package org.opendaylight.ovsdb.lib.message.operations;
 import java.util.List;
 
 import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.notation.Mutation;
+import org.opendaylight.ovsdb.lib.table.internal.Table;
 //TODO Madhu : This is not complete. Getting it in to enable other committers to make progress
 public class UpdateOperation extends Operation {
     String table;
     List<Condition> where;
-    Object row;
+    Table<?> row;
 
-    public UpdateOperation(String table, List<Condition> where, Object row) {
+    public UpdateOperation(String table, List<Condition> where, Table<?> row) {
         super();
         super.setOp("update");
         this.table = table;
@@ -29,10 +29,10 @@ public class UpdateOperation extends Operation {
     public void setWhere(List<Condition> where) {
         this.where = where;
     }
-    public Object getRow() {
+    public Table<?> getRow() {
         return row;
     }
-    public void setRow(Object row) {
+    public void setRow(Table<?> row) {
         this.row = row;
     }
     @Override
index 5680e415bfdacb28c560b77e709fa457278ad9b6..790c0e7697220ef7189423754bff595b2a3c7a5c 100755 (executable)
@@ -31,6 +31,7 @@ import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
 import org.opendaylight.ovsdb.lib.message.operations.MutateOperation;
 import org.opendaylight.ovsdb.lib.message.operations.Operation;
 import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
+import org.opendaylight.ovsdb.lib.message.operations.UpdateOperation;
 import org.opendaylight.ovsdb.lib.notation.Condition;
 import org.opendaylight.ovsdb.lib.notation.Function;
 import org.opendaylight.ovsdb.lib.notation.Mutation;
@@ -57,6 +58,7 @@ import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.util.concurrent.ListenableFuture;
 
 public class ConfigurationService implements IPluginInBridgeDomainConfigService, OVSDBConfigService,
@@ -820,7 +822,7 @@ public class ConfigurationService implements IPluginInBridgeDomainConfigService,
 
     @Override
     public Status insertRow(Node node, String tableName, String parent_uuid, Table<?> row) {
-        logger.error("tableName : {}, parent_uuid : {} Row : {}", tableName, parent_uuid, row.toString());
+        logger.info("tableName : {}, parent_uuid : {} Row : {}", tableName, parent_uuid, row.toString());
         Status statusWithUUID = null;
 
         // Schema based Table handling will help fix this static Table handling.
@@ -867,6 +869,145 @@ public class ConfigurationService implements IPluginInBridgeDomainConfigService,
         return statusWithUUID;
     }
 
+
+    @Override
+    public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Table<?> row) {
+        try{
+            if (connectionService == null) {
+                logger.error("Couldn't refer to the ConnectionService");
+                return new Status(StatusCode.NOSERVICE);
+            }
+
+            Connection connection = this.getConnection(node);
+            if (connection == null) {
+                return new Status(StatusCode.NOSERVICE, "Connection to ovsdb-server not available");
+            }
+
+            Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, Open_vSwitch.NAME.getName());
+
+            if (ovsTable == null) {
+                return new Status(StatusCode.NOTFOUND, "There are no Open_vSwitch instance in the Open_vSwitch table");
+            }
+
+            UUID uuid = new UUID(rowUUID);
+            Condition condition = new Condition("_uuid", Function.EQUALS, uuid);
+            List<Condition> where = new ArrayList<Condition>();
+            where.add(condition);
+            Operation updateRequest = new UpdateOperation(tableName, where, row);
+
+            TransactBuilder transaction = new TransactBuilder();
+            transaction.addOperations(new ArrayList<Operation>(
+                                      Arrays.asList(updateRequest)));
+
+            ListenableFuture<List<OperationResult>> transResponse = connection.getRpc().transact(transaction);
+            List<OperationResult> tr = transResponse.get();
+            List<Operation> requests = transaction.getRequests();
+            Status status = new Status(StatusCode.SUCCESS);
+            for (int i = 0; i < tr.size() ; i++) {
+                if (i < requests.size()) requests.get(i).setResult(tr.get(i));
+                if (tr.get(i) != null && tr.get(i).getError() != null && tr.get(i).getError().trim().length() > 0) {
+                    OperationResult result = tr.get(i);
+                    status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
+                }
+            }
+
+            if (tr.size() > requests.size()) {
+                OperationResult result = tr.get(tr.size()-1);
+                logger.error("Error Updating Row : {}/{}\n Error : {}\n Details : {}", tableName, row,
+                                                                                       result.getError(),
+                                                                                       result.getDetails());
+                status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
+            }
+            if (status.isSuccess()) {
+                status = new Status(StatusCode.SUCCESS);
+            }
+            return status;
+        } catch(Exception e){
+            e.printStackTrace();
+        }
+        return new Status(StatusCode.INTERNALERROR);
+    }
+
+    @Override
+    public Status deleteRow(Node node, String tableName, String uuid) {
+        if (tableName.equalsIgnoreCase("Bridge")) {
+            return deleteBridgeRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Capbility")) {
+            return deleteCapabilityRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Controller")) {
+            return deleteControllerRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Interface")) {
+            return deleteInterfaceRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Manager")) {
+            return deleteManagerRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Mirror")) {
+            return deleteMirrorRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("NetFlow")) {
+            return deleteNetFlowRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Open_vSwitch")) {
+            return deleteOpen_vSwitchRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Port")) {
+            return deletePortRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("QoS")) {
+            return deleteQosRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("Queue")) {
+            return deleteQueueRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("sFlow")) {
+            return deleteSflowRow(node, uuid);
+        }
+        else if (tableName.equalsIgnoreCase("SSL")) {
+            return deleteSSLRow(node, uuid);
+        }
+        return new Status(StatusCode.NOTFOUND, "Table "+tableName+" not supported");
+    }
+
+    @Override
+    public String getRows(Node node, String tableName) throws Exception{
+        try{
+            if (inventoryServiceInternal == null) {
+                throw new Exception("Inventory Service is Unavailable.");
+            }
+            Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, tableName);
+            if (ovsTable == null) return null;
+            ObjectMapper mapper = new ObjectMapper();
+            return mapper.writeValueAsString(ovsTable);
+        } catch(Exception e){
+            throw new Exception("Unable to read table due to "+e.getMessage());
+        }
+    }
+
+    @Override
+    public String getRow(Node node, String tableName, String uuid) throws Exception {
+        try{
+            if (inventoryServiceInternal == null) {
+                throw new Exception("Inventory Service is Unavailable.");
+            }
+            Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, tableName);
+            if (ovsTable == null) return null;
+            ObjectMapper mapper = new ObjectMapper();
+            return mapper.writeValueAsString(ovsTable.get(uuid));
+        } catch(Exception e){
+            throw new Exception("Unable to read table due to "+e.getMessage());
+        }
+    }
+
+    @Override
+    public List<String> getTables(Node node) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     private Status insertBridgeRow(Node node, String open_VSwitch_uuid, Bridge bridgeRow) {
         try{
             if (connectionService == null) {
@@ -1063,32 +1204,110 @@ public class ConfigurationService implements IPluginInBridgeDomainConfigService,
         return new Status(StatusCode.NOTIMPLEMENTED, "Insert operation for this Table is not implemented yet.");
     }
 
-    @Override
-    public Status updateRow(Node node, String rowUUID, Table<?> row) {
-        return new Status(StatusCode.NOTIMPLEMENTED, "Update Row functionality is not implemented yet.");
+    private Status deleteBridgeRow(Node node, String uuid) {
+
+        try {
+            if (connectionService == null) {
+                logger.error("Couldn't refer to the ConnectionService");
+                return new Status(StatusCode.NOSERVICE);
+            }
+            Connection connection = this.getConnection(node);
+            if (connection == null) {
+                return new Status(StatusCode.NOSERVICE, "Connection to ovsdb-server not available");
+            }
+            Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, Open_vSwitch.NAME.getName());
+            Map<String, Table<?>> brTable = inventoryServiceInternal.getTableCache(node, Bridge.NAME.getName());
+            Operation delBrRequest = null;
+
+            if (ovsTable == null || brTable == null || uuid == null || brTable.get(uuid) == null) {
+                return new Status(StatusCode.NOTFOUND, "");
+            }
+
+            UUID bridgeUuidPair = new UUID(uuid);
+            Mutation bm = new Mutation("bridges", Mutator.DELETE, bridgeUuidPair);
+            List<Mutation> mutations = new ArrayList<Mutation>();
+            mutations.add(bm);
+
+            UUID ovsUuid = new UUID((String) ovsTable.keySet().toArray()[0]);
+            Condition condition = new Condition("_uuid", Function.EQUALS, ovsUuid);
+            List<Condition> where = new ArrayList<Condition>();
+            where.add(condition);
+            delBrRequest = new MutateOperation(Open_vSwitch.NAME.getName(), where, mutations);
+
+            TransactBuilder transaction = new TransactBuilder();
+            transaction.addOperations(new ArrayList<Operation>(Arrays.asList(delBrRequest)));
+
+            ListenableFuture<List<OperationResult>> transResponse = connection.getRpc().transact(transaction);
+            List<OperationResult> tr = transResponse.get();
+            List<Operation> requests = transaction.getRequests();
+            Status status = new Status(StatusCode.SUCCESS);
+            for (int i = 0; i < tr.size(); i++) {
+                if (i < requests.size()) requests.get(i).setResult(tr.get(i));
+                if (tr.get(i) != null && tr.get(i).getError() != null && tr.get(i).getError().trim().length() > 0) {
+                    OperationResult result = tr.get(i);
+                    status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
+                }
+            }
+
+            if (tr.size() > requests.size()) {
+                OperationResult result = tr.get(tr.size() - 1);
+                logger.error("Error creating Bridge : {}\n Error : {}\n Details : {}",
+                        uuid, result.getError(), result.getDetails());
+                status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
+            }
+            return status;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return new Status(StatusCode.INTERNALERROR);
     }
 
-    @Override
-    public Status deleteRow(Node node, String tableName, String uuid) {
-        return new Status(StatusCode.NOTIMPLEMENTED, "Delete Row functionality is not implemented yet.");
+    private Status deletePortRow(Node node, String uuid) {
+        return new Status(StatusCode.INTERNALERROR);
     }
 
-    @Override
-    public List<Table<?>> getRows(Node node, String tableName) {
-        // TODO Auto-generated method stub
-        return null;
+    private Status deleteInterfaceRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
     }
 
-    @Override
-    public Table<?> getRow(Node node, String tableName, String uuid) {
-        // TODO Auto-generated method stub
-        return null;
+    private Status deleteOpen_vSwitchRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
     }
 
-    @Override
-    public List<String> getTables(Node node) {
-        // TODO Auto-generated method stub
-        return null;
+    private Status deleteControllerRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteSSLRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteSflowRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteQueueRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteQosRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteNetFlowRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteMirrorRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteManagerRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
+    }
+
+    private Status deleteCapabilityRow(Node node, String uuid) {
+        return new Status(StatusCode.NOTIMPLEMENTED, "delete operation for this Table is not implemented yet.");
     }
 
     public void _ovsconnect (CommandInterpreter ci) {
index e2e9c37f21ec77b88f0d5522558edad0e36d1ac1..4032541201172d3f2611cf0f0113f87df9e8c368 100644 (file)
@@ -8,9 +8,9 @@ import org.opendaylight.ovsdb.lib.table.internal.Table;
 
 public interface OVSDBConfigService {
     public Status insertRow (Node node, String tableName, String parentUUID, Table<?> row);
-    public Status deleteRow (Node node, String tableName, String uuid);
-    public Status updateRow (Node node, String rowUUID, Table<?> row);
-    public Table<?> getRow(Node node, String tableName, String uuid);
-    public List<Table<?>> getRows(Node node, String tableName);
-    public List<String> getTables(Node node);
+    public Status deleteRow (Node node, String tableName, String rowUUID);
+    public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Table<?> row);
+    public String getRow(Node node, String tableName, String uuid) throws Exception;
+    public String getRows(Node node, String tableName) throws Exception;
+    public List<String> getTables(Node node) throws Exception;
 }