Merge changes from topic 'sonar-cleanup'
authorSam Hague <shague@redhat.com>
Mon, 30 Nov 2015 16:30:50 +0000 (16:30 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 30 Nov 2015 16:30:50 +0000 (16:30 +0000)
* changes:
  Remove unused code and imports
  General code cleanup
  Simplify AbstractNeutronInterface::readMd

openstack/net-virt-it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/it/NetvirtIT.java
openstack/net-virt-it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/it/NetvirtITConstants.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/ConfigurationService.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/Southbound.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/ConfigurationServiceImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SouthboundImpl.java
openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImplTest.java
resources/commons/Ovsdb-HwvtepSouthbound-Collection.json.postman_collection

index 3cfb7f28a54c33385f2fbf0c903b10560d8ac62d..31183ef5371850c3cdf27cd9625fd116c9ac8b2e 100644 (file)
@@ -162,7 +162,8 @@ public class NetvirtIT extends AbstractMdsalTestBase {
         return new Option[] {
                 propagateSystemProperties(NetvirtITConstants.SERVER_IPADDRESS,
                         NetvirtITConstants.SERVER_PORT, NetvirtITConstants.CONNECTION_TYPE,
-                        NetvirtITConstants.CONTROLLER_IPADDRESS),
+                        NetvirtITConstants.CONTROLLER_IPADDRESS,
+                        NetvirtITConstants.USERSPACE_ENABLED)
         };
     }
 
