diff --git a/awx/main/management/commands/list_instances.py b/awx/main/management/commands/list_instances.py index 2e6af440f7..d2f11b6e14 100644 --- a/awx/main/management/commands/list_instances.py +++ b/awx/main/management/commands/list_instances.py @@ -3,6 +3,7 @@ from awx.main.models import Instance, InstanceGroup from django.core.management.base import BaseCommand +import six class Command(BaseCommand): @@ -13,10 +14,11 @@ class Command(BaseCommand): super(Command, self).__init__() for instance in Instance.objects.all(): - print("hostname: {}; created: {}; heartbeat: {}; capacity: {}".format(instance.hostname, instance.created, - instance.modified, instance.capacity)) + print(six.text_type( + "hostname: {0.hostname}; created: {0.created}; " + "heartbeat: {0.modified}; capacity: {0.capacity}").format(instance)) for instance_group in InstanceGroup.objects.all(): - print("Instance Group: {}; created: {}; capacity: {}; members: {}".format(instance_group.name, - instance_group.created, - instance_group.capacity, - [x.hostname for x in instance_group.instances.all()])) + print(six.text_type( + "Instance Group: {0.name}; created: {0.created}; " + "capacity: {0.capacity}; members: {1}").format(instance_group, + [x.hostname for x in instance_group.instances.all()])) diff --git a/awx/main/management/commands/register_queue.py b/awx/main/management/commands/register_queue.py index 85c7842381..5f252a4637 100644 --- a/awx/main/management/commands/register_queue.py +++ b/awx/main/management/commands/register_queue.py @@ -19,11 +19,11 @@ class InstanceNotFound(Exception): class Command(BaseCommand): def add_arguments(self, parser): - parser.add_argument('--queuename', dest='queuename', type=str, + parser.add_argument('--queuename', dest='queuename', type=lambda s: six.text_type(s, 'utf8'), help='Queue to create/update') - parser.add_argument('--hostnames', dest='hostnames', type=str, + parser.add_argument('--hostnames', dest='hostnames', type=lambda s: six.text_type(s, 'utf8'), help='Comma-Delimited Hosts to add to the Queue') - parser.add_argument('--controller', dest='controller', type=str, + parser.add_argument('--controller', dest='controller', type=lambda s: six.text_type(s, 'utf8'), default='', help='The controlling group (makes this an isolated group)') parser.add_argument('--instance_percent', dest='instance_percent', type=int, default=0, help='The percentage of active instances that will be assigned to this group'), @@ -96,7 +96,7 @@ class Command(BaseCommand): if options.get('hostnames'): hostname_list = options.get('hostnames').split(",") - with advisory_lock('instance_group_registration_%s' % queuename): + with advisory_lock(six.text_type('instance_group_registration_{}').format(queuename)): (ig, created, changed) = self.get_create_update_instance_group(queuename, inst_per, inst_min) if created: print(six.text_type("Creating instance group {}".format(ig.name)))