Merge "Changed the constant name logger to LOGGER to comply with the naming convention"
authorFlavio Fernandes <ffernand@redhat.com>
Fri, 20 Mar 2015 21:38:01 +0000 (21:38 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 20 Mar 2015 21:38:01 +0000 (21:38 +0000)
northbound/src/main/java/org/opendaylight/ovsdb/northbound/NodeResource.java
northbound/src/test/java/org/opendaylight/ovsdb/northbound/NodeResourceTest.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/FlowCapableNodeDataChangeListener.java
resources/commons/OVSDB_Southbound.postman_collection
southbound/southbound-api/src/main/yang/ovsdb.yang
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbNodeDataChangeListener.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundConstants.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeCreateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java

index 34745cf37ef5cad65311d705292f9be5514e5f18..a4fc913c0f011167cab3a2c5aa653cbdf5388c2e 100644 (file)
@@ -97,7 +97,7 @@ public class NodeResource {
 
         List<String> nodeIds = Lists.newArrayList();
         for (Node node : nodes) {
-            nodeIds.add(node.toString());
+            nodeIds.add(node.getId().getValue());
         }
 
         String response = objectMapper.writeValueAsString(nodeIds);
index 5e52c35f676fc03568febd1d26ce8dc26b0c0bb2..e2e0f896da2565c0ca880dff9ad06d300300065a 100644 (file)
@@ -9,6 +9,7 @@
  */
 package org.opendaylight.ovsdb.northbound;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
@@ -16,6 +17,10 @@ import static org.mockito.Matchers.anyObject;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.when;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.common.collect.Lists;
+import java.util.List;
+import javax.ws.rs.core.Response;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
@@ -28,13 +33,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(ServiceHelper.class)
 public class NodeResourceTest {
+    static final Logger LOG = LoggerFactory.getLogger(NodeResourceTest.class);
     private static final String OVS = "OVS";
     private static final String IDENTIFIER = "192.168.120.31:45001";
+    private static final String IDENTIFIER2 = "192.168.120.31:45002";
     private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
+    private static final String OVS_IDENTIFIER2 = OVS + "|" + IDENTIFIER2;
     private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
 
     @Test
@@ -98,4 +108,65 @@ public class NodeResourceTest {
         testConnection = NodeResource.getOvsdbConnection(IDENTIFIER, this);
         assertNotNull("Connection " + OVS_IDENTIFIER + " is null", testConnection);
     }
+
+    @Test
+    public void testGetNodes () {
+        ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
+
+        PowerMockito.mockStatic(ServiceHelper.class);
+        when(ServiceHelper.getGlobalInstance(eq(OvsdbConnectionService.class), anyObject()))
+                .thenReturn(connectionService)
+                .thenReturn(connectionService)
+                .thenReturn(connectionService);
+
+        NodeResource nodeResource = new NodeResource();
+
+        // Check getNodes when there are no nodes
+        try {
+            Response response = nodeResource.getNodes();
+            assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+            assertNotNull("entity should not be null", response.getEntity());
+            String id = new String();
+            List<String> ids = Lists.newArrayList();
+            ids.add(id);
+            assertEquals("there should be no nodes", ids.toString(), response.getEntity());
+        } catch (JsonProcessingException ex) {
+            fail("Exception should not have been caught");
+        }
+
+        // Check getNodes when there is a node
+        Connection connection = new Connection(IDENTIFIER, null);
+        connectionService.putOvsdbConnection(IDENTIFIER, connection);
+
+        try {
+            Response response = nodeResource.getNodes();
+            assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+            assertNotNull("entity should not be null", response.getEntity());
+            String id = new String("\"" + OVS_IDENTIFIER + "\"");
+            List<String> ids = Lists.newArrayList();
+            ids.add(id);
+            assertEquals(OVS_IDENTIFIER + " should be found", ids.toString(), response.getEntity());
+        } catch (JsonProcessingException ex) {
+            fail("Exception should not have been caught");
+        }
+
+        // Check getNodes when there are multiple nodes
+        connection = new Connection(IDENTIFIER2, null);
+        connectionService.putOvsdbConnection(IDENTIFIER2, connection);
+
+        try {
+            Response response = nodeResource.getNodes();
+            assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+            assertNotNull("entity should not be null", response.getEntity());
+            String id = new String("\"" + OVS_IDENTIFIER + "\"");
+            String id2 = new String("\"" + OVS_IDENTIFIER2 + "\"");
+            List<String> ids = Lists.newArrayList();
+            ids.add(id);
+            ids.add(id2);
+            assertEquals(OVS_IDENTIFIER + " and " + OVS_IDENTIFIER2 + " should be found",
+                    ids.toString().replaceAll("\\s",""), response.getEntity());
+        } catch (JsonProcessingException ex) {
+            fail("Exception should not have been caught");
+        }
+    }
 }
index 878a0f29f87fde28dae5145acf1b9010c9b10365..02b649ed45568f812afb42063e393dc3252f801a 100644 (file)
@@ -49,8 +49,8 @@ public class FlowCapableNodeDataChangeListener implements DataChangeListener, Au
 
     public FlowCapableNodeDataChangeListener (DataBroker dataBroker) {
         LOG.info("Registering FlowCapableNodeChangeListener");
-        registration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
-                createFlowCapableNodePath(), this, AsyncDataBroker.DataChangeScope.ONE);
+        registration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                createFlowCapableNodePath(), this, AsyncDataBroker.DataChangeScope.BASE);
     }
 
     @Override
