diff options
author | Sage Weil <sage@newdream.net> | 2020-01-29 15:51:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 15:51:39 +0100 |
commit | dd1fe6acce4684ab01b586cbcab0c3a8cc0d3e2d (patch) | |
tree | 8b7156404a5894f885446e2eaedff17ad6fbce03 | |
parent | Merge pull request #32893 from sebastian-philipp/orchestrator-document-client... (diff) | |
parent | mgr/cephadm: drop "type: ignore" annotations (diff) | |
download | ceph-dd1fe6acce4684ab01b586cbcab0c3a8cc0d3e2d.tar.xz ceph-dd1fe6acce4684ab01b586cbcab0c3a8cc0d3e2d.zip |
Merge pull request #32957 from tchaikov/wip-mgr-cephadm
mgr/cephadm: init attrs created by settattr()
-rw-r--r-- | src/pybind/mgr/cephadm/module.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index d5a44a00d42..749e171d5b0 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -8,8 +8,9 @@ from functools import wraps import string try: from typing import List, Dict, Optional, Callable, TypeVar, Type, Any + from typing import TYPE_CHECKING except ImportError: - pass # just for type checking + TYPE_CHECKING = False # just for type checking import datetime @@ -331,6 +332,15 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): self.run = True self.event = Event() + # for mypy which does not run the code + if TYPE_CHECKING: + self.ssh_config_file = None # type: Optional[str] + self.inventory_cache_timeout = 0 + self.service_cache_timeout = 0 + self.mode = '' + self.container_image_base = '' + self.warn_on_stray_hosts = True + self.warn_on_stray_services = True self.config_notify() path = self.get_ceph_option('cephadm_path') @@ -723,7 +733,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): ssh_options = [] # type: List[str] # ssh_config - ssh_config_fname = self.ssh_config_file # type: ignore + ssh_config_fname = self.ssh_config_file ssh_config = self.get_store("ssh_config") if ssh_config is not None or ssh_config_fname is None: if not ssh_config: @@ -764,9 +774,9 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): self._ssh_options = None self.log.info('ssh_options %s' % ssh_options) - if self.mode == 'root': # type: ignore + if self.mode == 'root': self.ssh_user = 'root' - elif self.mode == 'cephadm-package': # type: ignore + elif self.mode == 'cephadm-package': self.ssh_user = 'cephadm' @staticmethod @@ -957,7 +967,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): final_args += ['--fsid', self._cluster_fsid] final_args += args - if self.mode == 'root': # type: ignore + if self.mode == 'root': self.log.debug('args: %s' % (' '.join(final_args))) self.log.debug('stdin: %s' % stdin) script = 'injected_argv = ' + json.dumps(final_args) + '\n' @@ -978,7 +988,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): if error_ok: return '', str(e), 1 raise - elif self.mode == 'cephadm-package': # type: ignore + elif self.mode == 'cephadm-package': try: out, err, code = remoto.process.check( conn, @@ -1102,7 +1112,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): keys = [node_name] for host, host_info in self.service_cache.items_filtered(keys): hosts.append(host) - if host_info.outdated(self.service_cache_timeout) or refresh: # type: ignore + if host_info.outdated(self.service_cache_timeout) or refresh: self.log.info("refreshing stale services for '{}'".format(host)) wait_for_args.append((host,)) else: @@ -1243,7 +1253,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): def _get_inventory(host, host_info): # type: (str, orchestrator.OutdatableData) -> orchestrator.InventoryNode - if host_info.outdated(self.inventory_cache_timeout) or refresh: # type: ignore + if host_info.outdated(self.inventory_cache_timeout) or refresh: self.log.info("refresh stale inventory for '{}'".format(host)) out, err, code = self._run_cephadm( host, 'osd', @@ -1875,7 +1885,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): def upgrade_check(self, image, version): if version: - target_name = self.container_image_base + ':v' + version # type: ignore + target_name = self.container_image_base + ':v' + version elif image: target_name = image else: @@ -1920,7 +1930,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): def upgrade_start(self, image, version): if version: - target_name = self.container_image_base + ':v' + version # type: ignore + target_name = self.container_image_base + ':v' + version elif image: target_name = image else: |