1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Add execution node information

This commit is contained in:
Matthew Jones 2016-10-20 13:24:12 -04:00
parent e8669b0cbf
commit b906469b40
3 changed files with 11 additions and 9 deletions

View File

@ -562,7 +562,7 @@ class UnifiedJobSerializer(BaseSerializer):
fields = ('*', 'unified_job_template', 'launch_type', 'status', fields = ('*', 'unified_job_template', 'launch_type', 'status',
'failed', 'started', 'finished', 'elapsed', 'job_args', 'failed', 'started', 'finished', 'elapsed', 'job_args',
'job_cwd', 'job_env', 'job_explanation', 'result_stdout', 'job_cwd', 'job_env', 'job_explanation', 'result_stdout',
'result_traceback') 'execution_node', 'result_traceback')
extra_kwargs = { extra_kwargs = {
'unified_job_template': { 'unified_job_template': {
'source': 'unified_job_template_id', 'source': 'unified_job_template_id',

View File

@ -31,13 +31,10 @@ class InstanceManager(models.Manager):
hostname='localhost', hostname='localhost',
uuid='00000000-0000-0000-0000-000000000000') uuid='00000000-0000-0000-0000-000000000000')
# If we can determine the instance we are on then return node = self.filter(hostname=settings.CLUSTER_HOST_ID)
# that, otherwise None which would be the standalone if node.exists():
# case return node[0]
# TODO: Replace, this doesn't work if the hostname raise RuntimeError("No instance found with the current cluster host id")
# is different from the Instance.name
# node = self.filter(hostname=socket.gethostname())
return self.all()[0]
def my_role(self): def my_role(self):
# NOTE: TODO: Likely to repurpose this once standalone ramparts are a thing # NOTE: TODO: Likely to repurpose this once standalone ramparts are a thing

View File

@ -438,6 +438,11 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
editable=False, editable=False,
related_name='%(class)s_blocked_jobs+', related_name='%(class)s_blocked_jobs+',
) )
execution_node = models.TextField(
blank=True,
default='',
editable=False,
)
notifications = models.ManyToManyField( notifications = models.ManyToManyField(
'Notification', 'Notification',
editable=False, editable=False,
@ -801,7 +806,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
def pre_start(self, **kwargs): def pre_start(self, **kwargs):
if not self.can_start: if not self.can_start:
self.job_explanation = u'%s is not in a startable status: %s, expecting one of %s' % (self._meta.verbose_name, self.status, str(('new', 'waiting'))) self.job_explanation = u'%s is not in a startable state: %s, expecting one of %s' % (self._meta.verbose_name, self.status, str(('new', 'waiting')))
self.save(update_fields=['job_explanation']) self.save(update_fields=['job_explanation'])
return (False, None) return (False, None)