make CLI show_port command display interface-id, add additional test case

This commit is contained in:
Dan Wendlandt 2011-08-26 13:22:18 -07:00
parent 61ad18c3f2
commit fa4e2c4c7d
2 changed files with 33 additions and 5 deletions

View File

@ -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))

View 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,7 +343,7 @@ 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:
@ -352,7 +355,27 @@ class CLITest(unittest.TestCase):
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_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_show_port_with_attach failed due to an exception")
LOG.debug("Operation completed. Verifying result")
LOG.debug(self.fake_stdout.content)