Integrate md-sal port model and add more port E2E tests 77/24177/1
authorRyan Moats <rmoats@us.ibm.com>
Wed, 15 Jul 2015 23:39:34 +0000 (18:39 -0500)
committerRyan Moats <rmoats@us.ibm.com>
Wed, 15 Jul 2015 23:39:34 +0000 (18:39 -0500)
Again, this change is *NOT* a candidate for stable/lithium as
it changes both the sematics of port update *and* it changes
the device-id portion of the yang model from uuid to flat
string.

Change-Id: Ic95d5c4e3125bcd31aecc48f13e8a2e0a2b2720f
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/ITNeutronE2E.java
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronPortTests.java
model/src/main/yang/neutron-ports.yang
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronPortInterface.java

index e5b77539b66bb4954007ef34572eb42a0ee9e37b..6bdb5d0fe6497f6ffa0bbab23d3ecfc087b4c544 100644 (file)
@@ -109,6 +109,11 @@ public class ITNeutronE2E {
         port_tester.port_collection_get_test();
         port_tester.singleton_port_create_test();
         port_tester.router_interface_port_create_test(); //needed for router test
+        port_tester.bulk_port_create_test();
+        port_tester.port_update_test();
+        port_tester.port_element_get_test();
+        port_tester.port_delete_test();
+        port_tester.port_element_negative_get_test();
 
         NeutronRouterTests router_tester = new NeutronRouterTests(base);
         router_tester.router_collection_get_test();
index 453a299632352184b7d507375c41dfe84df64b76..c526b2a6552e0e1a1b605105359f4f6c5f3539fd 100644 (file)
@@ -49,7 +49,7 @@ public class NeutronPortTests {
                 "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","+
                 "\"ip_address\": \"10.0.0.2\" } ],"+
             "\"id\": \"65c0ee9f-d634-4522-8954-51021b570b0d\","+
-            "\"security_groups\": [ \"f0ac4394-7e4a-4409-9701-ba8be283dbc3\" ],"+
+            "\"security_groups\": [,"+
             "\"device_id\": \"\" } }";
         ITNeutronE2E.test_create(url, content,"Singleton Port Post Failed NB");
     }
@@ -60,4 +60,79 @@ public class NeutronPortTests {
         String content = "{\"port\": {\"status\": \"DOWN\", \"binding:host_id\": \"\", \"allowed_address_pairs\": [], \"device_owner\": \"network:router_gateway\", \"binding:profile\": {}, \"fixed_ips\": [{\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\", \"ip_address\": \"10.0.0.1\"}], \"id\": \"d8a4cc85-ad78-46ac-b5a1-8e04f16fa51e\", \"security_groups\": [], \"device_id\": \"8604a0de-7f6b-409a-a47c-a1cc7bc77b2e\", \"name\": \"\", \"admin_state_up\": true, \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", \"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", \"binding:vif_details\": {}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"unbound\", \"mac_address\": \"fa:16:3e:dc:1d:8d\"}}";
         ITNeutronE2E.test_create(url, content, "Router Interface Port Post Failed NB");
     }
+
+    public void bulk_port_create_test() {
+        String url = base + "/ports";
+        String content = "{ \"ports\": [ { "
+            + " \"status\": \"DOWN\", "
+            + " \"name\": \"sample_port_1\", "
+            + " \"allowed_address_pairs\": [], "
+            + " \"admin_state_up\": false, "
+            + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+            + " \"tenant_id\": \"d6700c0c9ffa4f1cb322cd4a1f3906fa\", "
+            + " \"device_owner\": \"\", "
+            + " \"mac_address\": \"fa:16:3e:48:b8:9f\", "
+            + " \"fixed_ips\": [ { "
+            + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+            + " \"ip_address\": \"10.0.0.5\" } ], "
+            + " \"id\": \"94225baa-9d3f-4b93-bf12-b41e7ce49cdb\", "
+            + " \"security_groups\": [], "
+            + " \"device_id\": \"\" }, { "
+            + " \"status\": \"DOWN\", "
+            + " \"name\": \"sample_port_2\", "
+            + " \"allowed_address_pairs\": [], "
+            + " \"admin_state_up\": false, "
+            + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+            + " \"tenant_id\": \"d6700c0c9ffa4f1cb322cd4a1f3906fa\", "
+            + " \"device_owner\": \"\", "
+            + " \"mac_address\": \"fa:16:3e:f4:73:df\", "
+            + " \"fixed_ips\": [ { "
+            + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+            + " \"ip_address\": \"10.0.0.6\" } ], "
+            + " \"id\": \"43c831e0-19ce-4a76-9a49-57b57e69428b\", "
+            + " \"security_groups\": [], "
+            + " \"device_id\": \"\" } ] } ";
+        ITNeutronE2E.test_create(url, content, "Bulk Subnet Post Failed");
+    }
+
+    public void port_update_test() {
+        String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+        String content = " { \"port\": { "
+        + " \"status\": \"DOWN\", "
+        + " \"binding:host_id\": \"test_for_port_update_host\", "
+        + " \"allowed_address_pairs\": [], "
+        + " \"extra_dhcp_opts\": [], "
+        + " \"device_owner\": \"compute:nova\", "
+        + " \"binding:profile\": {}, "
+        + " \"fixed_ips\": [ { "
+        + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+        + " \"ip_address\": \"10.0.0.7\" } ], "
+        + " \"id\": \"43c831e0-19ce-4a76-9a49-57b57e69428b\", "
+        + " \"security_groups\": [], "
+        + " \"device_id\": \"\", "
+        + " \"name\": \"test-for-port-update\", "
+        + " \"admin_state_up\": true, "
+        + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+        + " \"tenant_id\": \"522eda8d23124b25bf03fe44f1986b74\", "
+        + " \"binding:vif_details\": {}, "
+        + " \"binding:vnic_type\": \"normal\", "
+        + " \"binding:vif_type\": \"binding_failed\", "
+        + " \"mac_address\": \"fa:16:3e:11:11:5e\" } } ";
+        ITNeutronE2E.test_modify(url, content,"Subnet Put Failed");
+    }
+
+    public void port_element_get_test() {
+        String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+        ITNeutronE2E.test_fetch(url, true, "Subnet Element Get Failed");
+    }
+
+    public void port_delete_test() {
+        String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+        ITNeutronE2E.test_delete(url, "Subnet Element Delete Failed");
+    }
+
+    public void port_element_negative_get_test() {
+        String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+        ITNeutronE2E.test_fetch(url, false, "Subnet Element Get Failed");
+    }
 }
