summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2017-10-10 17:35:47 +1000
committerDan Callaghan <dcallagh@redhat.com>2017-10-12 06:27:54 +0000
commitaa6ca48acf927d67e1870ba29088ee774b604741 (patch)
treebb08d4962f8ce2795bb9e860272ccba211681964
parent0d72f8c9158682f902c922e5b931c9efcbb2c02c (diff)
implement OpenStack flavor filtering for <not/>
This was somehow missed in the original implementation, causing <not/> to always default to precluding OpenStack. Bug: 1499646 Change-Id: I79dd7ccedbb7c5e38af4deef724504e5874b56b7
-rw-r--r--IntegrationTests/src/bkr/inttest/server/test_needpropertyxml.py21
-rw-r--r--Server/bkr/server/needpropertyxml.py14
2 files changed, 35 insertions, 0 deletions
diff --git a/IntegrationTests/src/bkr/inttest/server/test_needpropertyxml.py b/IntegrationTests/src/bkr/inttest/server/test_needpropertyxml.py
index 5e4514c..37db4c8 100644
--- a/IntegrationTests/src/bkr/inttest/server/test_needpropertyxml.py
+++ b/IntegrationTests/src/bkr/inttest/server/test_needpropertyxml.py
@@ -1270,6 +1270,17 @@ class OpenstackFlavorFilteringTest(DatabaseTestCase):
""",
present=[small_flavor], absent=[medium_flavor, large_flavor])
+ def test_not(self):
+ small_flavor = FakeFlavor(disk=10, ram=512, vcpus=1)
+ large_flavor = FakeFlavor(disk=20, ram=2048, vcpus=2)
+ self.check_filter("""
+ <hostRequires>
+ <not><pool value="somepool"/></not>
+ <not><memory op="&lt;" value="2048"/></not>
+ </hostRequires>
+ """,
+ present=[large_flavor], absent=[small_flavor])
+
class VirtualisabilityTestCase(DatabaseTestCase):
def setUp(self):
@@ -1421,3 +1432,13 @@ class VirtualisabilityTestCase(DatabaseTestCase):
</hostRequires>
""",
False)
+
+ def test_not(self):
+ self.check_filter("""
+ <hostRequires>
+ <not>
+ <pool value="somepool"/>
+ </not>
+ </hostRequires>
+ """,
+ True)
diff --git a/Server/bkr/server/needpropertyxml.py b/Server/bkr/server/needpropertyxml.py
index 547b562..cb1a3b3 100644
--- a/Server/bkr/server/needpropertyxml.py
+++ b/Server/bkr/server/needpropertyxml.py
@@ -252,6 +252,20 @@ class XmlNot(ElementWrapper):
queries.append(query)
return not_(and_(*queries))
+ def filter_openstack_flavors(self, flavors, lab_controller):
+ # Acceptable flavours are any flavour which was *not* matched by the
+ # child filters.
+ result = set(flavors)
+ for child in self:
+ child_result = child.filter_openstack_flavors(flavors, lab_controller)
+ result.difference_update(child_result)
+ return list(result)
+
+ def virtualisable(self):
+ # Even if the child filters cannot be satisfied by OpenStack,
+ # the negation of them probably can be.
+ return True
+
class XmlDistroArch(ElementWrapper):
"""