mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Add the calculated natural key to the export data for each asset
This commit is contained in:
@@ -4,7 +4,7 @@ import sys
|
|||||||
|
|
||||||
from awxkit import api, config
|
from awxkit import api, config
|
||||||
from awxkit.utils import to_str
|
from awxkit.utils import to_str
|
||||||
from awxkit.api.pages import Page, TentativePage
|
from awxkit.api.pages import Page
|
||||||
from awxkit.cli.format import FORMATTERS, format_response, add_authentication_arguments
|
from awxkit.cli.format import FORMATTERS, format_response, add_authentication_arguments
|
||||||
from awxkit.cli.utils import CustomRegistryMeta, cprint
|
from awxkit.cli.utils import CustomRegistryMeta, cprint
|
||||||
|
|
||||||
@@ -75,8 +75,8 @@ NATURAL_KEYS = {
|
|||||||
|
|
||||||
|
|
||||||
def get_natural_key(page):
|
def get_natural_key(page):
|
||||||
natural_key = {'type': page.type}
|
natural_key = {'type': page['type']}
|
||||||
lookup = NATURAL_KEYS.get(page.type, ())
|
lookup = NATURAL_KEYS.get(page['type'], ())
|
||||||
|
|
||||||
for key in lookup or ():
|
for key in lookup or ():
|
||||||
if key.startswith(':'):
|
if key.startswith(':'):
|
||||||
@@ -236,6 +236,7 @@ class Export(CustomCommand):
|
|||||||
key: asset[key] for key in options
|
key: asset[key] for key in options
|
||||||
if key in asset.json and key not in asset.related
|
if key in asset.json and key not in asset.related
|
||||||
}
|
}
|
||||||
|
fields['natural_key'] = get_natural_key(asset)
|
||||||
|
|
||||||
fk_fields = {
|
fk_fields = {
|
||||||
key: get_natural_key(asset.related[key].get()) for key in options
|
key: get_natural_key(asset.related[key].get()) for key in options
|
||||||
|
|||||||
Reference in New Issue
Block a user