index d400a1b4f42e9edcfd05cfb1b38af717156c68da..3b27fec04460ea03a7db728c4b571863a8296db4 100644 (file)
@@ -93,7 +93,7 @@ module neutron-ports {
             type yang:uuid;
         }
         leaf device-id {
-            type yang:uuid;
+            type string;
         }
     }
 
index fe23680aeac47376b034b03e7505443aaeef7b52..ca93048304b736984694928ade0d9b79874e72f8 100644 (file)
@@ -433,31 +433,30 @@ public class NeutronPortsNorthbound {
             ) {
         NeutronCRUDInterfaces interfaces = getNeutronInterfaces(false, true);
         INeutronPortCRUD portInterface = interfaces.getPortInterface();
-        INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface();
-
         // port has to exist and only a single delta is supported
         if (!portInterface.portExists(portUUID)) {
             throw new ResourceNotFoundException(UUID_NO_EXIST);
         }
-        NeutronPort target = portInterface.getPort(portUUID);
+        NeutronPort original = portInterface.getPort(portUUID);
         if (!input.isSingleton()) {
             throw new BadRequestException("only singleton edit suported");
         }
-        NeutronPort singleton = input.getSingleton();
-        NeutronPort original = portInterface.getPort(portUUID);
 
-        // deltas restricted by Neutron
-        if (singleton.getID() != null || singleton.getTenantID() != null ||
-                singleton.getStatus() != null) {
-            throw new BadRequestException("attribute change blocked by Neutron");
-        }
+        /*
+         * note: what we get appears to not be a delta, but rather a possibly
+         * complete updated object.  So, that needs to be sent down to
+         * folks to check 
+         */
+
+        NeutronPort updatedObject = input.getSingleton();
+        updatedObject.setID(portUUID);
 
         Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
         if (instances != null) {
             if (instances.length > 0) {
                 for (Object instance : instances) {
                     INeutronPortAware service = (INeutronPortAware) instance;
-                    int status = service.canUpdatePort(singleton, original);
+                    int status = service.canUpdatePort(updatedObject, original);
                     if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
                         return Response.status(status).build();
                     }
@@ -469,45 +468,17 @@ public class NeutronPortsNorthbound {
             throw new ServiceUnavailableException(NO_PROVIDER_LIST);
         }
 
-        // Verify the new fixed ips are valid
-        List<Neutron_IPs> fixedIPs = singleton.getFixedIPs();
-        if (fixedIPs != null && fixedIPs.size() > 0) {
-            Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
-            while (fixedIPIterator.hasNext()) {
-                Neutron_IPs ip = fixedIPIterator.next();
-                if (ip.getSubnetUUID() == null) {
-                    throw new BadRequestException("subnet UUID must be specified");
-                }
-                if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
-                    throw new BadRequestException("subnet UUID doesn't exist.");
-                }
-                NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
-                if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
-                    throw new BadRequestException(NET_UUID_MATCH);
-                }
-                if (ip.getIpAddress() != null) {
-                    if (!subnet.isValidIP(ip.getIpAddress())) {
-                        throw new BadRequestException("invalid IP address");
-                    }
-                    if (subnet.isIPInUse(ip.getIpAddress())) {
-                        throw new ResourceConflictException("IP address in use");
-                    }
-                }
-            }
-        }
-
         //        TODO: Support change of security groups
         // update the port and return the modified object
-        portInterface.updatePort(portUUID, singleton);
-        NeutronPort updatedPort = portInterface.getPort(portUUID);
+        portInterface.updatePort(portUUID, updatedObject);
         if (instances != null) {
             for (Object instance : instances) {
                 INeutronPortAware service = (INeutronPortAware) instance;
-                service.neutronPortUpdated(updatedPort);
+                service.neutronPortUpdated(updatedObject);
             }
         }
         return Response.status(HttpURLConnection.HTTP_OK).entity(
-                new NeutronPortRequest(updatedPort)).build();
+                new NeutronPortRequest(updatedObject)).build();
 
     }
 
index 0bad069f6a4eb806094cf762b47824db95bebc68..8050401707b8f026d0e0d04451712edab038e1ab 100644 (file)
@@ -232,7 +232,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             portBuilder.setBindingProfile(neutronPort.getBindinghostID());
         }
         if (neutronPort.getDeviceID() != null) {
-            portBuilder.setDeviceId(toUuid(neutronPort.getDeviceID()));
+            portBuilder.setDeviceId(neutronPort.getDeviceID());
         }
         if (neutronPort.getDeviceOwner() != null) {
         portBuilder.setDeviceOwner(neutronPort.getDeviceOwner());