mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 11:08:13 -03:30
* Add a local node queue to execute targeted jobs * Add a setting for active cluster node id (per-node) * Base the heartbeat time on the `modified` time on the Instance table * Add periodic task that calls save() on the instance to update the heartbeat time if services are up * Purge/update any ha/instance management commands * Fix up CELERY_ROUTES settings data structure
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# Copyright (c) 2015 Ansible, Inc.
|
|
# All Rights Reserved
|
|
|
|
from awx.main.models import Instance
|
|
from django.conf import settings
|
|
|
|
from django.core.management.base import CommandError, NoArgsCommand
|
|
|
|
class Command(NoArgsCommand):
|
|
"""
|
|
Internal tower command.
|
|
Regsiter this instance with the database for HA tracking.
|
|
"""
|
|
|
|
option_list = NoArgsCommand.option_list + (
|
|
make_option('--hostname', dest='hostname', type='string',
|
|
help='Hostname used during provisioning')
|
|
)
|
|
|
|
def handle(self, *args, **options):
|
|
super(Command, self).handle(**options)
|
|
uuid = settings.SYSTEM_UUID
|
|
|
|
instance = Instance.objects.filter(hostname=options.get('hostname'))
|
|
if instance.exists():
|
|
print("Instance already registered %s" % instance_str(instance[0]))
|
|
return
|
|
instance = Instance(uuid=uuid, hostname=options.get('hostname'))
|
|
instance.save()
|
|
print('Successfully registered instance %s.' % instance_str(instance))
|