From 35fbb94aa67e7358584756d68d6de92ef9577884 Mon Sep 17 00:00:00 2001 From: Stanislav Zaprudskiy Date: Fri, 17 Feb 2023 17:33:45 +0100 Subject: [PATCH] Use `CLUSTER_HOST_ID` as default hostname argument value Incorporates feedback from https://github.com/ansible/awx/pull/13445/files#r1106012308 Signed-off-by: Stanislav Zaprudskiy --- awx/main/management/commands/disable_instance.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/awx/main/management/commands/disable_instance.py b/awx/main/management/commands/disable_instance.py index a0f7bfef10..054e47974b 100644 --- a/awx/main/management/commands/disable_instance.py +++ b/awx/main/management/commands/disable_instance.py @@ -1,4 +1,3 @@ -import socket import time from urllib.parse import urljoin @@ -18,7 +17,7 @@ class AWXInstance: self.get_instance() def get_instance(self): - filter = self.filter if self.filter is not None else dict(hostname=socket.gethostname()) + filter = self.filter if self.filter is not None else dict(hostname=settings.CLUSTER_HOST_ID) qs = Instance.objects.filter(**filter) if not qs.exists(): raise ValueError(f"No AWX instance found with {filter} parameters") @@ -88,7 +87,7 @@ class Command(BaseCommand): filter_group.add_argument( "--hostname", type=str, - default=socket.gethostname(), + default=settings.CLUSTER_HOST_ID, help=f"{Instance.hostname.field.help_text} Defaults to the hostname of the machine where the Python interpreter is currently executing".strip(), ) filter_group.add_argument("--id", type=self.ge_1, help=Instance.id.field.help_text)