From e8da497f4cfbe07f7072d77de756d81baf003a47 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 1 Mar 2021 13:56:51 +0100 Subject: [PATCH] mgr/test_orchestrator: Refactor create_osds Signed-off-by: Sebastian Wagner (cherry picked from commit 0f22f24a35651a37430296e6c2eea454b3489e6a) --- src/pybind/mgr/test_orchestrator/module.py | 29 +++++----------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 1f527cba07657..75fec48d37ef3 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -205,37 +205,21 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): The drivegroup file must only contain one spec at a time. """ + return self._create_osds(drive_group) + + def _create_osds(self, drive_group): + # type: (DriveGroupSpec) -> str drive_group.validate() all_hosts = raise_if_exception(self.get_hosts()) - - - def get_hosts_func(label=None, as_hostspec=False): - if as_hostspec: - return all_hosts - return [h.hostname for h in all_hosts] - - if not drive_group.placement.filter_matching_hosts(get_hosts_func): + if not drive_group.placement.filter_matching_hostspecs(all_hosts): raise orchestrator.OrchestratorValidationError('failed to match') return '' @handle_orch_error def apply_drivegroups(self, specs): # type: (List[DriveGroupSpec]) -> List[str] - drive_group = specs[0] - - all_hosts = raise_if_exception(self.get_hosts()) - - drive_group.validate() - - def get_hosts_func(label=None, as_hostspec=False): - if as_hostspec: - return all_hosts - return [h.hostname for h in all_hosts] - - if not drive_group.placement.filter_matching_hosts(get_hosts_func): - raise orchestrator.OrchestratorValidationError('failed to match') - return [] + return [self._create_osds(dg) for dg in specs] @handle_orch_error def remove_daemons(self, names): @@ -335,4 +319,3 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): assert all([isinstance(h[0], str) for h in spec.placement.hosts]) assert all([isinstance(h[1], str) or h[1] is None for h in spec.placement.hosts]) return spec.one_line_str() - -- 2.39.5