diff --git a/awx/main/management/commands/register_instance.py b/awx/main/management/commands/register_instance.py index 5072f5195e..942eb9af4d 100644 --- a/awx/main/management/commands/register_instance.py +++ b/awx/main/management/commands/register_instance.py @@ -3,7 +3,6 @@ from django.core.management.base import CommandError -from awx.api.license import feature_enabled from awx.main.management.commands._base_instance import BaseCommandInstance from awx.main.models import Instance @@ -33,13 +32,6 @@ class Command(BaseCommandInstance): uuid = self.get_UUID() - # Are we attempting to register a secondary instance? - # If so, we are only willing to do that if the Tower license allows - # it. - if self.is_option_secondary() and not feature_enabled('ha'): - raise CommandError('Your Tower license does not permit creation ' - 'of secondary instances.') - # Is there an existing record for this machine? If so, retrieve that record and look for issues. try: instance = Instance.objects.get(uuid=uuid) diff --git a/awx/main/management/commands/remove_instance.py b/awx/main/management/commands/remove_instance.py index bcbd757b41..d8712137be 100644 --- a/awx/main/management/commands/remove_instance.py +++ b/awx/main/management/commands/remove_instance.py @@ -33,7 +33,7 @@ class Command(BaseCommandInstance): # Sanity check: Do not remove the primary instance. if instance.primary: - raise CommandError('I cowardly refuse to remove the primary instance %s.' % instance_str(instance)) + raise CommandError('Cannot remove primary instance %s. Another instance must be promoted to primary first.' % instance_str(instance)) # Remove the instance. instance.delete() diff --git a/awx/main/management/commands/update_instance.py b/awx/main/management/commands/update_instance.py index cd3e53f711..7ffffa62a7 100644 --- a/awx/main/management/commands/update_instance.py +++ b/awx/main/management/commands/update_instance.py @@ -5,7 +5,7 @@ from django.core.management.base import CommandError from django.db import transaction from awx.main.management.commands._base_instance import BaseCommandInstance - +from awx.api.license import feature_enabled from awx.main.models import Instance instance_str = BaseCommandInstance.instance_str @@ -33,6 +33,10 @@ class Command(BaseCommandInstance): def handle(self, *args, **options): super(Command, self).handle(*args, **options) + # You can only promote/demote if your license allows HA + if not feature_enabled('ha'): + raise CommandError('Your Tower license does not permit promoting a secondary instance') + # Is there an existing record for this machine? If so, retrieve that record and look for issues. try: instance = Instance.objects.get(**self.get_unique_fields())