From: Kefu Chai Date: Sun, 15 Mar 2020 03:52:54 +0000 (+0800) Subject: pybind/mgr: apply_drivegroups should return Sequence[Completion] X-Git-Tag: v15.2.0~49^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=54ec595811979ca9f5dd0424977e2a959a485ddd;p=ceph.git pybind/mgr: apply_drivegroups should return Sequence[Completion] * change annotation of `orchestrator.Orchestrator.apply_drivegroups()` so it returns `Sequence[Completion]` see https://mypy.readthedocs.io/en/latest/generics.html#variance-of-generic-types * to follow the interface defined by `orchestrator.Orchestrator`. change all its implementations. see `orchestrator/_interface.py`. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index e4bbcaf78aa9..6d9bfbf05367 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -10,7 +10,8 @@ from mgr_util import create_self_signed_cert, verify_tls, ServerConfigException import string try: - from typing import List, Dict, Optional, Callable, Tuple, TypeVar, Type, Any, NamedTuple, Iterator, Set + from typing import List, Dict, Optional, Callable, Tuple, TypeVar, Type, \ + Any, NamedTuple, Iterator, Set, Sequence from typing import TYPE_CHECKING except ImportError: TYPE_CHECKING = False # just for type checking @@ -1949,7 +1950,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): r[str(o['osd'])] = o['uuid'] return r - def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> List[orchestrator.Completion]: + def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> Sequence[orchestrator.Completion]: completions: List[orchestrator.Completion] = list() for spec in specs: completions.extend(self._apply(spec)) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 5a83120b065f..e7ed20a903f7 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -913,7 +913,7 @@ class Orchestrator(object): """ raise NotImplementedError() - def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> List[Completion]: + def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> Sequence[Completion]: """ Update OSD cluster """ raise NotImplementedError() diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 5f22e30ce0d7..c8db5b7ae1f8 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -10,7 +10,7 @@ from subprocess import check_output, CalledProcessError from ceph.deployment.service_spec import NFSServiceSpec, ServiceSpec try: - from typing import Callable, List, Tuple + from typing import Callable, List, Sequence, Tuple except ImportError: pass # type checking @@ -259,7 +259,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): ) def apply_drivegroups(self, specs): - # type: (List[DriveGroupSpec]) -> TestCompletion + # type: (List[DriveGroupSpec]) -> Sequence[TestCompletion] drive_group = specs[0] def run(all_hosts): # type: (List[orchestrator.HostSpec]) -> None @@ -267,12 +267,12 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): if drive_group.placement.host_pattern: if not drive_group.placement.pattern_matches_hosts([h.hostname for h in all_hosts]): raise orchestrator.OrchestratorValidationError('failed to match') - return self.get_hosts().then(run).then( + return [self.get_hosts().then(run).then( on_complete=orchestrator.ProgressReference( message='apply_drivesgroups', mgr=self, ) - ) + )] @deferred_write("remove_daemons") def remove_daemons(self, names, force):