mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-20 07:43:35 -05:00
Altering --timeout from awxkit to --action-timeout to remove conflict with new launch timeout
This commit is contained in:
committed by
Alan Rominger
parent
d07177be9c
commit
75597cf29c
@@ -50,7 +50,7 @@ class Launchable(object):
|
|||||||
if with_pk:
|
if with_pk:
|
||||||
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('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.')
|
parser.choices[self.action].add_argument('--monitor', action='store_true', help='If set, prints stdout of the launched job until it finishes.')
|
||||||
parser.choices[self.action].add_argument('--timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.') # noqa
|
parser.choices[self.action].add_argument('--action-timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.')
|
||||||
parser.choices[self.action].add_argument('--wait', action='store_true', help='If set, waits until the launched job finishes.')
|
parser.choices[self.action].add_argument('--wait', action='store_true', help='If set, waits until the launched job finishes.')
|
||||||
|
|
||||||
launch_time_options = self.page.connection.options(self.page.endpoint + '1/{}/'.format(self.action))
|
launch_time_options = self.page.connection.options(self.page.endpoint + '1/{}/'.format(self.action))
|
||||||
@@ -66,7 +66,7 @@ class Launchable(object):
|
|||||||
response,
|
response,
|
||||||
self.page.connection.session,
|
self.page.connection.session,
|
||||||
print_stdout=not kwargs.get('wait'),
|
print_stdout=not kwargs.get('wait'),
|
||||||
timeout=kwargs.get('timeout'),
|
action_timeout=kwargs.get('action_timeout'),
|
||||||
)
|
)
|
||||||
if status:
|
if status:
|
||||||
response.json['status'] = status
|
response.json['status'] = status
|
||||||
@@ -78,7 +78,7 @@ class Launchable(object):
|
|||||||
monitor_kwargs = {
|
monitor_kwargs = {
|
||||||
'monitor': kwargs.pop('monitor', False),
|
'monitor': kwargs.pop('monitor', False),
|
||||||
'wait': kwargs.pop('wait', False),
|
'wait': kwargs.pop('wait', False),
|
||||||
'timeout': kwargs.pop('timeout', False),
|
'action_timeout': kwargs.pop('action_timeout', False),
|
||||||
}
|
}
|
||||||
response = self.page.get().related.get(self.action).post(kwargs)
|
response = self.page.get().related.get(self.action).post(kwargs)
|
||||||
self.monitor(response, **monitor_kwargs)
|
self.monitor(response, **monitor_kwargs)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from .utils import cprint, color_enabled, STATUS_COLORS
|
|||||||
from awxkit.utils import to_str
|
from awxkit.utils import to_str
|
||||||
|
|
||||||
|
|
||||||
def monitor_workflow(response, session, print_stdout=True, timeout=None, interval=0.25):
|
def monitor_workflow(response, session, print_stdout=True, action_timeout=None, interval=0.25):
|
||||||
get = response.url.get
|
get = response.url.get
|
||||||
payload = {
|
payload = {
|
||||||
'order_by': 'finished',
|
'order_by': 'finished',
|
||||||
@@ -46,7 +46,7 @@ def monitor_workflow(response, session, print_stdout=True, timeout=None, interva
|
|||||||
started = time.time()
|
started = time.time()
|
||||||
seen = set()
|
seen = set()
|
||||||
while True:
|
while True:
|
||||||
if timeout and time.time() - started > timeout:
|
if action_timeout and time.time() - started > action_timeout:
|
||||||
if print_stdout:
|
if print_stdout:
|
||||||
cprint('Monitoring aborted due to timeout.', 'red')
|
cprint('Monitoring aborted due to timeout.', 'red')
|
||||||
break
|
break
|
||||||
@@ -68,7 +68,7 @@ def monitor_workflow(response, session, print_stdout=True, timeout=None, interva
|
|||||||
return get().json.status
|
return get().json.status
|
||||||
|
|
||||||
|
|
||||||
def monitor(response, session, print_stdout=True, timeout=None, interval=0.25):
|
def monitor(response, session, print_stdout=True, action_timeout=None, interval=0.25):
|
||||||
get = response.url.get
|
get = response.url.get
|
||||||
payload = {'order_by': 'start_line', 'no_truncate': True}
|
payload = {'order_by': 'start_line', 'no_truncate': True}
|
||||||
if response.type == 'job':
|
if response.type == 'job':
|
||||||
@@ -97,7 +97,7 @@ def monitor(response, session, print_stdout=True, timeout=None, interval=0.25):
|
|||||||
|
|
||||||
started = time.time()
|
started = time.time()
|
||||||
while True:
|
while True:
|
||||||
if timeout and time.time() - started > timeout:
|
if action_timeout and time.time() - started > action_timeout:
|
||||||
if print_stdout:
|
if print_stdout:
|
||||||
cprint('Monitoring aborted due to timeout.', 'red')
|
cprint('Monitoring aborted due to timeout.', 'red')
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user