Added node show support
This commit is contained in:
@@ -272,6 +272,24 @@ class Node(resource.Resource):
|
||||
tags = resource.prop('tags', type=dict)
|
||||
data = resource.prop('data', type=dict)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'name': self.name,
|
||||
'physical_id': self.physical_id,
|
||||
'cluster_id': self.cluster_id,
|
||||
'profile_id': self.profile_id,
|
||||
'index': self.index,
|
||||
'role': self.role,
|
||||
'created_time': self.created_time,
|
||||
'updated_time': self.updated_time,
|
||||
'deleted_time': self.deleted_time,
|
||||
'status': self.status,
|
||||
'status_reason': self.status_reason,
|
||||
'tags': self.tags,
|
||||
'data': self.data,
|
||||
}
|
||||
|
||||
|
||||
class Action(resource.Resource):
|
||||
resources_key = 'actions'
|
||||
|
||||
@@ -571,6 +571,25 @@ def do_node_create(sc, args):
|
||||
'node %s') % (resp['action_id'], resp['id']))
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NODE ID>',
|
||||
help=_('Name or ID of the node to show the details for.'))
|
||||
def do_node_show(sc, args):
|
||||
'''Show detailed info about the specified node.'''
|
||||
try:
|
||||
query = {'id': args.id}
|
||||
node = sc.get(models.Node, query)
|
||||
except exc.HTTPNotFound:
|
||||
msg = _('Node %(id)s is not found') % args.id
|
||||
raise exc.CommandError(msg)
|
||||
|
||||
formatters = {
|
||||
'tags': utils.json_formatter,
|
||||
'data': utils.json_formatter,
|
||||
}
|
||||
|
||||
utils.print_dict(node.to_dict(), formatters=formatters)
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NAME or ID>', nargs='+',
|
||||
help=_('Name or ID of node(s) to delete.'))
|
||||
def do_node_delete(sc, args):
|
||||
@@ -645,25 +664,6 @@ def do_node_join(sc, args):
|
||||
do_node_list(sc)
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<NODE ID>',
|
||||
help=_('Name or ID of the node to show the details for.'))
|
||||
def do_node_show(sc, args):
|
||||
'''Show detailed info about the specified node.'''
|
||||
try:
|
||||
query = {'id': args.id}
|
||||
node = sc.get(models.Node, query)
|
||||
except exc.HTTPNotFound:
|
||||
msg = _('Node %(id)s is not found') % args.id
|
||||
raise exc.CommandError(msg)
|
||||
|
||||
formatters = {
|
||||
'links': utils.link_formatter,
|
||||
'required_by': utils.newline_list_formatter
|
||||
}
|
||||
|
||||
utils.print_dict(node.to_dict(), formatters=formatters)
|
||||
|
||||
|
||||
##### EVENTS
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user