mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 14:36:00 -03:30
cli: add ability to specify a name instead of primary key
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import functools
|
||||
|
||||
from six import with_metaclass
|
||||
|
||||
from .stdout import monitor, monitor_workflow
|
||||
@@ -44,8 +46,15 @@ class CustomAction(with_metaclass(CustomActionRegistryMeta)):
|
||||
class Launchable(object):
|
||||
|
||||
def add_arguments(self, parser, with_pk=True):
|
||||
from .options import pk_or_name
|
||||
if with_pk:
|
||||
parser.choices[self.action].add_argument('id', type=int, help='')
|
||||
parser.choices[self.action].add_argument(
|
||||
'id',
|
||||
type=functools.partial(
|
||||
pk_or_name, None, self.resource, page=self.page
|
||||
),
|
||||
help=''
|
||||
)
|
||||
parser.choices[self.action].add_argument(
|
||||
'--monitor', action='store_true',
|
||||
help='If set, prints stdout of the launched job until it finishes.'
|
||||
@@ -154,7 +163,14 @@ class HasStdout(object):
|
||||
action = 'stdout'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.choices['stdout'].add_argument('id', type=int, help='')
|
||||
from .options import pk_or_name
|
||||
parser.choices['stdout'].add_argument(
|
||||
'id',
|
||||
type=functools.partial(
|
||||
pk_or_name, None, self.resource, page=self.page
|
||||
),
|
||||
help=''
|
||||
)
|
||||
|
||||
def perform(self):
|
||||
fmt = 'txt_download'
|
||||
|
||||
Reference in New Issue
Block a user