@@ -88,7 +88,7 @@ public class FlowCapableNodeDataChangeListener implements DataChangeListener, Au
         for (Map.Entry<InstanceIdentifier<?>, DataObject> updated : changes.getUpdatedData().entrySet()) {
             InstanceIdentifier<?> iID = updated.getKey();
             String openflowId = iID.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
-            LOG.trace(">>>>> updated iiD: {} - first: {} - NodeKey: {}",
+            LOG.info(">>>>> updated iiD: {} - first: {} - NodeKey: {}",
                     iID, iID.firstIdentifierOf(Node.class), openflowId);
             Node openFlowNode = NodeUtils.getOpenFlowNode(openflowId);
             if (nodeCache.contains(openFlowNode)) {
@@ -101,7 +101,7 @@ public class FlowCapableNodeDataChangeListener implements DataChangeListener, Au
 
     private void notifyNodeUpdated (Node openFlowNode) {
         final String openflowId = openFlowNode.getId().getValue();
-        LOG.trace("notifyNodeUpdated: Node {} from Controller's inventory Service", openflowId);
+        LOG.info("notifyNodeUpdated: Node {} from Controller's inventory Service", openflowId);
 
         // TODO: will do something amazing here, someday
     }
index b26acacaa7cd5715e9caa5d7009c8e9def6478d1..d63d04d19b5a7d0065dc6ac85cab1b923b1bea1f 100644 (file)
 {
-       "id": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-       "name": "Ovsdb Southbound Collection",
-       "timestamp": 1424977469540,
-       "order": [
-               "25991d63-bce2-fd31-6504-c5602b0a7099",
-               "19541dee-f73c-ac03-ff4e-36d65a313624",
-               "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
-               "da0ea53d-ea33-c15f-5140-9eb339445ee1",
-               "b542ee70-45fd-824f-ab33-a5c3bae38d24",
-               "91d7a25c-13a7-486d-f23e-1e90c485d78e"
-       ],
-       "owner": 0,
-       "sharedWithTeam": false,
-       "synced": false,
-       "subscribed": false,
-       "hasRequests": true,
-       "requests": [
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "19541dee-f73c-ac03-ff4e-36d65a313624",
-                       "name": "Get Operational Topology",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/operational/network-topology:network-topology/",
-                       "method": "GET",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
-                       "data": [],
-                       "dataMode": "params",
-                       "timestamp": 0,
-                       "responses": [],
-                       "version": 2,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false
-               },
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "25991d63-bce2-fd31-6504-c5602b0a7099",
-                       "name": "Create Specific Config OvsdbNode",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
-                       "method": "PUT",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-                       "data": [],
-                       "dataMode": "raw",
-                       "timestamp": 0,
-                       "version": 2,
-                       "time": 1425926377425,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false,
-                       "rawModeData": "{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"ovsdb:/127.0.0.1: 16640\",\n            \"ovsdb:port\": 16640,\n            \"ovsdb:ip\": \"127.0.0.1\"\n        }\n    ]\n}"
-               },
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
-                       "name": "Create Specific Config Bridge",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F127.0.0.1:16640%2Fbridge%2Fbr02",
-                       "method": "PUT",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-                       "data": [],
-                       "dataMode": "raw",
-                       "timestamp": 0,
-                       "version": 2,
-                       "time": 1426530506948,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false,
-                       "rawModeData": "{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"ovsdb://127.0.0.1:16640/bridge/br02\",\n             \"ovsdb:bridge-name\": \"br02\",\n             \"ovsdb:datapath-id\": \"00:00:b2:bf:48:25:f2:4b\",\n             \"ovsdb:protocol-entry\": [\n                {\n                  \"protocol\": \"ovsdb:ovsdb-bridge-protocol-openflow-13\"\n                }\n              ],\n              \"ovsdb:controller-entry\": [\n                {\n                  \"target\": \"tcp:127.0.0.1:6633\"\n                }\n              ],\n             \"ovsdb:managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://127.0.0.1:16640']\"\n        }\n    ]\n}"
-               },
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "91d7a25c-13a7-486d-f23e-1e90c485d78e",
-                       "name": "Get Specific Config OvsdbNode",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
-                       "method": "GET",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
-                       "data": [],
-                       "dataMode": "params",
-                       "timestamp": 0,
-                       "responses": [],
-                       "version": 2,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false
-               },
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "b542ee70-45fd-824f-ab33-a5c3bae38d24",
-                       "name": "Get Config Topology",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/config/network-topology:network-topology/",
-                       "method": "GET",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
-                       "data": [],
-                       "dataMode": "params",
-                       "timestamp": 0,
-                       "responses": [],
-                       "version": 2,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false
-               },
-               {
-                       "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
-                       "id": "da0ea53d-ea33-c15f-5140-9eb339445ee1",
-                       "name": "Delete Specific Config OvsdbNode",
-                       "description": "",
-                       "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
-                       "method": "DELETE",
-                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
-                       "data": [],
-                       "dataMode": "params",
-                       "timestamp": 0,
-                       "responses": [],
-                       "version": 2,
-                       "owner": 0,
-                       "preRequestScript": "",
-                       "tests": "",
-                       "synced": false
-               }
-       ]
-}
\ No newline at end of file
+  "id": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+  "name": "Ovsdb Southbound Collection",
+  "timestamp": 1424977469540,
+  "order": [
+    "25991d63-bce2-fd31-6504-c5602b0a7099",
+    "19541dee-f73c-ac03-ff4e-36d65a313624",
+    "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
+    "da0ea53d-ea33-c15f-5140-9eb339445ee1",
+    "b542ee70-45fd-824f-ab33-a5c3bae38d24",
+    "91d7a25c-13a7-486d-f23e-1e90c485d78e"
+  ],
+  "requests": [
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "19541dee-f73c-ac03-ff4e-36d65a313624",
+      "name": "Get Operational Topology",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/operational\/network-topology:network-topology\/",
+      "method": "GET",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+      "data": [
+
+      ],
+      "dataMode": "params",
+      "timestamp": 0,
+      "responses": [
+
+      ],
+      "version": 2
+    },
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "25991d63-bce2-fd31-6504-c5602b0a7099",
+      "name": "Create Specific Config OvsdbNode",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+      "method": "PUT",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application\/json\n",
+      "data": "{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"ovsdb:\/127.0.0.1: 16640\",\n            \"ovsdb:port\": 16640,\n            \"ovsdb:ip\": \"127.0.0.1\"\n        }\n    ]\n}",
+      "dataMode": "raw",
+      "timestamp": 0,
+      "version": 2,
+      "time": 1425926377425
+    },
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
+      "name": "Create Specific Config Bridge",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F%2F127.0.0.1:16640%2Fbridge%2Fbr02",
+      "method": "PUT",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application\/json\n",
+      "data": "{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"ovsdb:\/\/127.0.0.1:16640\/bridge\/br02\",\n             \"ovsdb:bridge-name\": \"br02\",\n             \"ovsdb:protocol-entry\": [\n                {\n                  \"protocol\": \"ovsdb:ovsdb-bridge-protocol-openflow-13\"\n                }\n              ],\n              \"ovsdb:controller-entry\": [\n                {\n                  \"target\": \"tcp:127.0.0.1:6633\"\n                }\n              ],\n              \"ovsdb:fail-mode\": \"ovsdb:ovsdb-fail-mode-secure\",\n             \"ovsdb:managed-by\": \"\/network-topology:network-topology\/network-topology:topology[network-topology:topology-id='ovsdb:1']\/network-topology:node[network-topology:node-id='ovsdb:\/\/127.0.0.1:16640']\"\n        }\n    ]\n}",
+      "dataMode": "raw",
+      "timestamp": 0,
+      "version": 2,
+      "time": 1426707526682
+    },
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "91d7a25c-13a7-486d-f23e-1e90c485d78e",
+      "name": "Get Specific Config OvsdbNode",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+      "method": "GET",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+      "data": [
+
+      ],
+      "dataMode": "params",
+      "timestamp": 0,
+      "responses": [
+
+      ],
+      "version": 2
+    },
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "b542ee70-45fd-824f-ab33-a5c3bae38d24",
+      "name": "Get Config Topology",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/",
+      "method": "GET",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+      "data": [
+
+      ],
+      "dataMode": "params",
+      "timestamp": 0,
+      "responses": [
+
+      ],
+      "version": 2
+    },
+    {
+      "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+      "id": "da0ea53d-ea33-c15f-5140-9eb339445ee1",
+      "name": "Delete Specific Config OvsdbNode",
+      "description": "",
+      "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+      "method": "DELETE",
+      "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+      "data": [
+
+      ],
+      "dataMode": "params",
+      "timestamp": 0,
+      "responses": [
+
+      ],
+      "version": 2
+    }
+  ]
+}
index a910d23006c7f3c5c7b12743b1f943a65baaf07d..28440f199ac5c2b42a88e93fc8bbc7316b7a5507 100644 (file)
@@ -51,6 +51,20 @@ module ovsdb {
            RFC 2579: Textual Conventions for SMIv2";
     }
 
