Add a new cmd method node-get-vendor-passthru-methods
This method will return vendor-passthru-methods for the node. Change-Id: I1c5b18e2102ef355d0619be3c87771dafb7733ae Partial-Bug: #1507546
This commit is contained in:
parent
1073a5469b
commit
cd3cd7e791
@ -72,6 +72,11 @@ CONSOLE_ENABLE = 'true'
|
||||
BOOT_DEVICE = {'boot_device': 'pxe', 'persistent': False}
|
||||
SUPPORTED_BOOT_DEVICE = {'supported_boot_devices': ['pxe']}
|
||||
|
||||
NODE_VENDOR_PASSTHRU_METHOD = {"heartbeat": {"attach": "false",
|
||||
"http_methods": ["POST"],
|
||||
"description": "",
|
||||
"async": "true"}}
|
||||
|
||||
CREATE_NODE = copy.deepcopy(NODE1)
|
||||
del CREATE_NODE['id']
|
||||
del CREATE_NODE['uuid']
|
||||
@ -294,6 +299,13 @@ fake_responses = {
|
||||
SUPPORTED_BOOT_DEVICE,
|
||||
),
|
||||
},
|
||||
'/v1/nodes/%s/vendor_passthru/methods' % NODE1['uuid']:
|
||||
{
|
||||
'GET': (
|
||||
{},
|
||||
NODE_VENDOR_PASSTHRU_METHOD,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
fake_responses_pagination = {
|
||||
@ -931,3 +943,12 @@ class NodeManagerTest(testtools.TestCase):
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(SUPPORTED_BOOT_DEVICE, boot_device)
|
||||
|
||||
def test_node_get_vendor_passthru_methods(self):
|
||||
vendor_methods = self.mgr.get_vendor_passthru_methods(NODE1['uuid'])
|
||||
expect = [
|
||||
('GET', '/v1/nodes/%s/vendor_passthru/methods' % NODE1['uuid'],
|
||||
{}, None)
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertEqual(NODE_VENDOR_PASSTHRU_METHOD, vendor_methods)
|
||||
|
@ -789,3 +789,11 @@ class NodeShellTest(utils.BaseTestCase):
|
||||
fields=[['foo', 'bar']])
|
||||
self.assertRaises(exceptions.CommandError,
|
||||
n_shell.do_node_port_list, client_mock, args)
|
||||
|
||||
def test_do_node_get_vendor_passthru_methods(self):
|
||||
client_mock = mock.MagicMock()
|
||||
args = mock.MagicMock()
|
||||
args.node = 'node_uuid'
|
||||
n_shell.do_node_get_vendor_passthru_methods(client_mock, args)
|
||||
client_mock.node.get_vendor_passthru_methods.assert_called_once_with(
|
||||
'node_uuid')
|
||||
|
@ -323,3 +323,7 @@ class NodeManager(base.Manager):
|
||||
def get_supported_boot_devices(self, node_uuid):
|
||||
path = "%s/management/boot_device/supported" % node_uuid
|
||||
return self.get(path).to_dict()
|
||||
|
||||
def get_vendor_passthru_methods(self, node_ident):
|
||||
path = "%s/vendor_passthru/methods" % node_ident
|
||||
return self.get(path).to_dict()
|
||||
|
@ -472,3 +472,20 @@ def do_node_show_states(cc, args):
|
||||
"""Show information about the node's states."""
|
||||
states = cc.node.states(args.node)
|
||||
cliutils.print_dict(states.to_dict(), wrap=72)
|
||||
|
||||
|
||||
@cliutils.arg('node', metavar='<node>', help="Name or UUID of the node.")
|
||||
def do_node_get_vendor_passthru_methods(cc, args):
|
||||
"""Get the vendor passthru methods for a node."""
|
||||
methods = cc.node.get_vendor_passthru_methods(args.node)
|
||||
data = []
|
||||
for method, response in methods.items():
|
||||
response['name'] = method
|
||||
http_methods = ','.join(response['http_methods'])
|
||||
response['http_methods'] = http_methods
|
||||
data.append(response)
|
||||
fields = res_fields.VENDOR_PASSTHRU_METHOD_RESOURCE.fields
|
||||
field_labels = res_fields.VENDOR_PASSTHRU_METHOD_RESOURCE.labels
|
||||
cliutils.print_list(data, fields,
|
||||
field_labels=field_labels,
|
||||
sortby_index=None)
|
||||
|
@ -32,6 +32,8 @@ class Resource(object):
|
||||
|
||||
FIELDS = {
|
||||
'address': 'Address',
|
||||
'async': 'Async',
|
||||
'attach': 'Response is attachment',
|
||||
'chassis_uuid': 'Chassis UUID',
|
||||
'clean_step': 'Clean Step',
|
||||
'console_enabled': 'Console Enabled',
|
||||
@ -41,6 +43,7 @@ class Resource(object):
|
||||
'driver_info': 'Driver Info',
|
||||
'driver_internal_info': 'Driver Internal Info',
|
||||
'extra': 'Extra',
|
||||
'http_methods': 'Supported HTTP methods',
|
||||
'inspection_finished_at': 'Inspection Finished At',
|
||||
'inspection_started_at': 'Inspection Started At',
|
||||
'instance_info': 'Instance Info',
|
||||
@ -165,6 +168,13 @@ NODE_RESOURCE = Resource(
|
||||
'provision_state',
|
||||
'maintenance',
|
||||
])
|
||||
VENDOR_PASSTHRU_METHOD_RESOURCE = Resource(
|
||||
['name',
|
||||
'http_methods',
|
||||
'async',
|
||||
'description',
|
||||
'attach'
|
||||
])
|
||||
|
||||
# Ports
|
||||
PORT_DETAILED_RESOURCE = Resource(
|
||||
|
Loading…
x
Reference in New Issue
Block a user