mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
Merge pull request #1719 from AlanCoding/dragon_lair
Allow unicode queue names via CLI
This commit is contained in:
commit
b50bddbc93
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from awx.main.models import Instance, InstanceGroup
|
from awx.main.models import Instance, InstanceGroup
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@ -13,10 +14,11 @@ class Command(BaseCommand):
|
|||||||
super(Command, self).__init__()
|
super(Command, self).__init__()
|
||||||
|
|
||||||
for instance in Instance.objects.all():
|
for instance in Instance.objects.all():
|
||||||
print("hostname: {}; created: {}; heartbeat: {}; capacity: {}".format(instance.hostname, instance.created,
|
print(six.text_type(
|
||||||
instance.modified, instance.capacity))
|
"hostname: {0.hostname}; created: {0.created}; "
|
||||||
|
"heartbeat: {0.modified}; capacity: {0.capacity}").format(instance))
|
||||||
for instance_group in InstanceGroup.objects.all():
|
for instance_group in InstanceGroup.objects.all():
|
||||||
print("Instance Group: {}; created: {}; capacity: {}; members: {}".format(instance_group.name,
|
print(six.text_type(
|
||||||
instance_group.created,
|
"Instance Group: {0.name}; created: {0.created}; "
|
||||||
instance_group.capacity,
|
"capacity: {0.capacity}; members: {1}").format(instance_group,
|
||||||
[x.hostname for x in instance_group.instances.all()]))
|
[x.hostname for x in instance_group.instances.all()]))
|
||||||
|
@ -19,11 +19,11 @@ class InstanceNotFound(Exception):
|
|||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
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')
|
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')
|
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)')
|
default='', help='The controlling group (makes this an isolated group)')
|
||||||
parser.add_argument('--instance_percent', dest='instance_percent', type=int, default=0,
|
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'),
|
help='The percentage of active instances that will be assigned to this group'),
|
||||||
@ -96,7 +96,7 @@ class Command(BaseCommand):
|
|||||||
if options.get('hostnames'):
|
if options.get('hostnames'):
|
||||||
hostname_list = options.get('hostnames').split(",")
|
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)
|
(ig, created, changed) = self.get_create_update_instance_group(queuename, inst_per, inst_min)
|
||||||
if created:
|
if created:
|
||||||
print(six.text_type("Creating instance group {}".format(ig.name)))
|
print(six.text_type("Creating instance group {}".format(ig.name)))
|
||||||
|
Loading…
Reference in New Issue
Block a user