@@ -192,9 +193,11 @@ public class NetvirtIT extends AbstractMdsalTestBase {
         addressStr = props.getProperty(NetvirtITConstants.SERVER_IPADDRESS);
         portStr = props.getProperty(NetvirtITConstants.SERVER_PORT, NetvirtITConstants.DEFAULT_SERVER_PORT);
         connectionType = props.getProperty(NetvirtITConstants.CONNECTION_TYPE, "active");
-        controllerStr = props.getProperty(NetvirtITConstants.CONTROLLER_IPADDRESS);
-        LOG.info("setUp: Using the following properties: mode= {}, ip:port= {}:{}, controller ip: {}",
-                connectionType, addressStr, portStr, controllerStr);
+        controllerStr = props.getProperty(NetvirtITConstants.CONTROLLER_IPADDRESS, "0.0.0.0");
+        String userSpaceEnabled = props.getProperty(NetvirtITConstants.USERSPACE_ENABLED, "no");
+        LOG.info("setUp: Using the following properties: mode= {}, ip:port= {}:{}, controller ip: {}, " +
+                "userspace.enabled: {}",
+                connectionType, addressStr, portStr, controllerStr, userSpaceEnabled);
         if (connectionType.equalsIgnoreCase(NetvirtITConstants.CONNECTION_TYPE_ACTIVE)) {
             if (addressStr == null) {
                 fail(usage());
@@ -664,13 +667,12 @@ public class NetvirtIT extends AbstractMdsalTestBase {
      * </pre>
      * @throws InterruptedException
      */
-    @Ignore
     @Test
     public void testNetVirt() throws InterruptedException {
         ConnectionInfo connectionInfo = getConnectionInfo(addressStr, portStr);
         Node ovsdbNode = connectOvsdbNode(connectionInfo);
 
-        Thread.sleep(30000);
+        Thread.sleep(15000);
         // Verify the pipeline flows were installed
         PipelineOrchestrator pipelineOrchestrator =
                 (PipelineOrchestrator) ServiceHelper.getGlobalInstance(PipelineOrchestrator.class, this);
index 4fea5264b6a2c99a7619c2611aa9d335468fe65c..347be949553c2f0723a59f629473578a82a14b4e 100644 (file)
@@ -20,6 +20,7 @@ public final class NetvirtITConstants {
     public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
     public static final String SERVER_PORT = "ovsdbserver.port";
     public static final String CONTROLLER_IPADDRESS = "ovsdb.controller.address";
+    public static final String USERSPACE_ENABLED = "ovsdb.userspace.enabled";
     public static final String SERVER_EXTRAS = "ovsdbserver.extras";
     public static final String CONNECTION_TYPE = "ovsdbserver.connection";
     public static final String CONNECTION_TYPE_ACTIVE = "active";
index a41eb1020eeb8faaae9a6d339f12aac06ae8e6b8..209530b0ed4abe92547aafaa06b8cc1a29b047ad 100644 (file)
@@ -141,4 +141,6 @@ public interface ConfigurationService {
      * @return the MacAddress to use for the default gateway; or null if none is configured.
      */
     String getDefaultGatewayMacAddress(Node node);
+
+    boolean isUserSpaceEnabled();
 }
index f0baac9d1cb7672db24c918fc968be4b4b9077a3..6805837e7dff92b2b517b19a8548f1ef679c29e1 100644 (file)
@@ -11,6 +11,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+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.OvsdbBridgeAugmentation;
 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.OvsdbTerminationPointAugmentation;
@@ -36,7 +37,8 @@ public interface Southbound {
     boolean isBridgeOnOvsdbNode(Node node, String bridgeName);
     String getOvsdbNodeUUID(Node node);
     String getOsdbNodeExternalIdsValue(OvsdbNodeAugmentation ovsdbNodeAugmentation, String key);
-    boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr);
+    boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
+                      final Class<? extends DatapathTypeBase> dpType);
     boolean deleteBridge(Node ovsdbNode);
     OvsdbBridgeAugmentation readBridge(Node node, String name);
     Node readBridgeNode(Node node, String name);
index 74d90064c9fa9aa9d3aa114e4c60dfe39e9f083a..d59f53601734280d497669f225369496a3d40f84 100644 (file)
@@ -19,6 +19,9 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+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.DatapathTypeNetdev;
+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.OvsdbNodeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagerEntry;
@@ -483,7 +486,11 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage
         boolean rv = true;
         if ((!southbound.isBridgeOnOvsdbNode(ovsdbNode, bridgeName)) ||
                 (southbound.getBridgeFromConfig(ovsdbNode, bridgeName) == null)) {
-            rv = southbound.addBridge(ovsdbNode, bridgeName, getControllersFromOvsdbNode(ovsdbNode));
+            Class<? extends DatapathTypeBase> dpType = null;
+            if (configurationService.isUserSpaceEnabled()) {
+                dpType = DatapathTypeNetdev.class;
+            }
+            rv = southbound.addBridge(ovsdbNode, bridgeName, getControllersFromOvsdbNode(ovsdbNode), dpType);
         }
         return rv;
     }
index 79fa1921de9b003a114e225b41a6cd085371b258..c9691fce72a395d4c0db83e6f8a7e013ffd27430 100644 (file)
@@ -178,6 +178,12 @@ public class ConfigurationServiceImpl implements ConfigurationService, ConfigInt
         return l3gatewayForNode;
     }
 
+    @Override
+    public boolean isUserSpaceEnabled() {
+        final String enabledPropertyStr = ConfigProperties.getProperty(this.getClass(), "ovsdb.userspace.enabled");
+        return enabledPropertyStr != null && enabledPropertyStr.equalsIgnoreCase("yes");
+    }
+
     @Override
     public void setDependencies(ServiceReference serviceReference) {
         southbound =
index 38eeaecbdab60b1cf01d9e76dbf35d85703f1943..090e140a98de0d8ddfd6664d5c442ac61b983f58 100644 (file)
@@ -21,16 +21,7 @@ import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
 import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
 import org.opendaylight.ovsdb.openstack.netvirt.api.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.DatapathTypeNetdev;
-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.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder;
-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;
-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.OvsdbNodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder;
@@ -182,7 +173,8 @@ public class SouthboundImpl implements Southbound {
         return value;
     }
 
-    public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr) {
+    public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
+                             final Class<? extends DatapathTypeBase> dpType) {
         boolean result = false;
 
         LOG.info("addBridge: node: {}, bridgeName: {}, controller(s): {}", ovsdbNode, bridgeName, controllersStr);
@@ -207,6 +199,9 @@ public class SouthboundImpl implements Southbound {
             bridgeOtherConfigsList.add(bridgeOtherConfigsBuilder.build());
             ovsdbBridgeAugmentationBuilder.setBridgeOtherConfigs(bridgeOtherConfigsList);
             setManagedByForBridge(ovsdbBridgeAugmentationBuilder, ovsdbNode.getKey());
+            if (dpType != null) {
+                ovsdbBridgeAugmentationBuilder.setDatapathType(dpType);
+            }
             if (isOvsdbNodeDpdk(ovsdbNode)) {
                 ovsdbBridgeAugmentationBuilder.setDatapathType(DatapathTypeNetdev.class);
             }
index 5246a42b02cb09a81cf975a590cb5d9aa0d32a61..c5073c336340f130074a7dbe6f8e2e558b83a1c2 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+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.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
@@ -223,7 +224,7 @@ public class BridgeConfigurationManagerImplTest {
         PowerMockito.mockStatic(ConfigProperties.class);
         when(ConfigProperties.getProperty(any(Class.class), anyString())).thenReturn(ADDRESS);
 
-        when(southbound.addBridge(any(Node.class), anyString(), anyList())).thenReturn(true);
+        when(southbound.addBridge(any(Node.class), anyString(), anyList(), eq(DatapathTypeSystem.class))).thenReturn(true);
         when(configurationService.isL3ForwardingEnabled()).thenReturn(true);
 
         bridgeConfigurationManagerImpl.prepareNode(node);
index 7c98745706c4ecfe68e6aa76d9a51258f7b4e7ae..524fa8b1dc080c27b5d334e23630b2a1a8800695 100755 (executable)
@@ -29,7 +29,7 @@
             "id":"18032e93-3bc5-9976-4525-fe1e77e98207",
             "name":"Delete Specific Config Logical Switch",
             "description":"This restconf request delete specific logical switch from the config data store.",
-            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640/logical-switches/ls0",
             "method":"DELETE",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
             "data":[],
             "id":"538c71b3-e3e6-f01b-cc4c-d2b686686aa8",
             "name":"Get Specific Operational Logical Switch",
             "description":"This restconf request fetch the operational for specific Logical Switch",
-            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2logicalswitch%2ls0",
+            "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640/logical-switches/ls0",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":[],
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"9bc22ca7-049c-af51-7c12-6bf71044b2ec",
             "name":"Create Specific Config Logical Switch",
             "description":"Fire this Restconf request if you want to create a logical switch.",
-            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"POST",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\"             \n        }\n    ]\n}",
+            "data":"{\n  \"logical-switches\": [\n        {\n            \"hwvtep-node-name\": \"ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"tunnel-key\": \"10000\"\n         }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "url":"http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":[],
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"ee151670-85a0-30ec-b22b-5defe7b66e0b",
             "name":"Get Config  Hwvtep Topology",
             "description":"Fetch the config hwvtep topology from configuration data store.",
-            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/hwvtep:1/",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
             "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640\",\n            \"connection-info\": {\n              \"hwvtep:remote-port\": 6640,\n              \"hwvtep:remote-ip\": \"{{hwvtepNodeIp}}\"\n            }\n        }\n    ]\n}",
         {
             "collectionId":"19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
             "id":"f6d300f7-380a-d090-0d4a-2b2ddefe5104",
-            "name":"Create Specific Config Logical Switch",
+            "name":"Update Specific Config Logical Switch",
             "description":"Fire this request if you want to update specific logical switch.",
-            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640/logical-switches/ls0",
             "method":"PUT",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\",\n            \"managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='hwvtep:1']/network-topology:node[network-topology:node-id='hwvtep://{{hwvtepNodeIp}}:6640']\"             \n        }\n    ]\n}",
+            "data":"{\n  \"logical-switches\": [\n        {\n            \"hwvtep-node-name\": \"ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"tunnel-key\": \"10000\"\n         }\n    ]\n}",
             "dataMode":"raw",
             "timestamp":0,
             "version":2,
             "id":"f9f71d74-a49d-b190-d929-b6772ce0ba73",
             "name":"Get Specific Config Logical Switch",
             "description":"This restconf request fetch configuration for specific logical switch.",
-            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Flogicalswitch%2Fls0",
+            "url":"http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640/logical-switches/ls0",
             "method":"GET",
             "headers":"Authorization: Basic YWRtaW46YWRtaW4=\n",
-            "data":"{\n  \"network-topology:node\": [\n        {\n            \"node-id\": \"hwvtep://{{hwvtepNodeIp}}:6640/logicalswitch/ls0\",\n            \"hwvtep-node-description\": \"\",\n            \"hwvtep-node-name\": \"ls0\",\n            \"tunnel-key\": \"10000\"\n        }\n    ]\n}",
+            "data":[],
             "dataMode":"raw",
             "timestamp":0,
             "version":2,