From 1babba753d3838b73dde79d43bf886d7d1e1fa0c Mon Sep 17 00:00:00 2001 From: tikitavi Date: Fri, 29 Mar 2019 16:08:13 +0300 Subject: [PATCH] adapt inventory script to python 2.7 version (#4407) --- contrib/inventory_builder/inventory.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/inventory_builder/inventory.py b/contrib/inventory_builder/inventory.py index ab31a7eaa..24fb5c092 100644 --- a/contrib/inventory_builder/inventory.py +++ b/contrib/inventory_builder/inventory.py @@ -197,8 +197,14 @@ class KubesprayInventory(object): 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: