]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orch: PlacementSpec: add all_hosts property
authorSage Weil <sage@redhat.com>
Fri, 21 Feb 2020 15:27:28 +0000 (09:27 -0600)
committerSage Weil <sage@redhat.com>
Mon, 24 Feb 2020 13:39:46 +0000 (07:39 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/orchestrator/_interface.py

index 7c03d159d3f438c2164455e3a759bebd94414848..59fa605f85c336d0bb78c3ee90f74bd1cee678e4 100644 (file)
@@ -1173,8 +1173,8 @@ class PlacementSpec(object):
     """
     For APIs that need to specify a host subset
     """
-    def __init__(self, label=None, hosts=None, count=None):
-        # type: (Optional[str], Optional[List], Optional[int]) -> None
+    def __init__(self, label=None, hosts=None, count=None, all_hosts=False):
+        # type: (Optional[str], Optional[List], Optional[int], bool) -> None
         self.label = label
         self.hosts = []  # type: List[HostPlacementSpec]
         if hosts:
@@ -1185,6 +1185,7 @@ class PlacementSpec(object):
 
 
         self.count = count  # type: Optional[int]
+        self.all_hosts = all_hosts  # type: bool
 
     def set_hosts(self, hosts):
         # To backpopulate the .hosts attribute when using labels or count
@@ -1236,12 +1237,23 @@ class PlacementSpec(object):
             except ValueError:
                 pass
 
-        hosts = [x for x in strings if 'label:' not in x]
+        all_hosts = False
+        if '*' in strings:
+            all_hosts = True
+            strings.remove('*')
+        if 'all:true' in strings:
+            all_hosts = True
+            strings.remove('all:true')
+
+        hosts = [x for x in strings if x != '*' and 'label:' not in x]
         labels = [x for x in strings if 'label:' in x]
         if len(labels) > 1:
             raise OrchestratorValidationError('more than one label provided: {}'.format(labels))
 
-        ps = PlacementSpec(count=count, hosts=hosts, label=labels[0] if labels else None)
+        ps = PlacementSpec(count=count,
+                           hosts=hosts,
+                           label=labels[0] if labels else None,
+                           all_hosts=all_hosts)
         ps.validate()
         return ps