Merge "Apply pyupgrade"

This commit is contained in:
Zuul
2025-10-07 08:29:46 +00:00
committed by Gerrit Code Review
350 changed files with 766 additions and 1045 deletions

View File

@@ -39,8 +39,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Infrastructure Optimization API Reference'
copyright = u'2010-present, OpenStack Foundation'
project = 'Infrastructure Optimization API Reference'
copyright = '2010-present, OpenStack Foundation'
# openstackdocstheme options
openstackdocs_repo_name = 'openstack/watcher'
@@ -70,6 +70,6 @@ html_theme_options = {
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index', 'Watcher.tex', u'Infrastructure Optimization API Reference',
u'OpenStack Foundation', 'manual'),
('index', 'Watcher.tex', 'Infrastructure Optimization API Reference',
'OpenStack Foundation', 'manual'),
]

View File

@@ -27,7 +27,7 @@ class BaseWatcherDirective(rst.Directive):
def __init__(self, name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
super(BaseWatcherDirective, self).__init__(
super().__init__(
name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine)
self.result = statemachine.ViewList()

View File

@@ -112,7 +112,7 @@ jQuery(document).ready(function(){
col = nodes.entry()
row.append(col)
with open(self.SAMPLE_ROOT + sample_file, 'r') as f:
with open(self.SAMPLE_ROOT + sample_file) as f:
sample_content = f.read()
event_type = sample_file[0: -5]

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
# Copyright (c) 2016 Intel Corp

View File

@@ -1,5 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright © 2012 New Dream Network, LLC (DreamHost)
# All Rights Reserved.
# Copyright (c) 2016 Intel Corp
@@ -70,7 +68,7 @@ def _wrap_app(app):
return app
class VersionSelectorApplication(object):
class VersionSelectorApplication:
def __init__(self):
pc = get_pecan_config()
self.v1 = setup_app(config=pc)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -35,10 +34,10 @@ class APIBase(wtypes.Base):
def as_dict(self):
"""Render this object as a dict of its fields."""
return dict((k, getattr(self, k))
for k in self.fields
if hasattr(self, k) and
getattr(self, k) != wsme.Unset)
return {k: getattr(self, k)
for k in self.fields
if hasattr(self, k) and
getattr(self, k) != wsme.Unset}
def unset_fields_except(self, except_list=None):
"""Unset fields so they don't appear in the message body.
@@ -55,7 +54,7 @@ class APIBase(wtypes.Base):
@functools.total_ordering
class Version(object):
class Version:
"""API Version object."""
string = 'OpenStack-API-Version'

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
@@ -26,7 +25,7 @@ from watcher.api.controllers import link
from watcher.api.controllers import v1
class APIStatus(object):
class APIStatus:
CURRENT = "CURRENT"
SUPPORTED = "SUPPORTED"
DEPRECATED = "DEPRECATED"
@@ -118,4 +117,5 @@ class RootController(rest.RestController):
if args[0] and args[0] not in self._versions:
args = [self._default_version] + args
return super(RootController, self)._route(args, request)
return super()._route(args, request)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -72,10 +71,10 @@ class APIBase(wtypes.Base):
def as_dict(self):
"""Render this object as a dict of its fields."""
return dict((k, getattr(self, k))
for k in self.fields
if hasattr(self, k) and
getattr(self, k) != wsme.Unset)
return {k: getattr(self, k)
for k in self.fields
if hasattr(self, k) and
getattr(self, k) != wsme.Unset}
def unset_fields_except(self, except_list=None):
"""Unset fields so they don't appear in the message body.
@@ -282,7 +281,7 @@ class Controller(rest.RestController):
' '.join([versions.service_type_string(), str(v)]))
pecan.request.version = v
return super(Controller, self)._route(args, request)
return super()._route(args, request)
__all__ = ("Controller", )

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@@ -173,7 +172,7 @@ class Action(base.APIBase):
"""Status message"""
def __init__(self, **kwargs):
super(Action, self).__init__()
super().__init__()
self.fields = []
fields = list(objects.Action.fields)
@@ -263,7 +262,7 @@ class ActionsController(rest.RestController):
"""REST controller for Actions."""
def __init__(self):
super(ActionsController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@@ -253,7 +252,7 @@ class ActionPlan(base.APIBase):
"""Status message of the action plan"""
def __init__(self, **kwargs):
super(ActionPlan, self).__init__()
super().__init__()
self.fields = []
fields = list(objects.ActionPlan.fields)
for field in fields:
@@ -342,7 +341,7 @@ class ActionPlansController(rest.RestController):
"""REST controller for Actions."""
def __init__(self):
super(ActionPlansController, self).__init__()
super().__init__()
self.applier_client = rpcapi.ApplierAPI()
_custom_actions = {

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@@ -162,7 +161,7 @@ class AuditPostType(wtypes.Base):
'strategy': 'strategy_id',
'scope': 'scope',
}
to_string_fields = set(['goal', 'strategy'])
to_string_fields = {'goal', 'strategy'}
for k in at2a:
if not getattr(self, k):
try:
@@ -466,7 +465,7 @@ class AuditCollection(collection.Collection):
"""A list containing audits objects"""
def __init__(self, **kwargs):
super(AuditCollection, self).__init__()
super().__init__()
self._type = 'audits'
@staticmethod
@@ -489,7 +488,7 @@ class AuditsController(rest.RestController):
"""REST controller for Audits."""
def __init__(self):
super(AuditsController, self).__init__()
super().__init__()
self.dc_client = rpcapi.DecisionEngineAPI()
_custom_actions = {

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@@ -376,7 +375,7 @@ class AuditTemplate(base.APIBase):
"""Audit Scope"""
def __init__(self, **kwargs):
super(AuditTemplate, self).__init__()
super().__init__()
self.fields = []
fields = list(objects.AuditTemplate.fields)
@@ -453,7 +452,7 @@ class AuditTemplateCollection(collection.Collection):
"""A list containing audit templates objects"""
def __init__(self, **kwargs):
super(AuditTemplateCollection, self).__init__()
super().__init__()
self._type = 'audit_templates'
@staticmethod
@@ -477,7 +476,7 @@ class AuditTemplatesController(rest.RestController):
"""REST controller for AuditTemplates."""
def __init__(self):
super(AuditTemplatesController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 ZTE Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,7 +49,7 @@ class DataModelController(rest.RestController):
"""REST controller for data model"""
def __init__(self):
super(DataModelController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(wtypes.text, wtypes.text, types.uuid)
def get_all(self, data_model_type='compute', audit_uuid=None):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -60,7 +59,7 @@ class EfficacyIndicator(base.APIBase):
"""Value of this efficacy indicator"""
def __init__(self, **kwargs):
super(EfficacyIndicator, self).__init__()
super().__init__()
self.fields = []
fields = list(objects.EfficacyIndicator.fields)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
#
@@ -131,7 +130,7 @@ class GoalCollection(collection.Collection):
"""A list containing goals objects"""
def __init__(self, **kwargs):
super(GoalCollection, self).__init__()
super().__init__()
self._type = 'goals'
@staticmethod
@@ -155,7 +154,7 @@ class GoalsController(rest.RestController):
"""REST controller for Goals."""
def __init__(self):
super(GoalsController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright 2016 Intel
# All Rights Reserved.
#
@@ -76,7 +75,7 @@ class ScoringEngine(base.APIBase):
"""A list containing a self link and associated action links"""
def __init__(self, **kwargs):
super(ScoringEngine, self).__init__()
super().__init__()
self.fields = []
self.fields.append('uuid')
@@ -123,7 +122,7 @@ class ScoringEngineCollection(collection.Collection):
"""A list containing scoring engine objects"""
def __init__(self, **kwargs):
super(ScoringEngineCollection, self).__init__()
super().__init__()
self._type = 'scoring_engines'
@staticmethod
@@ -147,7 +146,7 @@ class ScoringEngineController(rest.RestController):
"""REST controller for Scoring Engines."""
def __init__(self):
super(ScoringEngineController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Servionica
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -109,7 +108,7 @@ class Service(base.APIBase):
"""A list containing a self link."""
def __init__(self, **kwargs):
super(Service, self).__init__()
super().__init__()
fields = list(objects.Service.fields) + ['status']
self.fields = []
@@ -153,7 +152,7 @@ class ServiceCollection(collection.Collection):
"""A list containing services objects"""
def __init__(self, **kwargs):
super(ServiceCollection, self).__init__()
super().__init__()
self._type = 'services'
@staticmethod
@@ -177,7 +176,7 @@ class ServicesController(rest.RestController):
"""REST controller for Services."""
def __init__(self):
super(ServicesController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -123,7 +122,7 @@ class Strategy(base.APIBase):
"""Parameters spec dict"""
def __init__(self, **kwargs):
super(Strategy, self).__init__()
super().__init__()
self.fields = []
self.fields.append('uuid')
@@ -174,7 +173,7 @@ class StrategyCollection(collection.Collection):
"""A list containing strategies objects"""
def __init__(self, **kwargs):
super(StrategyCollection, self).__init__()
super().__init__()
self._type = 'strategies'
@staticmethod
@@ -198,7 +197,7 @@ class StrategiesController(rest.RestController):
"""REST controller for Strategies."""
def __init__(self):
super(StrategiesController, self).__init__()
super().__init__()
_custom_actions = {
'detail': ['GET'],

View File

@@ -218,7 +218,7 @@ class JsonPatchType(wtypes.Base):
@staticmethod
def validate(patch):
_path = '/{0}'.format(patch.path.split('/')[1])
_path = '/{}'.format(patch.path.split('/')[1])
if len(patch.allowed_attrs()) > 0:
if _path not in patch.allowed_attrs():
msg = _("'%s' is not an allowed attribute and can not be "

View File

@@ -34,7 +34,7 @@ class WebhookController(rest.RestController):
"""REST controller for webhooks resource."""
def __init__(self):
super(WebhookController, self).__init__()
super().__init__()
self.dc_client = rpcapi.DecisionEngineAPI()
@wsme_pecan.wsexpose(None, wtypes.text, body=types.jsontype,

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -45,7 +44,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
raise exception.ConfigInvalid(
error_msg=_('Cannot compile public API routes'))
super(AuthTokenMiddleware, self).__init__(app, conf)
super().__init__(app, conf)
def __call__(self, env, start_response):
path = utils.safe_rstrip(env.get('PATH_INFO'), '/')
@@ -59,4 +58,4 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
if env['is_public_api']:
return self._app(env, start_response)
return super(AuthTokenMiddleware, self).__call__(env, start_response)
return super().__call__(env, start_response)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
@@ -31,7 +30,7 @@ from watcher._i18n import _
LOG = log.getLogger(__name__)
class ParsableErrorMiddleware(object):
class ParsableErrorMiddleware:
"""Replace error body with something the client can parse."""
def __init__(self, app):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 Servionica
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +34,7 @@ class APISchedulingService(scheduling.BackgroundSchedulerService):
def __init__(self, gconfig={}, **options):
self.services_status = {}
super(APISchedulingService, self).__init__(gconfig, **options)
super().__init__(gconfig, **options)
def get_services_status(self, context):
services = objects.service.Service.list(context)
@@ -110,7 +109,7 @@ class APISchedulingService(scheduling.BackgroundSchedulerService):
trigger='interval', jobstore='default', args=[context],
next_run_time=datetime.datetime.now(),
seconds=CONF.periodic_interval)
super(APISchedulingService, self).start()
super().start()
def stop(self):
"""Stop service."""

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -20,7 +19,7 @@
import abc
class BaseActionPlanHandler(object, metaclass=abc.ABCMeta):
class BaseActionPlanHandler(metaclass=abc.ABCMeta):
@abc.abstractmethod
def execute(self):
raise NotImplementedError()

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -34,7 +33,7 @@ LOG = log.getLogger(__name__)
class DefaultActionPlanHandler(base.BaseActionPlanHandler):
def __init__(self, context, service, action_plan_uuid):
super(DefaultActionPlanHandler, self).__init__()
super().__init__()
self.ctx = context
self.service = service
self.action_plan_uuid = action_plan_uuid

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -42,7 +41,7 @@ class BaseAction(loadable.Loadable, metaclass=abc.ABCMeta):
:param osc: an OpenStackClients instance, defaults to None
:type osc: :py:class:`~.OpenStackClients` instance, optional
"""
super(BaseAction, self).__init__(config)
super().__init__(config)
self._input_parameters = {}
self._osc = osc

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 ZTE
#
# Authors: Li Canwei

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +21,7 @@ from watcher.applier.loading import default
LOG = log.getLogger(__name__)
class ActionFactory(object):
class ActionFactory:
def __init__(self):
self.action_loader = default.DefaultActionLoader()

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 Servionica
#
# Authors: Alexander Chadin <a.chadin@servionica.ru>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -66,7 +66,7 @@ class VolumeMigrate(base.BaseAction):
DESTINATION_TYPE = "destination_type"
def __init__(self, config, osc=None):
super(VolumeMigrate, self).__init__(config)
super().__init__(config)
self.cinder_util = cinder_helper.CinderHelper(osc=self.osc)
self.nova_util = nova_helper.NovaHelper(osc=self.osc)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -28,7 +27,7 @@ See: :doc:`../architecture` for more details on this component.
import abc
class BaseApplier(object, metaclass=abc.ABCMeta):
class BaseApplier(metaclass=abc.ABCMeta):
@abc.abstractmethod
def execute(self, action_plan_uuid):
raise NotImplementedError()

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -29,7 +28,7 @@ CONF = cfg.CONF
class DefaultApplier(base.BaseApplier):
def __init__(self, context, applier_manager):
super(DefaultApplier, self).__init__()
super().__init__()
self._applier_manager = applier_manager
self._loader = default.DefaultWorkFlowEngineLoader()
self._engine = None

View File

@@ -16,11 +16,11 @@ from watcher.common.loader import default
class DefaultWorkFlowEngineLoader(default.DefaultLoader):
def __init__(self):
super(DefaultWorkFlowEngineLoader, self).__init__(
super().__init__(
namespace='watcher_workflow_engines')
class DefaultActionLoader(default.DefaultLoader):
def __init__(self):
super(DefaultActionLoader, self).__init__(
super().__init__(
namespace='watcher_actions')

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
# Copyright (c) 2016 Intel Corp
#

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -27,7 +26,7 @@ LOG = log.getLogger(__name__)
CONF = cfg.CONF
class TriggerActionPlan(object):
class TriggerActionPlan:
def __init__(self, applier_manager):
self.applier_manager = applier_manager
workers = CONF.watcher_applier.workers

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
# Copyright (c) 2016 Intel Corp
#
@@ -30,7 +29,7 @@ CONF = conf.CONF
class ApplierAPI(service.Service):
def __init__(self):
super(ApplierAPI, self).__init__(ApplierAPIManager)
super().__init__(ApplierAPIManager)
def launch_action_plan(self, context, action_plan_uuid=None):
if not utils.is_uuid_like(action_plan_uuid):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 ZTE
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +27,7 @@ CONF = cfg.CONF
LOG = log.getLogger(__name__)
class Syncer(object):
class Syncer:
"""Syncs all available actions with the Watcher DB"""
def sync(self):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
#
@@ -48,7 +47,7 @@ class BaseWorkFlowEngine(loadable.Loadable, metaclass=abc.ABCMeta):
:param osc: an OpenStackClients object, defaults to None
:type osc: :py:class:`~.OpenStackClients` instance, optional
"""
super(BaseWorkFlowEngine, self).__init__(config)
super().__init__(config)
self._context = context
self._applier_manager = applier_manager
self._action_factory = factory.ActionFactory()
@@ -111,7 +110,7 @@ class BaseWorkFlowEngine(loadable.Loadable, metaclass=abc.ABCMeta):
class BaseTaskFlowActionContainer(flow_task.Task):
def __init__(self, name, db_action, engine, **kwargs):
super(BaseTaskFlowActionContainer, self).__init__(name=name)
super().__init__(name=name)
self._db_action = db_action
self._engine = engine
self.loaded_action = None

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -130,11 +129,11 @@ class DefaultWorkFlowEngine(base.BaseWorkFlowEngine):
class TaskFlowActionContainer(base.BaseTaskFlowActionContainer):
def __init__(self, db_action, engine):
self.name = "action_type:{0} uuid:{1}".format(db_action.action_type,
db_action.uuid)
super(TaskFlowActionContainer, self).__init__(self.name,
db_action,
engine)
self.name = "action_type:{} uuid:{}".format(db_action.action_type,
db_action.uuid)
super().__init__(self.name,
db_action,
engine)
def do_pre_execute(self):
LOG.debug("Pre-condition action: %s", self.name)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
@@ -31,7 +30,7 @@ from watcher.db import purge
CONF = conf.CONF
class DBCommand(object):
class DBCommand:
@staticmethod
def upgrade():
@@ -145,11 +144,11 @@ def main():
register_sub_command_opts()
# this is hack to work with previous usage of watcher-dbsync
# pls change it to watcher-dbsync upgrade
valid_commands = set([
valid_commands = {
'upgrade', 'downgrade', 'revision',
'version', 'stamp', 'create_schema',
'purge',
])
}
if not set(sys.argv).intersection(valid_commands):
sys.argv.append('upgrade')

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright (c) 2016 Intel
#

View File

@@ -27,7 +27,7 @@ CONF = conf.CONF
LOG = log.getLogger(__name__)
class CinderHelper(object):
class CinderHelper:
def __init__(self, osc=None):
""":param osc: an OpenStackClients instance"""

View File

@@ -61,7 +61,7 @@ def check_min_nova_api_version(config_version):
MIN_NOVA_API_VERSION))
class OpenStackClients(object):
class OpenStackClients:
"""Convenience class to create and cache client instances."""
def __init__(self):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -93,7 +92,7 @@ class WatcherException(Exception):
# at least get the core msg_fmt out if something happened
message = self.msg_fmt
super(WatcherException, self).__init__(message)
super().__init__(message)
def __str__(self):
"""Encode to utf-8 then wsme api can consume it as well"""

View File

@@ -48,4 +48,4 @@ class APSchedulerThreadPoolExecutor(pool_executor.BasePoolExecutor):
def __init__(self, max_workers=10):
pool = get_futurist_pool_executor(max_workers)
super(APSchedulerThreadPoolExecutor, self).__init__(pool)
super().__init__(pool)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 ZTE Corporation
#
# Authors:Yumeng Bao <bao.yumeng@zte.com.cn>
@@ -26,7 +25,7 @@ from watcher.common import utils
LOG = log.getLogger(__name__)
class IronicHelper(object):
class IronicHelper:
def __init__(self, osc=None):
""":param osc: an OpenStackClients instance"""

View File

@@ -24,7 +24,7 @@ CONF = conf.CONF
LOG = log.getLogger(__name__)
class KeystoneHelper(object):
class KeystoneHelper:
def __init__(self, osc=None):
""":param osc: an OpenStackClients instance"""

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +16,7 @@
import abc
class BaseLoader(object, metaclass=abc.ABCMeta):
class BaseLoader(metaclass=abc.ABCMeta):
@abc.abstractmethod
def list_available(self):

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +34,7 @@ class DefaultLoader(base.BaseLoader):
:type namespace: str
:param conf: ConfigOpts instance, defaults to cfg.CONF
"""
super(DefaultLoader, self).__init__()
super().__init__()
self.namespace = namespace
self.conf = conf

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +18,7 @@ import abc
from watcher.common import service
class Loadable(object, metaclass=abc.ABCMeta):
class Loadable(metaclass=abc.ABCMeta):
"""Generic interface for dynamically loading a driver/entry point.
This defines the contract in order to let the loader manager inject
@@ -27,7 +26,7 @@ class Loadable(object, metaclass=abc.ABCMeta):
"""
def __init__(self, config):
super(Loadable, self).__init__()
super().__init__()
self.config = config
@classmethod
@@ -45,7 +44,7 @@ LoadableSingletonMeta = type(
"LoadableSingletonMeta", (abc.ABCMeta, service.Singleton), {})
class LoadableSingleton(object, metaclass=LoadableSingletonMeta):
class LoadableSingleton(metaclass=LoadableSingletonMeta):
"""Generic interface for dynamically loading a driver as a singleton.
This defines the contract in order to let the loader manager inject
@@ -54,7 +53,7 @@ class LoadableSingleton(object, metaclass=LoadableSingletonMeta):
"""
def __init__(self, config):
super(LoadableSingleton, self).__init__()
super().__init__()
self.config = config
@classmethod

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -34,7 +33,7 @@ LOG = log.getLogger(__name__)
CONF = conf.CONF
class NovaHelper(object):
class NovaHelper:
def __init__(self, osc=None):
""":param osc: an OpenStackClients instance"""

View File

@@ -1,4 +1,3 @@
# Copyright 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@@ -21,7 +21,7 @@ CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class PlacementHelper(object):
class PlacementHelper:
def __init__(self, osc=None):
""":param osc: an OpenStackClients instance"""

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Authors: Vincent FRANCOISE <vincent.francoise@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 eNovance <licensing@enovance.com>
##
@@ -109,7 +108,7 @@ class ServiceHeartbeat(scheduling.BackgroundSchedulerService):
def __init__(self, gconfig=None, service_name=None, **kwargs):
gconfig = None or {}
super(ServiceHeartbeat, self).__init__(gconfig, **kwargs)
super().__init__(gconfig, **kwargs)
ServiceHeartbeat.service_name = service_name
self.context = context.make_context()
self.send_beat()
@@ -140,7 +139,7 @@ class ServiceHeartbeat(scheduling.BackgroundSchedulerService):
def start(self):
"""Start service."""
self.add_heartbeat_job()
super(ServiceHeartbeat, self).start()
super().start()
def stop(self):
"""Stop service."""
@@ -161,7 +160,7 @@ class Service(service.ServiceBase):
API_VERSION = '1.0'
def __init__(self, manager_class):
super(Service, self).__init__()
super().__init__()
self.manager = manager_class()
self.publisher_id = self.manager.publisher_id

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2016 Servionica
##
@@ -17,7 +16,7 @@
import abc
class ServiceManager(object, metaclass=abc.ABCMeta):
class ServiceManager(metaclass=abc.ABCMeta):
@property
@abc.abstractmethod

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -126,10 +125,9 @@ def extend_with_default(validator_class):
if "default" in subschema and instance is not None:
instance.setdefault(prop, subschema["default"])
for error in validate_properties(
yield from validate_properties(
validator, properties, instance, schema
):
yield error
)
return validators.extend(validator_class,
{"properties": set_defaults})
@@ -147,10 +145,9 @@ def extend_with_strict_schema(validator_class):
if para not in properties.keys():
raise exception.AuditParameterNotAllowed(parameter=para)
for error in validate_properties(
yield from validate_properties(
validator, properties, instance, schema
):
yield error
)
return validators.extend(validator_class, {"properties": strict_schema})

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
# Copyright (c) 2016 Intel Corp
#

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 European Organization for Nuclear Research (CERN)
#
# Authors: Corne Lukken <info@dantalion.nl>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>
@@ -21,7 +20,7 @@ from oslo_db import options as oslo_db_options
from watcher.conf import paths
_DEFAULT_SQL_CONNECTION = 'sqlite:///{0}'.format(
_DEFAULT_SQL_CONNECTION = 'sqlite:///{}'.format(
paths.state_path_def('watcher.sqlite'))
database = cfg.OptGroup(name='database',

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 Servionica
#
# Authors: Alexander Chadin <a.chadin@servionica.ru>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 European Organization for Nuclear Research (CERN)
#
# Authors: Corne Lukken <info@dantalion.nl>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 European Organization for Nuclear Research (CERN)
#
# Authors: Corne Lukken <info@dantalion.nl>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 ZTE Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 ZTE Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Intel Corp
#
# Authors: Prudhvi Rao Shedimbi <prudhvi.rao.shedimbi@intel.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Authors: Vincent FRANCOISE <vincent.francoise@b-com.com>

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Authors: Vincent FRANCOISE <vincent.francoise@b-com.com>

View File

@@ -29,7 +29,7 @@ def get_instance():
return IMPL
class BaseConnection(object, metaclass=abc.ABCMeta):
class BaseConnection(metaclass=abc.ABCMeta):
"""Base class for storage system connections."""
@abc.abstractmethod

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +33,7 @@ from watcher import objects
LOG = log.getLogger(__name__)
class WatcherObjectsMap(object):
class WatcherObjectsMap:
"""Wrapper to deal with watcher objects per type
This wrapper object contains a list of watcher objects per type.
@@ -109,7 +108,7 @@ class WatcherObjectsMap(object):
return table.get_string()
class PurgeCommand(object):
class PurgeCommand:
"""Purges the DB by removing soft deleted entries
The workflow for this purge is the following:
@@ -193,7 +192,7 @@ class PurgeCommand(object):
action_plans = objects.ActionPlan.list(self.ctx, filters=filters)
actions = objects.Action.list(self.ctx, filters=filters)
goal_ids = set(g.id for g in goals)
goal_ids = {g.id for g in goals}
orphans.strategies = [
strategy for strategy in strategies
if strategy.goal_id not in goal_ids]

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
@@ -111,7 +110,7 @@ class Connection(api.BaseConnection):
}
def __init__(self):
super(Connection, self).__init__()
super().__init__()
def __add_simple_filter(self, query, model, fieldname, value, operator_):
field = getattr(model, fieldname)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2017 Servionica LTD
#
# Authors: Alexander Chadin <a.chadin@servionica.ru>
@@ -52,8 +51,8 @@ class WatcherJobStore(sqlalchemy.SQLAlchemyJobStore):
def __init__(self, url=None, engine=None, tablename='apscheduler_jobs',
metadata=None, pickle_protocol=pickle.HIGHEST_PROTOCOL,
tag=None):
super(WatcherJobStore, self).__init__(url, engine, tablename,
metadata, pickle_protocol)
super().__init__(url, engine, tablename,
metadata, pickle_protocol)
metadata = maybe_ref(metadata) or MetaData()
self.jobs_t = Table(tablename, metadata, autoload_with=engine)
service_ident = service.ServiceHeartbeat.get_service_name()

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Authors: Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
@@ -39,7 +38,7 @@ class BaseMetaClass(service.Singleton, abc.ABCMeta):
pass
class BaseAuditHandler(object, metaclass=BaseMetaClass):
class BaseAuditHandler(metaclass=BaseMetaClass):
@abc.abstractmethod
def execute(self, audit, request_context):
@@ -61,7 +60,7 @@ class BaseAuditHandler(object, metaclass=BaseMetaClass):
class AuditHandler(BaseAuditHandler, metaclass=abc.ABCMeta):
def __init__(self):
super(AuditHandler, self).__init__()
super().__init__()
self._strategy_context = default_context.DefaultStrategyContext()
self._planner_loader = loader.DefaultPlannerLoader()
self.applier_client = rpcapi.ApplierAPI()

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2016 Servionica LTD
# Copyright (c) 2016 Intel Corp
#
@@ -39,7 +38,7 @@ CONF = conf.CONF
class ContinuousAuditHandler(base.AuditHandler):
def __init__(self):
super(ContinuousAuditHandler, self).__init__()
super().__init__()
# scheduler for executing audits
self._audit_scheduler = None
# scheduler for a periodic task to launch audit
@@ -82,7 +81,7 @@ class ContinuousAuditHandler(base.AuditHandler):
return False
def do_execute(self, audit, request_context):
solution = super(ContinuousAuditHandler, self)\
solution = super()\
.do_execute(audit, request_context)
if audit.audit_type == objects.audit.AuditType.CONTINUOUS.value:

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2019 ZTE Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +20,7 @@ from watcher import objects
class EventAuditHandler(base.AuditHandler):
def post_execute(self, audit, solution, request_context):
super(EventAuditHandler, self).post_execute(audit, solution,
request_context)
super().post_execute(audit, solution,
request_context)
# change state of the audit to SUCCEEDED
self.update_audit_state(audit, objects.audit.State.SUCCEEDED)

View File

@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
# Copyright (c) 2015 b<>com
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +20,7 @@ from watcher import objects
class OneShotAuditHandler(base.AuditHandler):
def post_execute(self, audit, solution, request_context):
super(OneShotAuditHandler, self).post_execute(audit, solution,
request_context)
super().post_execute(audit, solution,
request_context)
# change state of the audit to SUCCEEDED
self.update_audit_state(audit, objects.audit.State.SUCCEEDED)

Some files were not shown because too many files have changed in this diff Show More