Tidy up - Rename Base

Some Python class and packages need to be renamed
for a better compliance with the shared terminology
which provides a better understanding of Watcher
objects and components by every contributor.

This patchset add missing Base in class name

Partially implements: blueprint glossary-related-refactoring

Change-Id: I95a3e41fbd5fcd90a99d81c9cf278940f50c7732
This commit is contained in:
Jean-Emile DARTOIS 2015-12-07 17:46:52 +01:00
parent b1fe7a5f3d
commit 35a1f0a657
26 changed files with 45 additions and 45 deletions

View File

@ -22,7 +22,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class Applier(object):
class BaseApplier(object):
@abc.abstractmethod
def execute(self, action_plan_uuid):
raise NotImplementedError(

View File

@ -16,13 +16,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.applier.base import Applier
from watcher.applier.base import BaseApplier
from watcher.applier.execution.executor import ActionPlanExecutor
from watcher.objects import Action
from watcher.objects import ActionPlan
class DefaultApplier(Applier):
class DefaultApplier(BaseApplier):
def __init__(self, manager_applier, context):
super(DefaultApplier, self).__init__()
self.manager_applier = manager_applier

View File

@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.applier.mapping.base import BaseActionMapper
from watcher.applier.primitives.change_nova_service_state import \
ChangeNovaServiceState

View File

@ -20,6 +20,7 @@
from oslo_config import cfg
from watcher.applier.primitives.base import BasePrimitive
from watcher.applier.primitives.wrapper.nova_wrapper import NovaWrapper
from watcher.applier.promise import Promise

View File

@ -21,6 +21,7 @@ from keystoneclient.auth.identity import v3
from keystoneclient import session
from oslo_config import cfg
from watcher.applier.primitives.base import BasePrimitive
from watcher.applier.primitives.wrapper.nova_wrapper import NovaWrapper
from watcher.applier.promise import Promise

View File

@ -19,6 +19,7 @@
from oslo_log import log
from watcher.applier.primitives.base import BasePrimitive
from watcher.applier.promise import Promise

View File

@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.applier.primitives.base import BasePrimitive
from watcher.applier.promise import Promise

View File

@ -16,12 +16,10 @@ Base classes for storage engines
"""
import abc
from oslo_config import cfg
from oslo_db import api as db_api
import six
_BACKEND_MAPPING = {'sqlalchemy': 'watcher.db.sqlalchemy.api'}
IMPL = db_api.DBAPI.from_config(cfg.CONF, backend_mapping=_BACKEND_MAPPING,
lazy=True)
@ -33,13 +31,9 @@ def get_instance():
@six.add_metaclass(abc.ABCMeta)
class Connection(object):
class BaseConnection(object):
"""Base class for storage system connections."""
@abc.abstractmethod
def __init__(self):
"""Constructor."""
@abc.abstractmethod
def get_audit_template_list(self, context, columns=None, filters=None,
limit=None, marker=None, sort_key=None,
@ -130,6 +124,7 @@ class Connection(object):
:raises: AuditTemplateNotFound
:raises: InvalidParameterValue
"""
@abc.abstractmethod
def soft_delete_audit_template(self, audit_template_id):
"""Soft delete an audit_template.

View File

@ -102,7 +102,7 @@ def _paginate_query(model, limit=None, marker=None, sort_key=None,
return query.all()
class Connection(api.Connection):
class Connection(api.BaseConnection):
"""SqlAlchemy connection."""
def __init__(self):

View File

@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.decision_engine.actions.base import BaseAction
from watcher.decision_engine.model.hypervisor_state import HypervisorState

View File

@ -17,6 +17,7 @@
# limitations under the License.
#
from watcher.decision_engine.actions.base import BaseAction

View File

@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.decision_engine.actions.base import BaseAction
from watcher.decision_engine.model.power_state import PowerState
@ -47,5 +48,5 @@ class ChangePowerState(BaseAction):
self._target = t
def __str__(self):
return "ChangePowerState {} => {} ".format(
self.target, self.powerstate)
return "ChangePowerState {} => {} ".format(self.target,
self.powerstate)

View File

@ -21,7 +21,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class Planner(object):
class BasePlanner(object):
@abc.abstractmethod
def schedule(self, context, audit_uuid, solution):
"""The planner receives a solution to schedule

View File

@ -21,7 +21,7 @@ from oslo_log import log
from enum import Enum
from watcher.common.exception import MetaActionNotFound
from watcher.common import utils
from watcher.decision_engine.planner.base import Planner
from watcher.decision_engine.planner.base import BasePlanner
from watcher import objects
@ -57,7 +57,7 @@ priority_primitives = {
}
class DefaultPlanner(Planner):
class DefaultPlanner(BasePlanner):
def create_action(self, action_plan_id, action_type, applies_to=None,
src=None,
dst=None,

View File

@ -21,7 +21,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class Solution(object):
class BaseSolution(object):
def __init__(self):
self._origin = None
self._model = None

View File

@ -17,12 +17,12 @@
# limitations under the License.
#
from oslo_log import log
from watcher.decision_engine.solution.base import Solution
from watcher.decision_engine.solution.base import BaseSolution
LOG = log.getLogger(__name__)
class DefaultSolution(Solution):
class DefaultSolution(BaseSolution):
def __init__(self):
"""The DefaultSolution class store a set of actions generated by a
strategy in order to achieve the goal.

View File

@ -21,7 +21,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class Solution(object):
class BaseSolutionComparator(object):
@abc.abstractmethod
def compare(self, sol1, sol2):
raise NotImplementedError(

View File

@ -21,7 +21,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class SolutionEvaluator(object):
class BaseSolutionEvaluator(object):
@abc.abstractmethod
def evaluate(self, solution):
raise NotImplementedError(

View File

@ -47,7 +47,7 @@ class BaseStrategy(object):
:param model: The name of the strategy to execute (loaded dynamically)
:type model: str
:return: A computed solution (via a placement algorithm)
:rtype: :class:`watcher.decision_engine.solution.base.Solution`
:rtype: :class:`watcher.decision_engine.solution.base.BaseSolution`
"""
@property

View File

@ -21,7 +21,7 @@ import six
@six.add_metaclass(abc.ABCMeta)
class Selector(object):
class BaseSelector(object):
@abc.abstractmethod
def define_from_goal(self, goal_name):
raise NotImplementedError(

View File

@ -18,7 +18,7 @@ from oslo_config import cfg
from oslo_log import log
from watcher.common.exception import WatcherException
from watcher.decision_engine.strategy.loader import StrategyLoader
from watcher.decision_engine.strategy.selector.base import Selector
from watcher.decision_engine.strategy.selector.base import BaseSelector
LOG = log.getLogger(__name__)
CONF = cfg.CONF
@ -38,7 +38,7 @@ CONF.register_group(goals_opt_group)
CONF.register_opts(WATCHER_GOALS_OPTS, goals_opt_group)
class StrategySelector(Selector):
class StrategySelector(BaseSelector):
def __init__(self):
self.strategy_loader = StrategyLoader()

View File

@ -426,7 +426,7 @@ class TestPatch(api_base.FunctionalTest):
super(TestPatch, self).setUp()
obj_utils.create_test_action_plan(self.context)
self.action = obj_utils.create_test_action(self.context, next=None)
p = mock.patch.object(db_api.Connection, 'update_action')
p = mock.patch.object(db_api.BaseConnection, 'update_action')
self.mock_action_update = p.start()
self.mock_action_update.side_effect = self._simulate_rpc_action_update
self.addCleanup(p.stop)
@ -552,7 +552,7 @@ class TestDelete(api_base.FunctionalTest):
super(TestDelete, self).setUp()
obj_utils.create_test_action_plan(self.context)
self.action = obj_utils.create_test_action(self.context, next=None)
p = mock.patch.object(db_api.Connection, 'update_action')
p = mock.patch.object(db_api.BaseConnection, 'update_action')
self.mock_action_update = p.start()
self.mock_action_update.side_effect = self._simulate_rpc_action_update
self.addCleanup(p.stop)

View File

@ -285,7 +285,7 @@ class TestDelete(api_base.FunctionalTest):
super(TestDelete, self).setUp()
self.action_plan = obj_utils.create_action_plan_without_audit(
self.context)
p = mock.patch.object(db_api.Connection, 'destroy_action_plan')
p = mock.patch.object(db_api.BaseConnection, 'destroy_action_plan')
self.mock_action_plan_delete = p.start()
self.mock_action_plan_delete.side_effect = \
self._simulate_rpc_action_plan_delete
@ -317,7 +317,7 @@ class TestPatch(api_base.FunctionalTest):
super(TestPatch, self).setUp()
self.action_plan = obj_utils.create_action_plan_without_audit(
self.context)
p = mock.patch.object(db_api.Connection, 'update_action_plan')
p = mock.patch.object(db_api.BaseConnection, 'update_action_plan')
self.mock_action_plan_update = p.start()
self.mock_action_plan_update.side_effect = \
self._simulate_rpc_action_plan_update

View File

@ -213,7 +213,7 @@ class TestPatch(api_base.FunctionalTest):
super(TestPatch, self).setUp()
self.audit_template = obj_utils.create_test_audit_template(
self.context)
p = mock.patch.object(db_api.Connection, 'update_audit_template')
p = mock.patch.object(db_api.BaseConnection, 'update_audit_template')
self.mock_audit_template_update = p.start()
self.mock_audit_template_update.side_effect = \
self._simulate_rpc_audit_template_update
@ -340,7 +340,7 @@ class TestPost(api_base.FunctionalTest):
def setUp(self):
super(TestPost, self).setUp()
p = mock.patch.object(db_api.Connection, 'create_audit_template')
p = mock.patch.object(db_api.BaseConnection, 'create_audit_template')
self.mock_create_audit_template = p.start()
self.mock_create_audit_template.side_effect = (
self._simulate_rpc_audit_template_create)
@ -417,7 +417,7 @@ class TestDelete(api_base.FunctionalTest):
super(TestDelete, self).setUp()
self.audit_template = obj_utils.create_test_audit_template(
self.context)
p = mock.patch.object(db_api.Connection, 'update_audit_template')
p = mock.patch.object(db_api.BaseConnection, 'update_audit_template')
self.mock_audit_template_update = p.start()
self.mock_audit_template_update.side_effect = \
self._simulate_rpc_audit_template_update

View File

@ -319,7 +319,7 @@ class TestPatch(api_base.FunctionalTest):
super(TestPatch, self).setUp()
obj_utils.create_test_audit_template(self.context)
self.audit = obj_utils.create_test_audit(self.context)
p = mock.patch.object(db_api.Connection, 'update_audit')
p = mock.patch.object(db_api.BaseConnection, 'update_audit')
self.mock_audit_update = p.start()
self.mock_audit_update.side_effect = self._simulate_rpc_audit_update
self.addCleanup(p.stop)
@ -414,7 +414,7 @@ class TestPost(api_base.FunctionalTest):
def setUp(self):
super(TestPost, self).setUp()
obj_utils.create_test_audit_template(self.context)
p = mock.patch.object(db_api.Connection, 'create_audit')
p = mock.patch.object(db_api.BaseConnection, 'create_audit')
self.mock_create_audit = p.start()
self.mock_create_audit.side_effect = (
self._simulate_rpc_audit_create)
@ -520,7 +520,7 @@ class TestDelete(api_base.FunctionalTest):
super(TestDelete, self).setUp()
obj_utils.create_test_audit_template(self.context)
self.audit = obj_utils.create_test_audit(self.context)
p = mock.patch.object(db_api.Connection, 'update_audit')
p = mock.patch.object(db_api.BaseConnection, 'update_audit')
self.mock_audit_update = p.start()
self.mock_audit_update.side_effect = self._simulate_rpc_audit_update
self.addCleanup(p.stop)

View File

@ -24,7 +24,6 @@ from watcher.decision_engine.planner.default import DefaultPlanner
from watcher.decision_engine.solution.default import DefaultSolution
from watcher.decision_engine.strategy.basic_consolidation import \
BasicConsolidation
from watcher.tests.db import base
from watcher.tests.db import utils as db_utils
from watcher.tests.decision_engine.faker_cluster_state import \
@ -59,11 +58,9 @@ class SolutionFakerSingleHyp(object):
class TestActionScheduling(base.DbTestCase):
scenarios = [
(str(action_cls), {"fake_action": mock.Mock(spec=action_cls)})
for action_cls in BaseAction.__subclasses__()
]
for action_cls in BaseAction.__subclasses__()]
def test_schedule_actions(self):
default_planner = DefaultPlanner()
@ -83,19 +80,18 @@ class TestActionScheduling(base.DbTestCase):
class TestDefaultPlanner(base.DbTestCase):
def setUp(self):
super(TestDefaultPlanner, self).setUp()
self.default_planner = DefaultPlanner()
obj_utils.create_test_audit_template(self.context)
p = mock.patch.object(db_api.Connection, 'create_action_plan')
p = mock.patch.object(db_api.BaseConnection, 'create_action_plan')
self.mock_create_action_plan = p.start()
self.mock_create_action_plan.side_effect = (
self._simulate_action_plan_create)
self.addCleanup(p.stop)
q = mock.patch.object(db_api.Connection, 'create_action')
q = mock.patch.object(db_api.BaseConnection, 'create_action')
self.mock_create_action = q.start()
self.mock_create_action.side_effect = (
self._simulate_action_create)