try:
from ceph.deployment.drive_group import DriveGroupSpec
- from typing import TypeVar, Generic, List, Optional, Union, Tuple, Iterator, Callable, Any, Type
+ from typing import TypeVar, Generic, List, Optional, Union, Tuple, Iterator, Callable, Any, \
+ Type, Sequence
except ImportError:
pass
def pretty_print(completions):
- # type: (List[Completion]) -> str
+ # type: (Sequence[Completion]) -> str
return ', '.join(c.pretty_print() for c in completions)
mock; python_version <= '3.3'
ipaddress; python_version < '3.3'
../../python-common
+kubernetes
from ceph.deployment import inventory
try:
- from typing import List, Dict, Optional, Callable, TypeVar
+ from typing import List, Dict, Optional, Callable, Any
from ceph.deployment.drive_group import DriveGroupSpec
except ImportError:
pass # just for type checking
MODULE_OPTIONS = [
# TODO: configure k8s API addr instead of assuming local
- ]
+ ] # type: List[Dict[str, Any]]
def process(self, completions):
# type: (List[RookCompletion]) -> None
@property
def k8s(self):
+ # type: () -> client.CoreV1Api
self._initialized.wait()
+ assert self._k8s is not None
return self._k8s
@property
def rook_cluster(self):
# type: () -> RookCluster
self._initialized.wait()
+ assert self._rook_cluster is not None
return self._rook_cluster
def serve(self):
def update_mds(self, spec):
num = spec.count
- return RookWriteCompletion(
- lambda: self.rook_cluster.update_mds_count(spec.name, num), None,
- "Updating MDS server count in {0} to {1}".format(spec.name, num))
+ return write_completion(
+ lambda: self.rook_cluster.update_mds_count(spec.name, num),
+ "Updating MDS server count in {0} to {1}".format(spec.name, num),
+ mgr=self
+ )
def update_nfs(self, spec):
num = spec.count
def has_osds(all_hosts):
# Find OSD pods on this host
pod_osd_ids = set()
- pods = self._k8s.list_namespaced_pod(self._rook_env.namespace,
+ pods = self.k8s.list_namespaced_pod(self._rook_env.namespace,
label_selector="rook_cluster={},app=rook-ceph-osd".format(self._rook_env.cluster_name),
field_selector="spec.nodeName={0}".format(
drive_group.hosts(all_hosts)[0]
from mgr_util import merge_dicts
+try:
+ from typing import Optional
+except ImportError:
+ pass # just for type annotations
+
try:
from kubernetes.client.rest import ApiException
from kubernetes.client import V1ListMeta, CoreV1Api, V1Pod
from kubernetes import watch
except ImportError:
- class ApiException(Exception): pass
+ class ApiException(Exception): # type: ignore
+ status = 0
import orchestrator
# ``_items`` is accessed by different threads. I assume assignment is atomic.
self._items = dict()
- self.thread = None # type: threading.Thread
+ self.thread = None # type: Optional[threading.Thread]
self.exception = None
if not _urllib3_supports_read_chunked:
logging.info('urllib3 is too old. Fallback to full fetches')
if _urllib3_supports_read_chunked:
# Start a thread which will use the kubernetes watch client against a resource
log.debug("Attaching resource watcher for k8s {}".format(self.api_func))
- self.thread = self._watch(resource_version) # type: threading.Thread
+ self.thread = self._watch(resource_version)
return self._items.values()
}
if spec.namespace:
- rook_nfsgw["spec"]["rados"]["namespace"] = spec.namespace
+ rook_nfsgw["spec"]["rados"]["namespace"] = spec.namespace # type: ignore
with self.ignore_409("NFS cluster '{0}' already exists".format(spec.name)):
self.rook_api_post("cephnfses/", body=rook_nfsgw)
if directories:
pd["directories"] = [{'path': p} for p in directories]
- patch.append({ "op": "add", "path": "/spec/storage/nodes/-", "value": pd })
+ patch.append({ "op": "add", "path": "/spec/storage/nodes/-", "value": pd }) # type: ignore
else:
# Extend existing node
node_idx = None
patch.append({
"op": "add",
"path": "/spec/storage/nodes/{0}/devices/-".format(node_idx),
- "value": {'name': n}
+ "value": {'name': n} # type: ignore
})
new_dirs = list(set(directories) - set(current_node['directories']))
patch.append({
"op": "add",
"path": "/spec/storage/nodes/{0}/directories/-".format(node_idx),
- "value": {'path': p}
+ "value": {'path': p} # type: ignore
})
if len(patch) == 0:
deps =
-r requirements.txt
mypy
-commands = mypy --config-file=../../mypy.ini orchestrator.py ssh/module.py
\ No newline at end of file
+commands = mypy --config-file=../../mypy.ini orchestrator.py ssh/module.py rook/module.py
\ No newline at end of file