Added random Infiniband GUID address generator
Infiniband[1] technology uses GUID[2] address as 'analog' of the MAC.
Adding GUID support to tempest-lib allows adding tempest tests or/and
external tempest plugin tests to test this technology.
For instance ironic tempest plugin[3].
More details about Infiniband Technology can be downloaded here[4].
[1]https://wiki.archlinux.org/index.php/InfiniBand
[2]https://wiki.archlinux.org/index.php/InfiniBand#GUID
[3]https://github.com/openstack/ironic/tree/master/ironic_tempest_plugin
[4]http://www.infinibandta.org/content/pages.php?pg=technology_download
Change-Id: I6129a94b1ea65d989c5fb549319d71ccac76d0a4
diff --git a/tempest/lib/common/utils/data_utils.py b/tempest/lib/common/utils/data_utils.py
index 01b6477..7c124af 100644
--- a/tempest/lib/common/utils/data_utils.py
+++ b/tempest/lib/common/utils/data_utils.py
@@ -121,6 +121,18 @@
return ':'.join(["%02x" % x for x in mac])
+def rand_infiniband_guid_address():
+ """Generate an Infiniband GUID address
+
+ :return: an random Infiniband GUID address
+ :rtype: string
+ """
+ guid = []
+ for i in range(8):
+ guid.append("%02x" % random.randint(0x00, 0xff))
+ return ':'.join(guid)
+
+
def parse_image_id(image_ref):
"""Return the image id from a given image ref
diff --git a/tempest/tests/lib/common/utils/test_data_utils.py b/tempest/tests/lib/common/utils/test_data_utils.py
index 493df89..220d172 100644
--- a/tempest/tests/lib/common/utils/test_data_utils.py
+++ b/tempest/tests/lib/common/utils/test_data_utils.py
@@ -93,6 +93,15 @@
actual2 = data_utils.rand_int_id()
self.assertNotEqual(actual, actual2)
+ def test_rand_infiniband_guid_address(self):
+ actual = data_utils.rand_infiniband_guid_address()
+ self.assertIsInstance(actual, str)
+ self.assertRegex(actual, "^([0-9a-f][0-9a-f]:){7}"
+ "[0-9a-f][0-9a-f]$")
+
+ actual2 = data_utils.rand_infiniband_guid_address()
+ self.assertNotEqual(actual, actual2)
+
def test_rand_mac_address(self):
actual = data_utils.rand_mac_address()
self.assertIsInstance(actual, str)