diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-24 11:00:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-07-24 11:00:12 +0000 |
commit | d85cefdffe8b3ccb9b919f1cb83be42152e9e802 (patch) | |
tree | 868025a4a02e7f92b3112cc6b8df056d8bfb9c98 /yardstick/common | |
parent | 05dcc38c95cf0f35adadc1545fe663bfbb457bef (diff) | |
parent | abd5b952f42f429f6f1b59f3f7822cc92da0f6f6 (diff) |
Merge changes from topics 'YARDSTICK-1351', 'YARDSTICK-1339'
* changes:
Add IP mask to IxNetwork configuration
Improve NetworkServiceTestCase._get_ip_flow_range() function
Diffstat (limited to 'yardstick/common')
-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: |