From: Sebastian Wagner Date: Tue, 25 Aug 2020 13:29:36 +0000 (+0200) Subject: mgr/cephadm: PEP8tify inventory.py X-Git-Tag: v16.1.0~1297^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fef1151a62dedc7edc34fd9887aa59a94d9c9c7f;p=ceph.git mgr/cephadm: PEP8tify inventory.py Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/inventory.py b/src/pybind/mgr/cephadm/inventory.py index 4b0154e75a56..4b5fc0f5398c 100644 --- a/src/pybind/mgr/cephadm/inventory.py +++ b/src/pybind/mgr/cephadm/inventory.py @@ -88,11 +88,11 @@ class Inventory: def spec_from_dict(self, info): hostname = info['hostname'] return HostSpec( - hostname, - addr=info.get('addr', hostname), - labels=info.get('labels', []), - status='Offline' if hostname in self.mgr.offline_hosts else info.get('status', ''), - ) + hostname, + addr=info.get('addr', hostname), + labels=info.get('labels', []), + status='Offline' if hostname in self.mgr.offline_hosts else info.get('status', ''), + ) def all_specs(self) -> Iterator[HostSpec]: return map(self.spec_from_dict, self._inventory.values()) @@ -105,9 +105,9 @@ class SpecStore(): def __init__(self, mgr): # type: (CephadmOrchestrator) -> None self.mgr = mgr - self.specs = {} # type: Dict[str, ServiceSpec] - self.spec_created = {} # type: Dict[str, datetime.datetime] - self.spec_preview = {} # type: Dict[str, ServiceSpec] + self.specs = {} # type: Dict[str, ServiceSpec] + self.spec_created = {} # type: Dict[str, datetime.datetime] + self.spec_preview = {} # type: Dict[str, ServiceSpec] def load(self): # type: () -> None @@ -162,6 +162,7 @@ class SpecStore(): service_name, specs)) return specs + class HostCache(): def __init__(self, mgr): # type: (CephadmOrchestrator) -> None @@ -172,9 +173,9 @@ class HostCache(): self.osdspec_previews = {} # type: Dict[str, List[Dict[str, Any]]] self.networks = {} # type: Dict[str, Dict[str, List[str]]] self.last_device_update = {} # type: Dict[str, datetime.datetime] - self.daemon_refresh_queue = [] # type: List[str] - self.device_refresh_queue = [] # type: List[str] - self.osdspec_previews_refresh_queue = [] # type: List[str] + self.daemon_refresh_queue = [] # type: List[str] + self.device_refresh_queue = [] # type: List[str] + self.osdspec_previews_refresh_queue = [] # type: List[str] # host -> daemon name -> dict self.daemon_config_deps = {} # type: Dict[str, Dict[str, Dict[str,Any]]] @@ -286,7 +287,7 @@ class HostCache(): if host in self.last_device_update: del self.last_device_update[host] self.mgr.event.set() - + def distribute_new_registry_login_info(self): self.registry_login_queue = set(self.mgr.inventory.keys()) @@ -299,9 +300,11 @@ class HostCache(): 'daemon_config_deps': {}, } if host in self.last_daemon_update: - j['last_daemon_update'] = self.last_daemon_update[host].strftime(DATEFMT) # type: ignore + j['last_daemon_update'] = self.last_daemon_update[host].strftime( + DATEFMT) # type: ignore if host in self.last_device_update: - j['last_device_update'] = self.last_device_update[host].strftime(DATEFMT) # type: ignore + j['last_device_update'] = self.last_device_update[host].strftime( + DATEFMT) # type: ignore for name, dd in self.daemons[host].items(): j['daemons'][name] = dd.to_json() # type: ignore for d in self.devices[host]: @@ -470,7 +473,7 @@ class HostCache(): return True # already up to date: return False - + def update_last_etc_ceph_ceph_conf(self, host: str): if not self.mgr.last_monmap: return @@ -510,7 +513,7 @@ class EventStore(): def __init__(self, mgr): # type: (CephadmOrchestrator) -> None self.mgr: CephadmOrchestrator = mgr - self.events = {} # type: Dict[str, List[OrchestratorEvent]] + self.events = {} # type: Dict[str, List[OrchestratorEvent]] def add(self, event: OrchestratorEvent) -> None: @@ -527,7 +530,8 @@ class EventStore(): self.events[event.kind_subject()] = self.events[event.kind_subject()][-5:] def for_service(self, spec: ServiceSpec, level, message) -> None: - e = OrchestratorEvent(datetime.datetime.utcnow(), 'service', spec.service_name(), level, message) + e = OrchestratorEvent(datetime.datetime.utcnow(), 'service', + spec.service_name(), level, message) self.add(e) def from_orch_error(self, e: OrchestratorError): @@ -540,7 +544,6 @@ class EventStore(): str(e) )) - def for_daemon(self, daemon_name, level, message): e = OrchestratorEvent(datetime.datetime.utcnow(), 'daemon', daemon_name, level, message) self.add(e)