[virt-tools-list] [PATCH v2 2/6] connection: support checking for a list of features

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Thu Feb 22 11:34:18 UTC 2018


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Make check_support() accept a list of features.

This will let tests have more complex conditions on the features they
require.

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 virtinst/connection.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/virtinst/connection.py b/virtinst/connection.py
index 3d1f73d2..40438d9a 100644
--- a/virtinst/connection.py
+++ b/virtinst/connection.py
@@ -409,7 +409,7 @@ class VirtualConnection(object):
                          _supportname.startswith("SUPPORT_")]:
         locals()[_supportname] = getattr(support, _supportname)
 
-    def check_support(self, feature, data=None):
+    def _check_support(self, feature, data=None):
         key = feature
         data = data or self
         if key not in self._support_cache:
@@ -417,6 +417,16 @@ class VirtualConnection(object):
                 self, feature, data)
         return self._support_cache[key]
 
+    def check_support(self, features, data=None):
+        if isinstance(features, list):
+            # 'and' condition over the feature list
+            for f in features:
+                if not self._check_support(f, data):
+                    return False
+            return True
+        else:
+            return self._check_support(features, data)
+
     def support_remote_url_install(self):
         if self._magic_uri:
             return False
-- 
2.16.1.73.g5832b7e9f2




More information about the virt-tools-list mailing list