+    identity datapath-type-base {
+        description "Base identity for all OVSDB datapath types";
+    }
+
+    identity datapath-type-system {
+        description "Datapath type for the kernel datapath";
+        base datapath-type-base;
+    }
+
+    identity datapath-type-netdev {
+        description "Datapath type for the userspace datapath";
+        base datapath-type-base;
+    }
+
     identity ovsdb-bridge-protocol-base {
         description "Base identity for all ovsdb-bridge-protocols";
     }
@@ -85,6 +99,20 @@ module ovsdb {
         base ovsdb-bridge-protocol-base;
     }
 
+    identity ovsdb-fail-mode-base {
+        description "Base identity for ovsdb-failmode";
+    }
+
+    identity ovsdb-fail-mode-standalone {
+        description "Identity for ovsdb-failmode standalone";
+        base ovsdb-fail-mode-base;
+    }
+
+    identity ovsdb-fail-mode-secure {
+        definition "Identity for ovsdb-failmode standalone";
+        base ovsdb-fail-mode-base;
+    }
+
     grouping ovsdb-bridge-attributes {
         leaf bridge-uuid {
             description "The unique identifier of the bridge";
@@ -119,6 +147,20 @@ module ovsdb {
             type datapath-id;
         }
 
+        leaf datapath-type {
+            description "The datapath type of the bridge";
+            type identityref {
+                base datapath-type-base;
+            }
+        }
+
+        leaf fail-mode {
+            description "Failmode of the bridge";
+            type identityref {
+                base ovsdb-fail-mode-base;
+            }
+        }
+
         leaf flow-node {
             description "Flow node corresponding to this bridge";
             type flow-node-ref;
@@ -166,6 +208,51 @@ module ovsdb {
         base interface-type-base;
     }
 
+    identity interface-type-tap {
+        description "Interface type for tun/tap interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-geneve {
+        description "Interface type for geneve interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-gre {
+        description "Interface type for gre interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-ipsec-gre {
+        description "Interface type for ipsec-gre interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-gre64 {
+        description "Interface type for gre64 interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-ipsec-gre64 {
+        description "Interface type for ipsec-gre64 interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-lisp {
+        description "Interface type for lisp interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-dpdk {
+        description "Interface type for dpdk interfaces";
+        base interface-type-base;
+    }
+
+    identity interface-type-dpdkr {
+        description "Interface type for dpdk ring interfaces";
+        base interface-type-base;
+    }
+
     grouping ovsdb-port-interface-attributes {
         leaf port-uuid {
             description "The unique identifier of the OVSDB port";
index 26593181c4fb8036e4b3c33e29ed6a5802c8b91f..82a899c2434e9ee0b271f62a75a7ee68fcb98ed0 100644 (file)
@@ -51,7 +51,7 @@ public class OvsdbNodeDataChangeListener implements DataChangeListener, AutoClos
     @Override
     public void onDataChanged(
             AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
-        LOG.info("Received change to ovsdbNode: {}", changes);
+        LOG.debug("Received change to ovsdbNode: {}", changes);
         for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
             // TODO validate we have the correct kind of InstanceIdentifier
             if (created.getValue() instanceof OvsdbNodeAugmentation) {
index 51994e050fa744594857ddded446ae067eacb72e..ecd37e42ff450da8cc7bd40e0ddf367bfa9f6d67 100644 (file)
@@ -8,6 +8,20 @@
 package org.opendaylight.ovsdb.southbound;
 
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeInternal;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypePatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeSystem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeTap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGeneve;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeIpsecGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeIpsecGre64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeLisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeDpdk;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeDpdkr;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow11;
@@ -15,6 +29,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow13;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow14;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow15;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeSecure;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeStandalone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeSystem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeNetdev;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 
 import com.google.common.collect.ImmutableBiMap;
@@ -33,4 +53,30 @@ public class SouthboundConstants {
             .put(OvsdbBridgeProtocolOpenflow14.class,"OpenFlow14")
             .put(OvsdbBridgeProtocolOpenflow15.class,"OpenFlow15")
             .build();
+
+    public static final ImmutableBiMap<Class<? extends OvsdbFailModeBase>,String> OVSDB_FAIL_MODE_MAP = new ImmutableBiMap.Builder<Class<? extends OvsdbFailModeBase>,String>()
+            .put(OvsdbFailModeStandalone.class,"standalone")
+            .put(OvsdbFailModeSecure.class,"secure")
+            .build();
+
+    public static final ImmutableBiMap<String, Class<? extends InterfaceTypeBase>> OVSDB_INTERFACE_TYPE_MAP = new ImmutableBiMap.Builder<String, Class<? extends InterfaceTypeBase>>()
+            .put("internal", InterfaceTypeInternal.class)
+            .put("vxlan", InterfaceTypeVxlan.class)
+            .put("patch", InterfaceTypePatch.class)
+            .put("system", InterfaceTypeSystem.class)
+            .put("tap", InterfaceTypeTap.class)
+            .put("geneve", InterfaceTypeGeneve.class)
+            .put("gre", InterfaceTypeGre.class)
+            .put("ipsec_gre", InterfaceTypeIpsecGre.class)
+            .put("gre64", InterfaceTypeGre64.class)
+            .put("ipsec_gre64", InterfaceTypeIpsecGre64.class)
+            .put("lisp", InterfaceTypeLisp.class)
+            .put("dpdk", InterfaceTypeDpdk.class)
+            .put("dpdkr", InterfaceTypeDpdkr.class)
+            .build();
+
+    public static final ImmutableBiMap<Class<? extends DatapathTypeBase>,String> DATAPATH_TYPE_MAP = new ImmutableBiMap.Builder<Class<? extends DatapathTypeBase>,String>()
+            .put(DatapathTypeSystem.class,"system")
+            .put(DatapathTypeNetdev.class,"netdev")
+            .build();
 }
index d873841c8a85a481bca7a88dbc54f6689378afc1..ba96c942f305fc8ef9fe37223571013f974c971a 100644 (file)
@@ -31,6 +31,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeSystem;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
@@ -212,6 +214,19 @@ public class SouthboundMapper {
         }
     }
 
+    public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
+        String datapathtype = new String(SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class));
+
+        if (mdsalbridge.getDatapathType() != null) {
+            if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
+                datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+            } else {
+                throw new IllegalArgumentException("Unknown datapath type " + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+            }
+        }
+        return datapathtype;
+    }
+
     public static DatapathId createDatapathId(String dpid) {
         Preconditions.checkNotNull(dpid);
         DatapathId datapath;
@@ -239,6 +254,11 @@ public class SouthboundMapper {
         return protocols;
     }
 
+    public static  Class<? extends InterfaceTypeBase> createInterfaceType(String type) {
+        Preconditions.checkNotNull(type);
+        return SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(type);
+    }
+
     public static List<ProtocolEntry> createMdsalProtocols(Bridge bridge) {
         Set<String> protocols = bridge.getProtocolsColumn().getData();
         List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
@@ -254,7 +274,7 @@ public class SouthboundMapper {
     }
 
     public static List<ControllerEntry> createControllerEntries(Bridge bridge,Map<UUID,Controller> updatedControllerRows) {
-        LOG.info("Bridge: {}, updatedControllerRows: {}",bridge,updatedControllerRows);
+        LOG.debug("Bridge: {}, updatedControllerRows: {}",bridge,updatedControllerRows);
         Set<UUID> controllerUUIDs = bridge.getControllerColumn().getData();
         List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
         for(UUID controllerUUID : controllerUUIDs ) {
index 2838ef199577dcae2582ce09b7dfd5ee704e5e40..2e6513a2c74c98e218fa6dc8d64f6182dacaa045 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
@@ -48,8 +49,12 @@ public class BridgeCreateCommand implements TransactCommand {
             // Bridge part
             Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class);
             bridge.setName(ovsdbManagedNode.getBridgeName().getValue());
+            if(ovsdbManagedNode.getFailMode() != null &&
+                    SouthboundConstants.OVSDB_FAIL_MODE_MAP.get(ovsdbManagedNode.getFailMode()) != null ) {
+                bridge.setFailMode(Sets.newHashSet(SouthboundConstants.OVSDB_FAIL_MODE_MAP.get(ovsdbManagedNode.getFailMode())));
+            }
             String namedUuid = "Bridge_" + ovsdbManagedNode.getBridgeName().getValue();
-            bridge.setName(ovsdbManagedNode.getBridgeName().getValue());
+            bridge.setDatapathType(SouthboundMapper.createDatapathType(ovsdbManagedNode));
             if(SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode) != null
                     && SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode).size() > 0){
                 bridge.setProtocols(SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode));
index 745f8b32f224e3a2d0d367af25b26934c292e5b1..60697e019af0e4362effefd55b30754fc2e83f0f 100644 (file)
@@ -1,11 +1,9 @@
 package org.opendaylight.ovsdb.southbound.transactions.md;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -17,8 +15,8 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
 import org.opendaylight.ovsdb.schema.openvswitch.Controller;
 import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
@@ -28,8 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -63,7 +59,7 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
                 LOG.debug("Read Operational/DS for Node fail! {}", nodePath, e);
             }
             if(node.isPresent()){
-                LOG.info("Node {} is present",node);
+                LOG.debug("Node {} is present",node);
                 NodeBuilder managedNodeBuilder = new NodeBuilder();
                 NodeId manageNodeId = SouthboundMapper.createManagedNodeId(getKey(), new OvsdbBridgeName(bridge.getName()));
                 managedNodeBuilder.setNodeId(manageNodeId);
@@ -82,6 +78,14 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand {
                 if(!SouthboundMapper.createControllerEntries(bridge, updatedControllerRows).isEmpty()) {
                     ovsdbManagedNodeBuilder.setControllerEntry(SouthboundMapper.createControllerEntries(bridge, updatedControllerRows));
                 }
+
+                if(bridge.getFailModeColumn() != null &&
+                        bridge.getFailModeColumn().getData() != null &&
+                        !bridge.getFailModeColumn().getData().isEmpty()) {
+                    String[] failmodeArray = new String[bridge.getFailModeColumn().getData().size()];
+                    bridge.getFailModeColumn().getData().toArray(failmodeArray);
+                    ovsdbManagedNodeBuilder.setFailMode(SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get(failmodeArray[0]));
+                }
                 ovsdbManagedNodeBuilder.setManagedBy(new OvsdbNodeRef(nodePath));
                 managedNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbManagedNodeBuilder.build());
 
index d4b493714cca08b76e9373bf0b4d11145ffb2740..c16b93111fdbb8d552b54bf4bbf7b53f323cc3e1 100644 (file)
@@ -12,14 +12,19 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.Column;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
+import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
@@ -94,6 +99,20 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
                                     .setName(port.getName());
                             ovsdbTerminationPointBuilder.setPortUuid(new Uuid(
                                     port.getUuid().toString()));
+                            Column<GenericTableSchema, Set<UUID>> iface = port.getInterfacesColumn();
+                            Set<UUID> ifUuid = iface.getData();
+                            Collection<Interface> ifUpdateRows = TyperUtils.extractRowsUpdated(Interface.class, getUpdates(),  getDbSchema()).values();
+                            for (UUID ifIter : ifUuid) {
+                                for (Interface interfIter : ifUpdateRows) {
+                                    Column<GenericTableSchema, String> typeColumn = interfIter.getTypeColumn();
+                                    String type = typeColumn.getData();
+                                    if ((interfIter.getUuid()).equals(ifIter)) {
+                                        ovsdbTerminationPointBuilder.setInterfaceUuid(new Uuid(interfIter.getUuid().toString()));
+                                        ovsdbTerminationPointBuilder.setInterfaceType(SouthboundMapper.createInterfaceType(type));
+                                        break;
+                                    }
+                                }
+                            }
                             entry.addAugmentation(
                                     (Class<? extends Augmentation<TerminationPoint>>) OvsdbTerminationPointAugmentation.class,
                                     ovsdbTerminationPointBuilder.build());