Copilot commented on code in PR #10571:
URL: https://github.com/apache/cloudstack/pull/10571#discussion_r2317996013
##########
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"
Review Comment:
The hardcoded IP address strings should be replaced with constants or use
the ipaddress module for better maintainability. Consider using
`ipaddress.ip_address(address).is_loopback` to check for all loopback
addresses, not just the two specific ones.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]