Correct node-port-list help info
node-port-list accecpts node_name but help say it only accecpt node_uuid. Correct it and add related tests. Change-Id: I37f7d505e249156e6a428c3b8d2648b43fcc3df4
This commit is contained in:
parent
1ced89b9e9
commit
f89739bed7
@ -205,6 +205,13 @@ fake_responses = {
|
||||
{"ports": [PORT]},
|
||||
),
|
||||
},
|
||||
'/v1/nodes/%s/ports' % NODE1['name']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"ports": [PORT]},
|
||||
),
|
||||
},
|
||||
'/v1/nodes/%s/ports/detail' % NODE1['uuid']:
|
||||
{
|
||||
'GET': (
|
||||
@ -212,6 +219,13 @@ fake_responses = {
|
||||
{"ports": [PORT]},
|
||||
),
|
||||
},
|
||||
'/v1/nodes/%s/ports/detail' % NODE1['name']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"ports": [PORT]},
|
||||
),
|
||||
},
|
||||
'/v1/nodes/%s/ports?fields=uuid,address' % NODE1['uuid']:
|
||||
{
|
||||
'GET': (
|
||||
@ -603,13 +617,23 @@ class NodeManagerTest(testtools.TestCase):
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(NEW_DRIVER, node.driver)
|
||||
|
||||
def test_node_port_list(self):
|
||||
def test_node_port_list_with_uuid(self):
|
||||
ports = self.mgr.list_ports(NODE1['uuid'])
|
||||
expect = [
|
||||
('GET', '/v1/nodes/%s/ports' % NODE1['uuid'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(1, len(ports))
|
||||
self.assertThat(ports, HasLength(1))
|
||||
self.assertEqual(PORT['uuid'], ports[0].uuid)
|
||||
self.assertEqual(PORT['address'], ports[0].address)
|
||||
|
||||
def test_node_port_list_with_name(self):
|
||||
ports = self.mgr.list_ports(NODE1['name'])
|
||||
expect = [
|
||||
('GET', '/v1/nodes/%s/ports' % NODE1['name'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(ports, HasLength(1))
|
||||
self.assertEqual(PORT['uuid'], ports[0].uuid)
|
||||
self.assertEqual(PORT['address'], ports[0].address)
|
||||
|
||||
@ -662,13 +686,21 @@ class NodeManagerTest(testtools.TestCase):
|
||||
self.assertEqual(PORT['uuid'], ports[0].uuid)
|
||||
self.assertEqual(PORT['address'], ports[0].address)
|
||||
|
||||
def test_node_port_list_detail(self):
|
||||
def test_node_port_list_detail_with_uuid(self):
|
||||
ports = self.mgr.list_ports(NODE1['uuid'], detail=True)
|
||||
expect = [
|
||||
('GET', '/v1/nodes/%s/ports/detail' % NODE1['uuid'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(1, len(ports))
|
||||
self.assertThat(ports, HasLength(1))
|
||||
|
||||
def test_node_port_list_detail_with_name(self):
|
||||
ports = self.mgr.list_ports(NODE1['name'], detail=True)
|
||||
expect = [
|
||||
('GET', '/v1/nodes/%s/ports/detail' % NODE1['name'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertThat(ports, HasLength(1))
|
||||
|
||||
def test_node_port_list_fields(self):
|
||||
ports = self.mgr.list_ports(NODE1['uuid'], fields=['uuid', 'address'])
|
||||
@ -677,7 +709,7 @@ class NodeManagerTest(testtools.TestCase):
|
||||
NODE1['uuid'], {}, None),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(1, len(ports))
|
||||
self.assertThat(ports, HasLength(1))
|
||||
|
||||
def test_node_port_list_detail_and_fields_fail(self):
|
||||
self.assertRaises(exc.InvalidAttribute, self.mgr.list_ports,
|
||||
|
@ -112,7 +112,7 @@ class NodeManager(base.Manager):
|
||||
sort_dir=None, detail=False, fields=None):
|
||||
"""List all the ports for a given node.
|
||||
|
||||
:param node_id: The UUID of the node.
|
||||
:param node_id: Name or UUID of the node.
|
||||
:param marker: Optional, the UUID of a port, eg the last
|
||||
port from a previous result set. Return
|
||||
the next result set.
|
||||
|
@ -309,7 +309,7 @@ def do_node_vendor_passthru(cc, args):
|
||||
metavar='<direction>',
|
||||
choices=['asc', 'desc'],
|
||||
help='Sort direction: "asc" (the default) or "desc".')
|
||||
@cliutils.arg('node', metavar='<node>', help="UUID of the node.")
|
||||
@cliutils.arg('node', metavar='<node>', help="Name or UUID of the node.")
|
||||
@cliutils.arg(
|
||||
'--fields',
|
||||
nargs='+',
|
||||
|
Loading…
x
Reference in New Issue
Block a user