Add chassis-node-list
List the nodes contained on a specific chassis. Change-Id: I7e0a46dd202b765c653b3e44dac1d878c8871ea9
This commit is contained in:
parent
a3872e8e36
commit
4dba2c95cb
@ -28,6 +28,14 @@ CHASSIS = {'id': 42,
|
||||
'extra': {},
|
||||
'description': 'data-center-1-chassis'}
|
||||
|
||||
NODE = {'id': 123,
|
||||
'uuid': '66666666-7777-8888-9999-000000000000',
|
||||
'chassis_id': 42,
|
||||
'driver': 'fake',
|
||||
'driver_info': {'user': 'foo', 'password': 'bar'},
|
||||
'properties': {'num_cpu': 4},
|
||||
'extra': {}}
|
||||
|
||||
CREATE_CHASSIS = copy.deepcopy(CHASSIS)
|
||||
del CREATE_CHASSIS['id']
|
||||
del CREATE_CHASSIS['uuid']
|
||||
@ -62,7 +70,13 @@ fixtures = {
|
||||
{},
|
||||
UPDATED_CHASSIS,
|
||||
),
|
||||
|
||||
},
|
||||
'/v1/chassis/%s/nodes' % CHASSIS['uuid']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
{"nodes": [NODE]},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
@ -117,3 +131,12 @@ class ChassisManagerTest(testtools.TestCase):
|
||||
]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
self.assertEqual(chassis.description, NEW_DESCR)
|
||||
|
||||
def test_chassis_node_list(self):
|
||||
nodes = self.mgr.list_nodes(CHASSIS['uuid'])
|
||||
expect = [
|
||||
('GET', '/v1/chassis/%s/nodes' % CHASSIS['uuid'], {}, None),
|
||||
]
|
||||
self.assertEqual(self.api.calls, expect)
|
||||
self.assertEqual(len(nodes), 1)
|
||||
self.assertEqual(nodes[0].uuid, NODE['uuid'])
|
||||
|
@ -36,6 +36,10 @@ class ChassisManager(base.Manager):
|
||||
def list(self):
|
||||
return self._list(self._path(), "chassis")
|
||||
|
||||
def list_nodes(self, chassis_id):
|
||||
path = "%s/nodes" % chassis_id
|
||||
return self._list(self._path(path), "nodes")
|
||||
|
||||
def get(self, chassis_id):
|
||||
try:
|
||||
return self._list(self._path(chassis_id))[0]
|
||||
|
@ -102,3 +102,16 @@ def do_chassis_update(cc, args):
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError('Chassis not found: %s' % args.chassis)
|
||||
_print_chassis_show(chassis)
|
||||
|
||||
|
||||
@utils.arg('chassis', metavar='<chassis id>', help="ID of chassis")
|
||||
def do_chassis_node_list(cc, args):
|
||||
"""List the nodes contained in the chassis."""
|
||||
try:
|
||||
nodes = cc.chassis.list_nodes(args.chassis)
|
||||
except exc.HTTPNotFound:
|
||||
raise exc.CommandError(_('Chassis not found: %s') % args.chassis)
|
||||
field_labels = ['UUID', 'Instance UUID',
|
||||
'Power State', 'Provisioning State']
|
||||
fields = ['uuid', 'instance_uuid', 'power_state', 'provision_state']
|
||||
utils.print_list(nodes, fields, field_labels, sortby=1)
|
||||
|
Loading…
Reference in New Issue
Block a user