]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: add py.typed (PEP 561) 33236/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Wed, 12 Feb 2020 10:34:40 +0000 (11:34 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 12 Feb 2020 10:34:40 +0000 (11:34 +0100)
Bugs found:

* Fixed documentation of how `mgr/Orchestrator.create_osds` is called
* mgr/Rook.create_osds: Added missing `.path` when querying paths.
* mgr/Rook.create_osds: Fixed progress message
* mgr/RookCluster.create_osds: Empty list instead of `None`
* python-common: use empty objects instead of `None`

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/requirements.txt
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py
src/python-common/ceph/deployment/drive_group.py
src/python-common/ceph/deployment/inventory.py
src/python-common/ceph/py.typed [new file with mode: 0644]

index 99f2010b98a6941fd7056f291e8e1b59c2262ff2..5d14f2c5a5dd3467367eab9149f96a6ea74a94a3 100644 (file)
@@ -24,7 +24,7 @@ import shutil
 import subprocess
 
 from ceph.deployment import inventory, translate
-from ceph.deployment.drive_group import DriveGroupSpecs
+from ceph.deployment.drive_group import DriveGroupSpec
 from ceph.deployment.drive_selection import selector
 
 from mgr_module import MgrModule
@@ -1514,11 +1514,12 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         return self.get_inventory().then(call_create)
 
     def create_osds(self, drive_groups):
+        # type: (List[DriveGroupSpec]) -> AsyncCompletion
         return self.get_hosts().then(lambda hosts: self.call_inventory(hosts, drive_groups))
 
     def _prepare_deployment(self,
                             all_hosts,  # type: List[orchestrator.InventoryNode]
-                            drive_groups,  # type: List[DriveGroupSpecs]
+                            drive_groups,  # type: List[DriveGroupSpec]
                             inventory_list  # type: List[orchestrator.InventoryNode]
                             ):
         # type: (...) -> orchestrator.Completion
index 90e9685baaffe4eb949771e935768238f9dba86b..0700317f7ad7e598d9d8ef01b09e8d548552cb0e 100644 (file)
@@ -890,7 +890,7 @@ class Orchestrator(object):
         raise NotImplementedError()
 
     def create_osds(self, drive_groups):
-        # type: (DriveGroupSpec) -> Completion
+        # type: (List[DriveGroupSpec]) -> Completion
         """
         Create one or more OSDs within a single Drive Group.
 
index f14efb8cd80d5a6d216efed924d55f44ae5d056f..4281f47e8c1dd83c33addd03277d87574a07c255 100644 (file)
@@ -1,7 +1,7 @@
 pytest-cov==2.7.1
 mock; python_version <= '3.3'
 ipaddress; python_version < '3.3'
-../../python-common
+-e../../python-common
 kubernetes
 requests-mock
 pyyaml
index a8970c7e0cdab4d9938a7cc5c94221f36d5d01c1..eb7e23f8085ad206ef90aa3440bff1720326b427 100644 (file)
@@ -387,8 +387,8 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
         drive_group = drive_groups[0]
 
         targets = []  # type: List[str]
-        if drive_group.data_devices:
-            targets += drive_group.data_devices.paths
+        if drive_group.data_devices and drive_group.data_devices.paths:
+            targets += [d.path for d in drive_group.data_devices.paths]
         if drive_group.data_directories:
             targets += drive_group.data_directories
 
@@ -409,7 +409,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
 
             return orchestrator.Completion.with_progress(
                 message="Creating OSD on {0}:{1}".format(
-                        drive_group.hosts(drive_group.host_pattern),
+                        drive_group.hosts(all_hosts),
                         targets),
                 mgr=self,
                 on_complete=lambda _:self.rook_cluster.add_osds(drive_group, all_hosts),
index 0fa724e5ae4f59640e895acde34923681b30caf8..bb667f0703f0f69a7b008b7ad012964c463f0638 100644 (file)
@@ -494,7 +494,7 @@ class RookCluster(object):
         Rook currently (0.8) can only do single-drive OSDs, so we
         treat all drive groups as just a list of individual OSDs.
         """
-        block_devices = drive_group.data_devices.paths if drive_group.data_devices else None
+        block_devices = drive_group.data_devices.paths if drive_group.data_devices else []
         directories = drive_group.data_directories
 
         assert drive_group.objectstore in ("bluestore", "filestore")
@@ -525,7 +525,7 @@ class RookCluster(object):
 
         if drive_group.hosts(all_hosts)[0] not in [n['name'] for n in current_nodes]:
             pd = { "name": drive_group.hosts(all_hosts)[0],
-                   "config": { "storeType": drive_group.objectstore }}
+                   "config": { "storeType": drive_group.objectstore }}  # type: dict
 
             if block_devices:
                 pd["devices"] = [{'name': d.path} for d in block_devices]
index 138f7d49e387004d899f07f60f2d2011b5a77951..8d4ab95b3d196cee67b4fbb380fe3a98383ebb00 100644 (file)
@@ -113,7 +113,7 @@ class DriveGroupSpecs(object):
     def __init__(self, drive_group_json):
         # type: (dict) -> None
         self.drive_group_json = drive_group_json
-        self.drive_groups = list()  # type: list
+        self.drive_groups = list()  # type: List[DriveGroupSpec]
         self.build_drive_groups()
 
     def build_drive_groups(self):
index 22109c567fc56a00b65b8ba27b36470a69ab28c9..361adf3c36845f828bcef8e4c7f1c5067cf921eb 100644 (file)
@@ -51,9 +51,9 @@ class Device(object):
                  device_id=None,  # type: Optional[str]
                  ):
         self.path = path
-        self.sys_api = sys_api
+        self.sys_api = sys_api if sys_api is not None else {}  # type: Dict[str, Any]
         self.available = available
-        self.rejected_reasons = rejected_reasons
+        self.rejected_reasons = rejected_reasons if rejected_reasons is not None else []
         self.lvs = lvs
         self.device_id = device_id
 
diff --git a/src/python-common/ceph/py.typed b/src/python-common/ceph/py.typed
new file mode 100644 (file)
index 0000000..444b02d
--- /dev/null
@@ -0,0 +1 @@
+# Marker file for PEP 561.  This  package uses inline types.
\ No newline at end of file