Skip to content

Commit

Permalink
adapt inventory script to python 2.7 version (kubernetes-sigs#4407)
Browse files Browse the repository at this point in the history
  • Loading branch information
tikitavi authored and k8s-ci-robot committed Mar 29, 2019
1 parent ed18a10 commit 1babba7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contrib/inventory_builder/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,14 @@ def range2ips(self, hosts):
reworked_hosts = []

def ips(start_address, end_address):
start = int(ip_address(start_address).packed.hex(), 16)
end = int(ip_address(end_address).packed.hex(), 16)
try:
# 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)]

for host in hosts:
Expand Down

0 comments on commit 1babba7

Please sign in to comment.