From b1b01a7080eed2b98d8b76a00b1516cc71978690 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 14 Mar 2025 09:14:25 +0100 Subject: [PATCH 1/3] cloudstack-setup-databases: get local address instead of 127.0.1.1 In some linux setup, the server has the line in /etc/hosts ``` 127.0.1.1 ``` If the mgmt serve IP is not specified when run cloudstack-setup-databases, ACS detects the host ip in python, however there is an issue with it. ``` >>> import socket >>> socket.gethostbyname(socket.gethostname()) '127.0.1.1' <<<<=======================this is not good >>> socket.gethostbyname(socket.gethostname() + ".local") '10.0.100.100' <<<========================this is good ``` --- setup/bindir/cloud-setup-databases.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 317acd22216d..82f930fa71e1 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -328,7 +328,7 @@ for example: def grabSystemInfo(self): def getIpAddr(): try: - ip = socket.gethostbyname(socket.gethostname()) + ip = socket.gethostbyname(socket.gethostname() + ".local") return ip except Exception as e: return "127.0.0.1" From 2662986f6df4414f18ea4a0991c59b4ee8e10166 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 27 May 2025 09:13:46 +0200 Subject: [PATCH 2/3] Revert "cloudstack-setup-databases: get local address instead of 127.0.1.1" This reverts commit b1b01a7080eed2b98d8b76a00b1516cc71978690. --- setup/bindir/cloud-setup-databases.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 82f930fa71e1..317acd22216d 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -328,7 +328,7 @@ for example: def grabSystemInfo(self): def getIpAddr(): try: - ip = socket.gethostbyname(socket.gethostname() + ".local") + ip = socket.gethostbyname(socket.gethostname()) return ip except Exception as e: return "127.0.0.1" From 3efd24bfe7780353c6ad2aeca636c54484f126fa Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 27 May 2025 09:13:46 +0200 Subject: [PATCH 3/3] Update PR10571 --- setup/bindir/cloud-setup-databases.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 317acd22216d..79962f925ef5 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -328,8 +328,11 @@ for example: def grabSystemInfo(self): def getIpAddr(): try: - ip = socket.gethostbyname(socket.gethostname()) - return ip + hostname, aliases, addresses = socket.gethostbyname_ex(socket.gethostname()) + for address in addresses: + if address != "127.0.0.1" and address != "127.0.1.1": + return address + return "127.0.0.1" except Exception as e: return "127.0.0.1"