diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-23 17:00:52 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-24 08:59:37 +0100 |
commit | abd5b952f42f429f6f1b59f3f7822cc92da0f6f6 (patch) | |
tree | 8a6519548f08650976ef4c31e16e30177905c39b /yardstick/common/utils.py | |
parent | 70eef8dd6ef160d3782984742fbc7958a35c03c7 (diff) |
Add IP mask to IxNetwork configuration
Assign the IP mask to IxNetwork configuration, depending on the IP range
provided by the user in the traffic profile. In case of single IP, a
default mask will be provided:
- IP_VERSION_4_MASK = 24
- IP_VERSION_6_MASK = 64
JIRA: YARDSTICK-1351
Change-Id: I029473ab8b9966a76cf559ffef53b34ca11462ad
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/common/utils.py')
-rw-r--r-- | yardstick/common/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 85cecc714..83ddbd470 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -335,6 +335,14 @@ def ip_to_hex(ip_addr, separator=''): return separator.join('{:02x}'.format(octet) for octet in address.packed) +def get_mask_from_ip_range(ip_low, ip_high): + _ip_low = ipaddress.ip_address(ip_low) + _ip_high = ipaddress.ip_address(ip_high) + _ip_low_int = int(_ip_low) + _ip_high_int = int(_ip_high) + return _ip_high.max_prefixlen - (_ip_high_int ^ _ip_low_int).bit_length() + + def try_int(s, *args): """Convert to integer if possible.""" try: |