adapt inventory script to python 2.7 version (#4407)
This commit is contained in:
parent
ed18a10571
commit
1babba753d
1 changed files with 8 additions and 2 deletions
|
@ -197,8 +197,14 @@ class KubesprayInventory(object):
|
||||||
reworked_hosts = []
|
reworked_hosts = []
|
||||||
|
|
||||||
def ips(start_address, end_address):
|
def ips(start_address, end_address):
|
||||||
start = int(ip_address(start_address).packed.hex(), 16)
|
try:
|
||||||
end = int(ip_address(end_address).packed.hex(), 16)
|
# Python 3.x
|
||||||
|
start = int(ip_address(start_address))
|
||||||
|
end = int(ip_address(end_address))
|
||||||
|
except:
|
||||||
|
# Python 2.7
|
||||||
|
start = int(ip_address(unicode(start_address)))
|
||||||
|
end = int(ip_address(unicode(end_address)))
|
||||||
return [ip_address(ip).exploded for ip in range(start, end+1)]
|
return [ip_address(ip).exploded for ip in range(start, end+1)]
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
|
|
Loading…
Reference in a new issue