]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: apply_drivegroups should return Sequence[Completion] 33977/head
authorKefu Chai <kchai@redhat.com>
Sun, 15 Mar 2020 03:52:54 +0000 (11:52 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 15 Mar 2020 04:39:46 +0000 (12:39 +0800)
* 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 <kchai@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/test_orchestrator/module.py

index e4bbcaf78aa91b3cadc3d4c5ca61aa24a189f5a3..6d9bfbf053674f72ad856fc81b4b6f0cd152ad81 100644 (file)
@@ -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))
index 5a83120b065f42c65df74831e4d99caa9e097c30..e7ed20a903f7fa7be266fc9dfcf8504299afe814 100644 (file)
@@ -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()
 
index 5f22e30ce0d7a50497c1e158c379797bd96785de..c8db5b7ae1f803e6ee60004f83d614ecddbd7383 100644 (file)
@@ -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):