From 1f4769dafd5553722545f1f60fe6dc044fd43e09 Mon Sep 17 00:00:00 2001 From: fpxie Date: Mon, 1 Jul 2019 15:10:59 +0800 Subject: [PATCH] Use triple double-quoted strings for docstrings Change-Id: I1bc612866b9fc98be7e702565ba249bda4a54785 Story: 2006136 Task: 35632 --- dcdbsync/common/context.py | 8 ++++---- dcdbsync/db/identity/api.py | 4 ++-- dcmanager/cmd/manage.py | 6 +++--- dcmanager/common/context.py | 10 +++++----- dcmanager/db/api.py | 4 ++-- dcmanager/drivers/base.py | 6 +++--- dcmanager/manager/scheduler.py | 16 ++++++++-------- dcmanager/rpc/client.py | 4 ++-- dcorch/cmd/manage.py | 6 +++--- dcorch/common/context.py | 10 +++++----- dcorch/drivers/base.py | 18 +++++++++--------- dcorch/drivers/openstack/cinder_v2.py | 2 +- dcorch/drivers/openstack/keystone_v3.py | 2 +- dcorch/drivers/openstack/neutron_v2.py | 14 +++++++------- dcorch/drivers/openstack/sdk.py | 4 ++-- dcorch/drivers/openstack/sdk_platform.py | 4 ++-- dcorch/engine/scheduler.py | 20 ++++++++++---------- dcorch/rpc/client.py | 4 ++-- 18 files changed, 71 insertions(+), 71 deletions(-) diff --git a/dcdbsync/common/context.py b/dcdbsync/common/context.py index 632a7d16e..51114c6d0 100644 --- a/dcdbsync/common/context.py +++ b/dcdbsync/common/context.py @@ -28,11 +28,11 @@ ALLOWED_WITHOUT_AUTH = '/' class RequestContext(base_context.RequestContext): - '''Stores information about the security context. + """Stores information about the security context. The context encapsulates information related to the user accessing the the system, as well as additional request information. - ''' + """ def __init__(self, auth_token=None, user=None, project=None, domain=None, user_domain=None, project_domain=None, @@ -43,7 +43,7 @@ class RequestContext(base_context.RequestContext): auth_token_info=None, region_name=None, roles=None, password=None, **kwargs): - '''Initializer of request context.''' + # Initializer of request context. # We still have 'tenant' param because oslo_context still use it. super(RequestContext, self).__init__( auth_token=auth_token, user=user, tenant=project, @@ -123,7 +123,7 @@ def get_admin_context(show_deleted=False): def get_service_context(**args): - '''An abstraction layer for getting service context.''' + """An abstraction layer for getting service context.""" pass diff --git a/dcdbsync/db/identity/api.py b/dcdbsync/db/identity/api.py index 55ebc44be..6e1c3fd41 100644 --- a/dcdbsync/db/identity/api.py +++ b/dcdbsync/db/identity/api.py @@ -18,11 +18,11 @@ # SPDX-License-Identifier: Apache-2.0 # -''' +""" Interface for database access. SQLAlchemy is currently the only supported backend. -''' +""" from oslo_config import cfg from oslo_db import api diff --git a/dcmanager/cmd/manage.py b/dcmanager/cmd/manage.py index cd0adad78..c3fea9125 100644 --- a/dcmanager/cmd/manage.py +++ b/dcmanager/cmd/manage.py @@ -35,15 +35,15 @@ CONF = cfg.CONF def do_db_version(): - '''Print database's current migration level.''' + """Print database's current migration level.""" print(api.db_version(api.get_engine())) def do_db_sync(): - '''Place a database under migration control and upgrade. + """Place a database under migration control and upgrade. DB is created first if necessary. - ''' + """ api.db_sync(api.get_engine(), CONF.command.version) diff --git a/dcmanager/common/context.py b/dcmanager/common/context.py index 40abec1b5..aace44db1 100644 --- a/dcmanager/common/context.py +++ b/dcmanager/common/context.py @@ -30,11 +30,11 @@ ALLOWED_WITHOUT_AUTH = '/' class RequestContext(base_context.RequestContext): - '''Stores information about the security context. + """Stores information about the security context. The context encapsulates information related to the user accessing the the system, as well as additional request information. - ''' + """ def __init__(self, auth_token=None, user=None, project=None, domain=None, user_domain=None, project_domain=None, @@ -45,7 +45,7 @@ class RequestContext(base_context.RequestContext): auth_token_info=None, region_name=None, roles=None, password=None, **kwargs): - '''Initializer of request context.''' + """Initializer of request context.""" # We still have 'tenant' param because oslo_context still use it. super(RequestContext, self).__init__( auth_token=auth_token, user=user, tenant=project, @@ -125,14 +125,14 @@ def get_admin_context(show_deleted=False): def get_service_context(**args): - '''An abstraction layer for getting service context. + """An abstraction layer for getting service context. There could be multiple cloud backends for dcmanager to use. This abstraction layer provides an indirection for dcmanager to get the credentials of 'dcmanager' user on the specific cloud. By default, this credential refers to the credentials built for dcmanager middleware in an OpenStack cloud. - ''' + """ pass diff --git a/dcmanager/db/api.py b/dcmanager/db/api.py index a50bedde0..287bd6238 100644 --- a/dcmanager/db/api.py +++ b/dcmanager/db/api.py @@ -19,11 +19,11 @@ # of this software may be licensed only pursuant to the terms # of an applicable Wind River license agreement. # -''' +""" Interface for database access. SQLAlchemy is currently the only supported backend. -''' +""" from oslo_config import cfg from oslo_db import api diff --git a/dcmanager/drivers/base.py b/dcmanager/drivers/base.py index 21607ccbd..f6b501e1d 100644 --- a/dcmanager/drivers/base.py +++ b/dcmanager/drivers/base.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" Base class for all drivers. -''' +""" import abc import six @@ -25,7 +25,7 @@ LOG = logging.getLogger(__name__) class DriverBase(object): six.add_metaclass(abc.ABCMeta) - '''Base class for all drivers.''' + """Base class for all drivers.""" def __init__(self, context): self.context = context diff --git a/dcmanager/manager/scheduler.py b/dcmanager/manager/scheduler.py index 2a4810e25..4ed967099 100644 --- a/dcmanager/manager/scheduler.py +++ b/dcmanager/manager/scheduler.py @@ -30,7 +30,7 @@ wallclock = time.time class ThreadGroupManager(object): - '''Thread group manager.''' + """Thread group manager.""" def __init__(self): super(ThreadGroupManager, self).__init__() @@ -38,15 +38,15 @@ class ThreadGroupManager(object): self.group = threadgroup.ThreadGroup() def start(self, func, *args, **kwargs): - '''Run the given method in a sub-thread.''' + """Run the given method in a sub-thread.""" return self.group.add_thread(func, *args, **kwargs) def add_timer(self, interval, func, *args, **kwargs): - '''Define a periodic task to be run in the thread group. + """Define a periodic task to be run in the thread group. The task will be executed in a separate green thread. - ''' + """ self.group.add_timer(interval, func, *args, **kwargs) @@ -54,7 +54,7 @@ class ThreadGroupManager(object): self.group.stop_timers() def stop(self, graceful=False): - '''Stop any active threads belong to this threadgroup.''' + """Stop any active threads belong to this threadgroup.""" # Try to stop all threads gracefully self.group.stop(graceful) self.group.wait() @@ -74,10 +74,10 @@ class ThreadGroupManager(object): def reschedule(action, sleep_time=1): - '''Eventlet Sleep for the specified number of seconds. + """Eventlet Sleep for the specified number of seconds. :param sleep_time: seconds to sleep; if None, no sleep; - ''' + """ if sleep_time is not None: LOG.debug('Action %s sleep for %s seconds' % ( @@ -86,6 +86,6 @@ def reschedule(action, sleep_time=1): def sleep(sleep_time): - '''Interface for sleeping.''' + """Interface for sleeping.""" eventlet.sleep(sleep_time) diff --git a/dcmanager/rpc/client.py b/dcmanager/rpc/client.py index 08341bbb5..beebe02a3 100644 --- a/dcmanager/rpc/client.py +++ b/dcmanager/rpc/client.py @@ -17,9 +17,9 @@ # of an applicable Wind River license agreement. # -''' +""" Client side of the DC Manager RPC API. -''' +""" from oslo_log import log as logging diff --git a/dcorch/cmd/manage.py b/dcorch/cmd/manage.py index e389f3dc9..6ff178d63 100644 --- a/dcorch/cmd/manage.py +++ b/dcorch/cmd/manage.py @@ -28,15 +28,15 @@ CONF = cfg.CONF def do_db_version(): - '''Print database's current migration level.''' + """Print database's current migration level.""" print(api.db_version(api.get_engine())) def do_db_sync(): - '''Place a database under migration control and upgrade. + """Place a database under migration control and upgrade. DB is created first if necessary. - ''' + """ api.db_sync(api.get_engine(), CONF.command.version) diff --git a/dcorch/common/context.py b/dcorch/common/context.py index 2b30ba125..67d50c2d6 100644 --- a/dcorch/common/context.py +++ b/dcorch/common/context.py @@ -23,11 +23,11 @@ ALLOWED_WITHOUT_AUTH = '/' class RequestContext(base_context.RequestContext): - '''Stores information about the security context. + """Stores information about the security context. The context encapsulates information related to the user accessing the the system, as well as additional request information. - ''' + """ def __init__(self, auth_token=None, user=None, project=None, domain=None, user_domain=None, project_domain=None, @@ -38,7 +38,7 @@ class RequestContext(base_context.RequestContext): auth_token_info=None, region_name=None, roles=None, password=None, **kwargs): - '''Initializer of request context.''' + """Initializer of request context.""" # We still have 'tenant' param because oslo_context still use it. super(RequestContext, self).__init__( auth_token=auth_token, user=user, tenant=project, @@ -118,14 +118,14 @@ def get_admin_context(show_deleted=False): def get_service_context(**args): - '''An abstraction layer for getting service context. + """An abstraction layer for getting service context. There could be multiple cloud backends for dcorch-engine to use. This abstraction layer provides an indirection for dcorch-engine to get the credentials of 'dcorch' user on the specific cloud. By default, this credential refers to the credentials built for keystone middleware in an OpenStack cloud. - ''' + """ pass diff --git a/dcorch/drivers/base.py b/dcorch/drivers/base.py index 37ac06b19..a91962f56 100644 --- a/dcorch/drivers/base.py +++ b/dcorch/drivers/base.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" Base class for all drivers. -''' +""" import abc import six @@ -25,31 +25,31 @@ LOG = logging.getLogger(__name__) class DriverBase(object): six.add_metaclass(abc.ABCMeta) - '''Base class for all drivers.''' + """Base class for all drivers.""" def __init__(self, context): self.context = context @abc.abstractmethod def get_resource_usages(self, project_id): - '''Collects resource usages for a given project + """Collects resource usages for a given project :params: project_id :return: dictionary of corresponding resources with its usage - ''' + """ @abc.abstractmethod def update_quota_limits(self, project_id, new_quota): - '''Updates quota limits for a given project + """Updates quota limits for a given project :params: project_id, dictionary with the quota limits to update :return: Nothing - ''' + """ @abc.abstractmethod def delete_quota_limits(self, project_id): - '''Delete quota limits for a given project + """Delete quota limits for a given project :params: project_id :return: Nothing - ''' + """ diff --git a/dcorch/drivers/openstack/cinder_v2.py b/dcorch/drivers/openstack/cinder_v2.py index e74c20ff4..6638e6c54 100644 --- a/dcorch/drivers/openstack/cinder_v2.py +++ b/dcorch/drivers/openstack/cinder_v2.py @@ -23,7 +23,7 @@ API_VERSION = '2' class CinderClient(base.DriverBase): - '''Cinder V2 driver.''' + """Cinder V2 driver.""" def __init__(self, region, disabled_quotas, session, endpoint_type): try: diff --git a/dcorch/drivers/openstack/keystone_v3.py b/dcorch/drivers/openstack/keystone_v3.py index 0bc0932ba..1204c3d9c 100644 --- a/dcorch/drivers/openstack/keystone_v3.py +++ b/dcorch/drivers/openstack/keystone_v3.py @@ -26,7 +26,7 @@ importutils.import_module('keystonemiddleware.auth_token') class KeystoneClient(base.DriverBase): - '''Keystone V3 driver.''' + """Keystone V3 driver.""" def __init__(self, region_name=None, auth_url=None): try: diff --git a/dcorch/drivers/openstack/neutron_v2.py b/dcorch/drivers/openstack/neutron_v2.py index df2a0cd34..a69440d36 100644 --- a/dcorch/drivers/openstack/neutron_v2.py +++ b/dcorch/drivers/openstack/neutron_v2.py @@ -24,7 +24,7 @@ API_VERSION = '2.0' class NeutronClient(base.DriverBase): - '''Neutron V2 driver.''' + """Neutron V2 driver.""" def __init__(self, region, disabled_quotas, session, endpoint_type): try: self.neutron = client.Client( @@ -42,11 +42,11 @@ class NeutronClient(base.DriverBase): raise def get_resource_usages(self, project_id): - '''Calcualte resources usage and return the dict + """Calcualte resources usage and return the dict :param: project_id :return: resource usage dict - ''' + """ if not self.no_network: try: usages = defaultdict(dict) @@ -95,10 +95,10 @@ class NeutronClient(base.DriverBase): raise def get_quota_limits(self, project_id): - '''Get the limits + """Get the limits TODO: support the rest of the limits - ''' + """ try: resource_limit = {} if not self.no_network: @@ -109,7 +109,7 @@ class NeutronClient(base.DriverBase): raise def update_quota_limits(self, project_id, new_quota): - '''Update the limits''' + """Update the limits""" try: if not self.no_network: return self.neutron.update_quota(project_id, @@ -118,7 +118,7 @@ class NeutronClient(base.DriverBase): raise def delete_quota_limits(self, project_id): - '''Delete/Reset the limits''' + """Delete/Reset the limits""" try: if not self.no_network: return self.neutron.delete_quota(project_id) diff --git a/dcorch/drivers/openstack/sdk.py b/dcorch/drivers/openstack/sdk.py index fc896fd99..054c87d43 100644 --- a/dcorch/drivers/openstack/sdk.py +++ b/dcorch/drivers/openstack/sdk.py @@ -12,9 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" OpenStack Driver -''' +""" import collections from oslo_concurrency import lockutils diff --git a/dcorch/drivers/openstack/sdk_platform.py b/dcorch/drivers/openstack/sdk_platform.py index b17330344..623659e97 100644 --- a/dcorch/drivers/openstack/sdk_platform.py +++ b/dcorch/drivers/openstack/sdk_platform.py @@ -12,9 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" OpenStack Driver -''' +""" import collections from oslo_concurrency import lockutils diff --git a/dcorch/engine/scheduler.py b/dcorch/engine/scheduler.py index 058d2e134..2b0033521 100644 --- a/dcorch/engine/scheduler.py +++ b/dcorch/engine/scheduler.py @@ -24,7 +24,7 @@ wallclock = time.time class ThreadGroupManager(object): - '''Thread group manager.''' + """Thread group manager.""" def __init__(self): super(ThreadGroupManager, self).__init__() @@ -37,7 +37,7 @@ class ThreadGroupManager(object): self._service_task) def _service_task(self): - '''Dummy task which gets queued on the service.Service threadgroup. + """Dummy task which gets queued on the service.Service threadgroup. Without this service.Service sees nothing running i.e has nothing to wait() on, so the process exits.. @@ -45,21 +45,21 @@ class ThreadGroupManager(object): housekeeping tasks (Yanyan)Not sure this is still necessary, just keep it temporarily. - ''' + """ # TODO(Yanyan): have this task call dbapi purge events pass def start(self, func, *args, **kwargs): - '''Run the given method in a sub-thread.''' + """Run the given method in a sub-thread.""" return self.group.add_thread(func, *args, **kwargs) def add_timer(self, interval, func, *args, **kwargs): - '''Define a periodic task to be run in the thread group. + """Define a periodic task to be run in the thread group. The task will be executed in a separate green thread. Interval is from cfg.CONF.periodic_interval - ''' + """ self.group.add_timer(interval, func, *args, **kwargs) @@ -67,7 +67,7 @@ class ThreadGroupManager(object): self.group.stop_timers() def stop(self, graceful=False): - '''Stop any active threads belong to this threadgroup.''' + """Stop any active threads belong to this threadgroup.""" # Try to stop all threads gracefully self.group.stop(graceful) self.group.wait() @@ -87,10 +87,10 @@ class ThreadGroupManager(object): def reschedule(action, sleep_time=1): - '''Eventlet Sleep for the specified number of seconds. + """Eventlet Sleep for the specified number of seconds. :param sleep_time: seconds to sleep; if None, no sleep; - ''' + """ if sleep_time is not None: LOG.debug('Action %s sleep for %s seconds' % ( @@ -99,6 +99,6 @@ def reschedule(action, sleep_time=1): def sleep(sleep_time): - '''Interface for sleeping.''' + """Interface for sleeping.""" eventlet.sleep(sleep_time) diff --git a/dcorch/rpc/client.py b/dcorch/rpc/client.py index 97e0a65fd..3db1ffa58 100644 --- a/dcorch/rpc/client.py +++ b/dcorch/rpc/client.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -''' +""" Client side of the DC Orchestrator RPC API. -''' +""" from oslo_log import log as logging