qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 2/3] Acceptance test: provides new functions


From: Oksana Vohchana
Subject: [PATCH v5 2/3] Acceptance test: provides new functions
Date: Tue, 7 Apr 2020 18:56:41 +0300

Provides new functions related to the rdma migration test
Adds functions to check if service RDMA is enabled and gets
the ip address on the interface where it was configured

Signed-off-by: Oksana Vohchana <address@hidden>
---
 tests/acceptance/migration.py | 45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index e4c39b85a1..1c3a684395 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -11,12 +11,57 @@
 
 
 import tempfile
+import json
 from avocado_qemu import Test
 from avocado import skipUnless
 
 from avocado.utils import network
 from avocado.utils import wait
 from avocado.utils.path import find_command
+from avocado.utils.network.interfaces import NetworkInterface
+from avocado.utils.network.hosts import LocalHost
+from avocado.utils import service
+from avocado.utils import process
+
+
+def get_rdma_status():
+    """Verify the status of RDMA service.
+
+    return: True if rdma service is enabled, False otherwise.
+    """
+    rdma_stat = service.ServiceManager()
+    return bool(rdma_stat.status('rdma'))
+
+def get_interface_rdma():
+    """Get the interface name where RDMA is configured.
+
+    return: The interface name or False if none is found
+    """
+    cmd = 'rdma link show -j'
+    out = json.loads(process.getoutput(cmd))
+    try:
+        for i in out:
+            if i['state'] == 'ACTIVE':
+                return i['netdev']
+    except KeyError:
+        pass
+    return False
+
+def get_ip_rdma(interface):
+    """Get the IP address on a specific interface.
+
+    :param interface: Network interface name
+    :return: IP addresses as a list, otherwise will return False
+    """
+    local = LocalHost()
+    network_in = NetworkInterface(interface, local)
+    try:
+        ip = network_in.get_ipaddrs()
+        if ip:
+            return ip
+    except:
+        pass
+    return False
 
 
 class Migration(Test):
-- 
2.21.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]