mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 06:29:31 -02:30
Merge pull request #330 from chrismeyersfsu/fix-update_instance
change update_instance to only take --primary role flag
This commit is contained in:
@@ -70,8 +70,13 @@ class BaseCommandInstance(BaseCommand):
|
|||||||
default='',
|
default='',
|
||||||
help='Find instance by specified uuid.')
|
help='Find instance by specified uuid.')
|
||||||
|
|
||||||
|
def include_option_primary_role(self):
|
||||||
|
BaseCommand.option_list += ( BaseCommandInstance.generate_option_primary(), )
|
||||||
|
self.enforce_primary_role = True
|
||||||
|
|
||||||
def include_options_roles(self):
|
def include_options_roles(self):
|
||||||
BaseCommand.option_list += ( BaseCommandInstance.generate_option_primary(), BaseCommandInstance.generate_option_secondary(), )
|
self.include_option_primary_role()
|
||||||
|
BaseCommand.option_list += ( BaseCommandInstance.generate_option_secondary(), )
|
||||||
self.enforce_roles = True
|
self.enforce_roles = True
|
||||||
|
|
||||||
def include_option_hostname_set(self):
|
def include_option_hostname_set(self):
|
||||||
@@ -107,6 +112,8 @@ class BaseCommandInstance(BaseCommand):
|
|||||||
return CommandError('--hostname and one of --primary or --secondary is required.')
|
return CommandError('--hostname and one of --primary or --secondary is required.')
|
||||||
elif self.enforce_hostname_set:
|
elif self.enforce_hostname_set:
|
||||||
return CommandError('--hostname is required.')
|
return CommandError('--hostname is required.')
|
||||||
|
elif self.enforce_primary_role:
|
||||||
|
return CommandError('--primary is required.')
|
||||||
elif self.enforce_roles:
|
elif self.enforce_roles:
|
||||||
return CommandError('One of --primary or --secondary is required.')
|
return CommandError('One of --primary or --secondary is required.')
|
||||||
|
|
||||||
@@ -120,6 +127,11 @@ class BaseCommandInstance(BaseCommand):
|
|||||||
|
|
||||||
if self.is_option_primary() and self.is_option_secondary() or not (self.is_option_primary() or self.is_option_secondary()):
|
if self.is_option_primary() and self.is_option_secondary() or not (self.is_option_primary() or self.is_option_secondary()):
|
||||||
raise self.usage_error
|
raise self.usage_error
|
||||||
|
elif self.enforce_primary_role:
|
||||||
|
if options['primary']:
|
||||||
|
self.option_primary = options['primary']
|
||||||
|
else:
|
||||||
|
raise self.usage_error
|
||||||
|
|
||||||
if self.enforce_hostname_set:
|
if self.enforce_hostname_set:
|
||||||
if options['hostname']:
|
if options['hostname']:
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Command(BaseCommandInstance):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Command, self).__init__()
|
super(Command, self).__init__()
|
||||||
|
|
||||||
self.include_options_roles()
|
self.include_option_primary_role()
|
||||||
self.include_option_hostname_uuid_find()
|
self.include_option_hostname_uuid_find()
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
|||||||
Reference in New Issue
Block a user