1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 13:55:31 +03:00

Merge pull request #5589 from jakemcdermott/fix-4056

Generate new uuid for newly registered iso nodes

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-01-08 18:37:52 +00:00 committed by GitHub
commit c0e1c8aa77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -1,6 +1,8 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved
from uuid import uuid4
from awx.main.models import Instance
from django.conf import settings
@ -22,6 +24,8 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--hostname', dest='hostname', type=str,
help='Hostname used during provisioning')
parser.add_argument('--is-isolated', dest='is_isolated', action='store_true',
help='Specify whether the instance is isolated')
def _register_hostname(self, hostname):
if not hostname:
@ -37,6 +41,9 @@ class Command(BaseCommand):
def handle(self, **options):
if not options.get('hostname'):
raise CommandError("Specify `--hostname` to use this command.")
if options['is_isolated']:
self.uuid = str(uuid4())
else:
self.uuid = settings.SYSTEM_UUID
self.changed = False
self._register_hostname(options.get('hostname'))

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from uuid import uuid4
from django.db import migrations
from awx.main.models import Instance
def _generate_new_uuid_for_iso_nodes(apps, schema_editor):
for instance in Instance.objects.all():
if instance.is_isolated():
instance.uuid = str(uuid4())
instance.save()
class Migration(migrations.Migration):
dependencies = [
('main', '0100_v370_projectupdate_job_tags'),
]
operations = [
migrations.RunPython(_generate_new_uuid_for_iso_nodes)
]