mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 12:57:40 -02:30
Normalize the requested resource into a pk
using the pk_or_name helper function. Also, authenticate to the API.
This commit is contained in:
@@ -131,6 +131,14 @@ class Export(CustomCommand):
|
|||||||
resources = parser.add_argument_group('resources')
|
resources = parser.add_argument_group('resources')
|
||||||
resources.add_argument('--users', nargs='?', const='')
|
resources.add_argument('--users', nargs='?', const='')
|
||||||
|
|
||||||
|
def get_resources(self, client, resource, value):
|
||||||
|
if value:
|
||||||
|
from .options import pk_or_name
|
||||||
|
|
||||||
|
print("Pulling {}: {}".format(resource, pk_or_name(client.v2, resource, value)))
|
||||||
|
else:
|
||||||
|
print("Pulling all {}.".format(resource))
|
||||||
|
|
||||||
def handle(self, client, parser):
|
def handle(self, client, parser):
|
||||||
self.extend_parser(parser)
|
self.extend_parser(parser)
|
||||||
|
|
||||||
@@ -138,20 +146,16 @@ class Export(CustomCommand):
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
|
|
||||||
|
client.authenticate()
|
||||||
parsed = parser.parse_known_args()[0]
|
parsed = parser.parse_known_args()[0]
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
for resource in ('users',):
|
for resource in ('users',):
|
||||||
value = getattr(parsed, resource, None)
|
value = getattr(parsed, resource, None)
|
||||||
if value is None:
|
if value is None:
|
||||||
print("Pulling no users.")
|
print("Pulling no {}.".format(resource))
|
||||||
continue
|
continue
|
||||||
if value:
|
self.get_resources(client, resource, value)
|
||||||
print("Pulling users: {}".format(value))
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
print("Pulling all users.")
|
|
||||||
pass
|
|
||||||
|
|
||||||
data[resource] = {}
|
data[resource] = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user