From 7077cb1ba58c3adcc1af00817c4420d1dee0958c Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 8 Jul 2019 10:37:51 +0200 Subject: [PATCH] python-common: Fix imports Signed-off-by: Sebastian Wagner --- src/pybind/mgr/ansible/module.py | 2 +- src/pybind/mgr/orchestrator.py | 1 + src/pybind/mgr/orchestrator_cli/module.py | 12 +++++++----- src/pybind/mgr/orchestrator_cli/test_orchestrator.py | 4 ++-- src/pybind/mgr/rook/module.py | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pybind/mgr/ansible/module.py b/src/pybind/mgr/ansible/module.py index 3fe83eab208f8..7711028e676fb 100644 --- a/src/pybind/mgr/ansible/module.py +++ b/src/pybind/mgr/ansible/module.py @@ -559,7 +559,7 @@ class Module(MgrModule, orchestrator.Orchestrator): If no host provided the operation affects all the host in the OSDS role - :param drive_group: (orchestrator.DriveGroupSpec), + :param drive_group: (ceph.deployment.drive_group.DriveGroupSpec), Drive group with the specification of drives to use :param all_hosts : (List[str]), List of hosts where the OSD's must be created diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 1e20cce4a8167..fe867f15601f3 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -18,6 +18,7 @@ from mgr_module import MgrModule, PersistentStoreDict from mgr_util import format_bytes try: + from ceph.deployment.drive_group import DriveGroupSpec from typing import TypeVar, Generic, List, Optional, Union, Tuple, Iterator T = TypeVar('T') diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 7583c5a52a0d6..a02912fc084ff 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -8,7 +8,9 @@ except ImportError: from functools import wraps -from mgr_module import MgrModule, HandleCommandResult, CLICommand +from ceph.deployment.drive_group import DriveGroupSpec, DriveGroupValidationError, \ + DeviceSelection +from mgr_module import MgrModule, CLICommand, HandleCommandResult import orchestrator @@ -170,7 +172,7 @@ Usage: if inbuf: try: - drive_group = orchestrator.DriveGroupSpec.from_json(json.loads(inbuf)) + drive_group = DriveGroupSpec.from_json(json.loads(inbuf)) except ValueError as e: msg = 'Failed to read JSON input: {}'.format(str(e)) + usage return HandleCommandResult(-errno.EINVAL, stderr=msg) @@ -183,8 +185,8 @@ Usage: msg = "Invalid host:device spec: '{}'".format(svc_arg) + usage return HandleCommandResult(-errno.EINVAL, stderr=msg) - devs = orchestrator.DeviceSelection(paths=block_devices) - drive_group = orchestrator.DriveGroupSpec(node_name, data_devices=devs) + devs = DeviceSelection(paths=block_devices) + drive_group = DriveGroupSpec(node_name, data_devices=devs) else: return HandleCommandResult(-errno.EINVAL, stderr=usage) @@ -197,7 +199,7 @@ Usage: try: drive_group.validate(all_hosts) - except orchestrator.DriveGroupValidationError as e: + except DriveGroupValidationError as e: return HandleCommandResult(-errno.EINVAL, stderr=str(e)) completion = self.create_osds(drive_group, all_hosts) diff --git a/src/pybind/mgr/orchestrator_cli/test_orchestrator.py b/src/pybind/mgr/orchestrator_cli/test_orchestrator.py index 834cd4d7c56c0..3374d5a3ca512 100644 --- a/src/pybind/mgr/orchestrator_cli/test_orchestrator.py +++ b/src/pybind/mgr/orchestrator_cli/test_orchestrator.py @@ -2,8 +2,8 @@ from __future__ import absolute_import import pytest -from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError, \ - InventoryDevice, ReadCompletion, raise_if_exception +from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection, DriveGroupValidationError +from orchestrator import InventoryDevice, ReadCompletion, raise_if_exception def test_DriveGroup(): diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 37d7bbb8d02b5..51c9bd1e1d164 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -4,6 +4,7 @@ import os import uuid try: from typing import List + from ceph.deployment.drive_group import DriveGroupSpec except ImportError: pass # just for type checking @@ -412,7 +413,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): "Updating NFS server count in {0} to {1}".format(spec.name, num)) def create_osds(self, drive_group, all_hosts): - # type: (orchestrator.DriveGroupSpec, List[str]) -> RookWriteCompletion + # type: (DriveGroupSpec, List[str]) -> RookWriteCompletion assert len(drive_group.hosts(all_hosts)) == 1 targets = [] -- 2.39.5