mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
Merge pull request #4648 from ryanpetrello/format-metrics-human
cli: add special code for formatting metrics and settings with -f human Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -13,6 +13,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
|
||||
@@ -27,10 +34,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)
|
||||
|
||||
Reference in New Issue
Block a user