]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
make CLI show_port command display interface-id, add additional test case
authorDan Wendlandt <dan@nicira.com>
Fri, 26 Aug 2011 20:22:18 +0000 (13:22 -0700)
committerDan Wendlandt <dan@nicira.com>
Fri, 26 Aug 2011 20:22:18 +0000 (13:22 -0700)
quantum/cli_lib.py
tests/unit/test_cli.py

index bffda703b2721cda60e966167f97ecaaf4ea9444..bfee9ac43c0bdf1fd157262480216886c4a7fded 100755 (executable)
@@ -170,8 +170,13 @@ def show_port(client, *args):
         LOG.debug("Operation 'list_port_details' executed.")
         #NOTE(salvatore-orland): current API implementation does not
         #return attachment with GET operation on port. Once API alignment
-        #branch is merged, update client to use the detail action
-        port['attachment'] = '<unavailable>'
+        #branch is merged, update client to use the detail action.
+        # (danwent) Until then, just make additonal webservice call.
+        attach = client.show_port_attachment(network_id, port_id)['attachment']
+        if "id" in attach:
+            port['attachment'] = attach['id']
+        else:
+            port['attachment'] = '<none>'
         output = prepare_output("show_port", tenant_id,
                                 dict(network_id=network_id,
                                      port=port))
index ba7838c9431976fa8ada962986531d6fdaf08cea..8fe388c6e50baec3f64bb11e1ce8a3927c763a67 100644 (file)
@@ -176,7 +176,10 @@ class CLITest(unittest.TestCase):
             # attachment in separate bug fix.
             port = db.port_get(port_id, network_id)
             port_data = {'id': port.uuid, 'state': port.state,
-                         'attachment': '<unavailable>'}
+                         'attachment': "<none>"}
+            if port.interface_id is not None:
+                port_data['attachment'] = port.interface_id
+
             # Fill CLI template
             output = cli.prepare_output('show_port', self.tenant_id,
                                         dict(network_id=network_id,
@@ -340,19 +343,39 @@ class CLITest(unittest.TestCase):
         LOG.debug(self.fake_stdout.content)
         self._verify_set_port_state(network_id, port_id)
 
-    def test_show_port(self):
+    def test_show_port_no_attach(self):
+        network_id = None
+        port_id = None
+        try:
+            # Pre-populate data for testing using db api
+            net = db.network_create(self.tenant_id, self.network_name_1)
+            network_id = net['uuid']
+            port = db.port_create(network_id)
+            port_id = port['uuid']
+            cli.show_port(self.client, self.tenant_id, network_id, port_id)
+        except:
+            LOG.exception("Exception caught: %s", sys.exc_info())
+            self.fail("test_show_port_no_attach failed due to an exception")
+
+        LOG.debug("Operation completed. Verifying result")
+        LOG.debug(self.fake_stdout.content)
+        self._verify_show_port(network_id, port_id)
+
+    def test_show_port_with_attach(self):
         network_id = None
         port_id = None
+        iface_id = "flavor crystals"
         try:
             # Pre-populate data for testing using db api
             net = db.network_create(self.tenant_id, self.network_name_1)
             network_id = net['uuid']
             port = db.port_create(network_id)
             port_id = port['uuid']
+            db.port_set_attachment(port_id, network_id, iface_id)
             cli.show_port(self.client, self.tenant_id, network_id, port_id)
         except:
             LOG.exception("Exception caught: %s", sys.exc_info())
-            self.fail("test_detail_port failed due to an exception")
+            self.fail("test_show_port_with_attach failed due to an exception")
 
         LOG.debug("Operation completed. Verifying result")
         LOG.debug(self.fake_stdout.content)