|
44 | 44 | import os.path |
45 | 45 | import json |
46 | 46 | import base64 |
| 47 | +import six |
47 | 48 | from datetime import datetime |
48 | 49 | import logging |
49 | 50 | import random |
@@ -84,18 +85,18 @@ def get_ip_address(af, hostid=1, netid=100): |
84 | 85 | netid : The first octet in the Address. |
85 | 86 | ''' |
86 | 87 | global Address_Count |
87 | | - third_octet = Address_Count % 255 |
88 | | - second_octet = (Address_Count / 255) % 255 |
89 | | - first_octet = netid + (Address_Count / 65025) |
| 88 | + third_octet = int(Address_Count % 255) |
| 89 | + second_octet = int((Address_Count / 255) % 255) |
| 90 | + first_octet = int(netid + (Address_Count / 65025)) |
90 | 91 | Address_Count = Address_Count + 1 |
91 | 92 | if af == 'v4': |
92 | | - return "{}.{}.{}.{}".format( |
93 | | - first_octet, second_octet, third_octet, hostid).decode() |
| 93 | + return six.text_type("{}.{}.{}.{}".format( |
| 94 | + first_octet, second_octet, third_octet, hostid)) |
94 | 95 | if af == 'v6': |
95 | 96 | # :0: gets removed in the IPv6 addresses. |
96 | 97 | # Adding a to octets, to avoid it. |
97 | | - return "fddd:a{}:a{}::a{}:{}".format( |
98 | | - first_octet, second_octet, third_octet, hostid).decode() |
| 98 | + return six.text_type("fddd:a{}:a{}::a{}:{}".format( |
| 99 | + first_octet, second_octet, third_octet, hostid)) |
99 | 100 |
|
100 | 101 |
|
101 | 102 | def get_incremental_value(key): |
|
0 commit comments