mypy: annotate volume manager
This is just a first pass to get things rolling. Change-Id: I67ac3df632a34729646e7b037205327696818a22
This commit is contained in:
parent
ccb6025cd1
commit
698ab86a74
@ -122,7 +122,7 @@ class RequestContext(context.RequestContext):
|
||||
# We need to have RequestContext attributes defined
|
||||
# when policy.check_is_admin invokes request logging
|
||||
# to make it loggable.
|
||||
if self.is_admin is None:
|
||||
if self.is_admin is None: # type: ignore
|
||||
self.is_admin = policy.check_is_admin(self)
|
||||
elif self.is_admin and 'admin' not in self.roles:
|
||||
self.roles.append('admin')
|
||||
|
@ -23,6 +23,7 @@ import shutil
|
||||
import sys
|
||||
import textwrap
|
||||
import time
|
||||
import typing as ty
|
||||
import urllib
|
||||
|
||||
import glanceclient.exc
|
||||
@ -32,6 +33,7 @@ from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from cinder import context
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
from cinder import service_auth
|
||||
@ -651,7 +653,8 @@ def _translate_plain_exception(exc_value):
|
||||
return exc_value
|
||||
|
||||
|
||||
def get_remote_image_service(context, image_href):
|
||||
def get_remote_image_service(context: context.RequestContext,
|
||||
image_href) -> ty.Tuple[GlanceImageService, str]:
|
||||
"""Create an image_service and parse the id from the given image_href.
|
||||
|
||||
The image_href param can be an href of the form
|
||||
|
@ -54,6 +54,7 @@ This module provides Manager, a base class for managers.
|
||||
from eventlet import greenpool
|
||||
from eventlet import tpool
|
||||
from oslo_config import cfg
|
||||
import oslo_config.types
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_service import periodic_task
|
||||
@ -83,16 +84,20 @@ class Manager(base.Base, PeriodicTasks):
|
||||
|
||||
target = messaging.Target(version=RPC_API_VERSION)
|
||||
|
||||
def __init__(self, host=None, db_driver=None, cluster=None, **kwargs):
|
||||
def __init__(self,
|
||||
host: oslo_config.types.HostAddress = None,
|
||||
db_driver=None,
|
||||
cluster=None,
|
||||
**_kwargs):
|
||||
if not host:
|
||||
host = CONF.host
|
||||
self.host = host
|
||||
self.host: oslo_config.types.HostAddress = host
|
||||
self.cluster = cluster
|
||||
self.additional_endpoints = []
|
||||
self.additional_endpoints: list = []
|
||||
self.availability_zone = CONF.storage_availability_zone
|
||||
super(Manager, self).__init__(db_driver)
|
||||
super(Manager, self).__init__(db_driver) # type: ignore
|
||||
|
||||
def _set_tpool_size(self, nthreads):
|
||||
def _set_tpool_size(self, nthreads: int) -> None:
|
||||
# NOTE(geguileo): Until PR #472 is merged we have to be very careful
|
||||
# not to call "tpool.execute" before calling this method.
|
||||
tpool.set_num_threads(nthreads)
|
||||
@ -217,14 +222,14 @@ class SchedulerDependentManager(ThreadPoolManager):
|
||||
|
||||
|
||||
class CleanableManager(object):
|
||||
def do_cleanup(self, context, cleanup_request):
|
||||
def do_cleanup(self, context, cleanup_request) -> None:
|
||||
LOG.info('Initiating service %s cleanup',
|
||||
cleanup_request.service_id)
|
||||
|
||||
# If the 'until' field in the cleanup request is not set, we default to
|
||||
# this very moment.
|
||||
until = cleanup_request.until or timeutils.utcnow()
|
||||
keep_entry = False
|
||||
keep_entry: bool = False
|
||||
|
||||
to_clean = db.worker_get_all(
|
||||
context,
|
||||
@ -300,10 +305,10 @@ class CleanableManager(object):
|
||||
|
||||
LOG.info('Service %s cleanup completed.', cleanup_request.service_id)
|
||||
|
||||
def _do_cleanup(self, ctxt, vo_resource):
|
||||
def _do_cleanup(self, ctxt, vo_resource) -> bool:
|
||||
return False
|
||||
|
||||
def init_host(self, service_id, **kwargs):
|
||||
def init_host(self, service_id, **kwargs) -> None:
|
||||
ctxt = context.get_admin_context()
|
||||
self.service_id = service_id
|
||||
# TODO(geguileo): Once we don't support MySQL 5.5 anymore we can remove
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@
|
||||
|
||||
"""Built-in volume type properties."""
|
||||
|
||||
import typing as ty
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
@ -331,7 +332,9 @@ def get_volume_type_qos_specs(volume_type_id):
|
||||
return res
|
||||
|
||||
|
||||
def volume_types_diff(context, vol_type_id1, vol_type_id2):
|
||||
def volume_types_diff(context: context.RequestContext,
|
||||
vol_type_id1,
|
||||
vol_type_id2) -> ty.Tuple[dict, bool]:
|
||||
"""Returns a 'diff' of two volume types and whether they are equal.
|
||||
|
||||
Returns a tuple of (diff, equal), where 'equal' is a boolean indicating
|
||||
@ -371,7 +374,8 @@ def volume_types_diff(context, vol_type_id1, vol_type_id2):
|
||||
encryption.pop(param, None)
|
||||
return encryption
|
||||
|
||||
def _dict_diff(dict1, dict2):
|
||||
def _dict_diff(dict1: ty.Optional[dict],
|
||||
dict2: ty.Optional[dict]) -> ty.Tuple[dict, bool]:
|
||||
res = {}
|
||||
equal = True
|
||||
if dict1 is None:
|
||||
|
@ -1,3 +1,6 @@
|
||||
cinder/context.py
|
||||
cinder/i18n.py
|
||||
cinder/manager.py
|
||||
cinder/volume/__init__.py
|
||||
cinder/volume/manager.py
|
||||
cinder/volume/volume_types.py
|
||||
|
Loading…
Reference in New Issue
Block a user