teach 'ara host facts' how to show only specific facts
(cherry picked from commit e3e0f070da3a53c0f038f16c7de142d6a6a3442c)
This commit is contained in:
committed by
David Moreau-Simard
parent
a4597dcf23
commit
3e5d1701a7
@@ -66,10 +66,10 @@ class HostShow(ShowOne):
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
def take_action(self, args):
|
||||
host = (models.Host.query
|
||||
.filter((models.Host.id == parsed_args.host) |
|
||||
(models.Host.name == parsed_args.host)).one())
|
||||
.filter((models.Host.id == args.host) |
|
||||
(models.Host.name == args.host)).one())
|
||||
|
||||
return utils.fields_from_object(FIELDS, host)
|
||||
|
||||
@@ -85,12 +85,21 @@ class HostFacts(ShowOne):
|
||||
metavar='<host>',
|
||||
help='Host name or id to show facts for',
|
||||
)
|
||||
parser.add_argument(
|
||||
'fact',
|
||||
nargs='*',
|
||||
metavar='<fact>',
|
||||
help='Show only named fact(s)',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
def take_action(self, args):
|
||||
host = (models.Host.query
|
||||
.filter((models.Host.id == parsed_args.host) |
|
||||
(models.Host.name == parsed_args.host)).one())
|
||||
.filter((models.Host.id == args.host) |
|
||||
(models.Host.name == args.host)).one())
|
||||
|
||||
facts = json.loads(host.facts.values)
|
||||
return zip(*sorted(six.iteritems(facts)))
|
||||
facts = ((k, v) for k, v in
|
||||
six.iteritems(json.loads(host.facts.values))
|
||||
if not args.fact or k in args.fact
|
||||
)
|
||||
return zip(*sorted(facts))
|
||||
|
||||
Reference in New Issue
Block a user