diff options
author | Sebastian Wagner <sebastian.wagner@suse.com> | 2020-03-09 15:26:31 +0100 |
---|---|---|
committer | Sebastian Wagner <sebastian.wagner@suse.com> | 2020-03-10 13:28:22 +0100 |
commit | 535ed8669c61f4685672620d03c3bd9513122188 (patch) | |
tree | d07d53eb3f275568be1b12360d58f556a1e6f6c9 | |
parent | python-common: Joined ServiceSpec and DriveGroupSpec from_json() (diff) | |
download | ceph-535ed8669c61f4685672620d03c3bd9513122188.tar.xz ceph-535ed8669c61f4685672620d03c3bd9513122188.zip |
cephadm: add host_pattern to supported scheduling
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
-rw-r--r-- | src/pybind/mgr/cephadm/module.py | 9 | ||||
-rw-r--r-- | src/pybind/mgr/cephadm/tests/test_scheduling.py | 8 | ||||
-rw-r--r-- | src/python-common/ceph/deployment/service_spec.py | 4 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 3a8eed618a9..5746089e5d3 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -3083,6 +3083,15 @@ class HostAssignment(object): logger.debug('All hosts: {}'.format(candidates)) return candidates + # respect host_pattern + if self.spec.placement.host_pattern: + candidates = [ + HostPlacementSpec(x, '', '') + for x in self.spec.placement.pattern_matches_hosts(self.get_hosts_func(None)) + ] + logger.debug('All hosts: {}'.format(candidates)) + return candidates + count = 0 if self.spec.placement.hosts and \ self.spec.placement.count and \ diff --git a/src/pybind/mgr/cephadm/tests/test_scheduling.py b/src/pybind/mgr/cephadm/tests/test_scheduling.py index e2a6a0191f7..d84c439e46e 100644 --- a/src/pybind/mgr/cephadm/tests/test_scheduling.py +++ b/src/pybind/mgr/cephadm/tests/test_scheduling.py @@ -104,6 +104,14 @@ class NodeAssignmentTest(NamedTuple): [], ['host1', 'host2', 'host3'] ), + # host_pattern + NodeAssignmentTest( + 'mon', + PlacementSpec(host_pattern='mon*'), + 'monhost1 monhost2 datahost'.split(), + [], + ['monhost1', 'monhost2'] + ), ]) def test_node_assignment(service_type, placement, hosts, daemons, expected): hosts = HostAssignment( diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 566e041fd91..481bad7254c 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -140,7 +140,9 @@ class PlacementSpec(object): def pattern_matches_hosts(self, all_hosts): # type: (List[str]) -> List[str] - return fnmatch.filter(all_hosts, self.host_pattern) # type: ignore + if not self.host_pattern: + return [] + return fnmatch.filter(all_hosts, self.host_pattern) def pretty_str(self): kv = [] |