add special code for formatting metrics and settings with -f human

see: https://github.com/ansible/awx/issues/4566
This commit is contained in:
Ryan Petrello
2019-09-03 16:56:13 -04:00
parent ba8b876dd3
commit 064f871fff
3 changed files with 49 additions and 7 deletions

View File

@@ -12,6 +12,13 @@ from .format import add_output_formatting_arguments
from .resource import DEPRECATED_RESOURCES_REVERSE
UNIQUENESS_RULES = {
'me': 'id, username',
'users': 'id, username',
'instances': 'id, hostname',
}
def pk_or_name(v2, model_name, value, page=None):
if isinstance(value, int):
return value
@@ -26,10 +33,8 @@ def pk_or_name(v2, model_name, value, page=None):
if model_name in DEPRECATED_RESOURCES_REVERSE:
model_name = DEPRECATED_RESOURCES_REVERSE[model_name]
if model_name == 'users':
identity = 'username'
elif model_name == 'instances':
model_name = 'hostname'
if model_name in UNIQUENESS_RULES:
identity = UNIQUENESS_RULES[model_name][-1]
if hasattr(v2, model_name):
page = getattr(v2, model_name)