Merge pull request #31 from johnpc35/master

Fix QEMU guest agent IP address retrieval
This commit is contained in:
Xabi 2021-03-05 22:43:21 +01:00 committed by GitHub
commit 0477e6df06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 8 deletions

View File

@ -208,14 +208,26 @@ class ProxmoxAPI(object):
if type(networks) is dict:
for network in networks:
for ip_address in ['ip-address']:
try:
# IP address validation
if socket.inet_aton(ip_address):
# Ignore localhost
if ip_address != '127.0.0.1':
return ip_address
except socket.error:
pass
try:
# IP address validation
if socket.inet_aton(ip_address):
# Ignore localhost
if ip_address != '127.0.0.1':
return ip_address
except socket.error:
pass
elif type(networks) is list:
for network in networks:
if 'ip-addresses' in network:
for ip_address in network['ip-addresses']:
try:
# IP address validation
if socket.inet_aton(ip_address['ip-address']):
# Ignore localhost
if ip_address['ip-address'] != '127.0.0.1':
return ip_address['ip-address']
except socket.error:
pass
return None
def openvz_ip_address(self, node, vm):