From: Dan Wendlandt Date: Fri, 26 Aug 2011 20:22:18 +0000 (-0700) Subject: make CLI show_port command display interface-id, add additional test case X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=fa4e2c4c7d2ad62f9827345046cb9628a13f1458;p=openstack-build%2Fneutron-build.git make CLI show_port command display interface-id, add additional test case --- diff --git a/quantum/cli_lib.py b/quantum/cli_lib.py index bffda703b..bfee9ac43 100755 --- a/quantum/cli_lib.py +++ b/quantum/cli_lib.py @@ -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'] = '' + #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'] = '' output = prepare_output("show_port", tenant_id, dict(network_id=network_id, port=port)) diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index ba7838c94..8fe388c6e 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -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': ''} + 'attachment': ""} + 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)