Files
awx/awx/main/management/commands/register_instance.py
Matthew Jones babe29ebfa Implement cluster health checks
* 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
2016-10-06 16:05:39 -04:00

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))