Fixed python3 errors
Modified `network` > `networks`. Also fixed Python3 `TypeError: string indices must be integers` dict error.
This commit is contained in:
parent
ebcd5ac294
commit
3650024b1d
21
proxmox.py
21
proxmox.py
|
@ -205,18 +205,17 @@ class ProxmoxAPI(object):
|
||||||
ip_address = None
|
ip_address = None
|
||||||
networks = self.get('api2/json/nodes/{0}/qemu/{1}/agent/network-get-interfaces'.format(node, vm))['result']
|
networks = self.get('api2/json/nodes/{0}/qemu/{1}/agent/network-get-interfaces'.format(node, vm))['result']
|
||||||
if networks:
|
if networks:
|
||||||
if type(network) is dict:
|
if type(networks) is dict:
|
||||||
for network in networks:
|
for network in networks:
|
||||||
for address in network['ip-addresses']:
|
for ip_address in ['ip-address']:
|
||||||
ip_address = address['ip-address']
|
try:
|
||||||
try:
|
# IP address validation
|
||||||
# IP address validation
|
if socket.inet_aton(ip_address):
|
||||||
if socket.inet_aton(ip_address):
|
# Ignore localhost
|
||||||
# Ignore localhost
|
if ip_address != '127.0.0.1':
|
||||||
if ip_address != '127.0.0.1':
|
return ip_address
|
||||||
return ip_address
|
except socket.error:
|
||||||
except socket.error:
|
pass
|
||||||
pass
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def openvz_ip_address(self, node, vm):
|
def openvz_ip_address(self, node, vm):
|
||||||
|
|
Reference in New Issue