Remove rally.deploy.__main__ hacks

These hacks make the code hard to read and create a mess of
imports, which doesn't allow us to optimize them
and reduce rally start up time.

Change-Id: I4fce652bb6c5fbdcc6e7416164baf7f2254f9c16
This commit is contained in:
Boris Pavlovic 2015-06-13 00:44:09 +03:00 committed by Andrey Kurilin
parent 2aadcf4ebe
commit fef85867ea
8 changed files with 27 additions and 43 deletions

View File

@ -25,7 +25,7 @@ from rally.benchmark import engine
from rally.common.i18n import _
from rally.common import log as logging
from rally import consts
from rally import deploy
from rally.deploy import engine as deploy_engine
from rally import exceptions
from rally import objects
from rally.verification.tempest import tempest
@ -51,7 +51,7 @@ class Deployment(object):
LOG.exception(e)
raise
deployer = deploy.EngineFactory.get_engine(
deployer = deploy_engine.EngineFactory.get_engine(
deployment["config"]["type"], deployment)
try:
deployer.validate()
@ -77,7 +77,7 @@ class Deployment(object):
# TODO(akscram): Check that the deployment have got a status that
# is equal to "*->finished" or "deploy->inconsistent".
deployment = objects.Deployment.get(deployment)
deployer = deploy.EngineFactory.get_engine(
deployer = deploy_engine.EngineFactory.get_engine(
deployment["config"]["type"], deployment)
tempest.Tempest(deployment["uuid"]).uninstall()
@ -92,7 +92,7 @@ class Deployment(object):
:param deployment: UUID or name of the deployment
"""
deployment = objects.Deployment.get(deployment)
deployer = deploy.EngineFactory.get_engine(
deployer = deploy_engine.EngineFactory.get_engine(
deployment["config"]["type"], deployment)
with deployer:
deployer.make_cleanup()
@ -247,9 +247,9 @@ class Verification(object):
tempest_config=tempest_config)
if not verifier.is_installed():
print("Tempest is not installed for specified deployment.")
print("Installing Tempest for deployment %s" % deploy)
print("Installing Tempest for deployment %s" % deployment_uuid)
verifier.install()
LOG.info("Starting verification of deployment: %s" % deploy)
LOG.info("Starting verification of deployment: %s" % deployment_uuid)
verification.set_running()
verifier.verify(set_name=set_name, regex=regex)

View File

@ -54,7 +54,7 @@ from rally.benchmark import sla
from rally.cli import cliutils
from rally.common.plugin import discover
from rally.common import utils
from rally import deploy
from rally.deploy import engine
from rally.deploy.serverprovider import provider
from rally import exceptions
@ -173,7 +173,7 @@ class InfoCommands(object):
def DeploymentEngines(self):
"""Get information about deploy engines available in Rally."""
engines = self._get_descriptions(deploy.EngineFactory)
engines = self._get_descriptions(engine.EngineFactory)
info = (self._make_header("Rally - Deployment engines") +
"\n\n"
"Rally is an OpenStack benchmarking system. Before starting "
@ -264,7 +264,7 @@ class InfoCommands(object):
scenario_methods = list(set(s.split(".")[1] for s in scenarios))
sla_info = [cls.get_name() for cls in sla.SLA.get_all()]
deploy_engines = [cls.get_name() for cls in
deploy.EngineFactory.get_all()]
engine.EngineFactory.get_all()]
server_providers = [cls.get_name() for cls in
provider.ProviderFactory.get_all()]
@ -341,7 +341,7 @@ class InfoCommands(object):
def _get_deploy_engine_info(self, query):
try:
deploy_engine = deploy.EngineFactory.get(query)
deploy_engine = engine.EngineFactory.get(query)
header = "%s (deploy engine)" % deploy_engine.get_name()
info = self._make_header(header)
info += "\n\n"

View File

@ -1,16 +0,0 @@
# Copyright 2013: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from rally import deploy # noqa

View File

@ -18,7 +18,7 @@ import mock
from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark import sla
from rally.cli.commands import info
from rally import deploy
from rally.deploy import engine
from rally.deploy.engines import existing as existing_cloud
from rally.deploy.serverprovider import provider
from rally.deploy.serverprovider.providers import existing as existing_servers
@ -30,7 +30,7 @@ from tests.unit import test
SCENARIO = "rally.cli.commands.info.scenario_base.Scenario"
SLA = "rally.cli.commands.info.sla.SLA"
ENGINE = "rally.cli.commands.info.deploy.EngineFactory"
ENGINE = "rally.cli.commands.info.engine.EngineFactory"
PROVIDER = "rally.cli.commands.info.provider.ProviderFactory"
UTILS = "rally.cli.commands.info.utils"
DISCOVER = "rally.cli.commands.info.discover"
@ -119,7 +119,7 @@ class InfoCommandsTestCase(test.TestCase):
return_value=[existing_cloud.ExistingCloud])
def test_DeploymentEngines(self, mock_itersubclasses):
status = self.info.DeploymentEngines()
mock_itersubclasses.assert_called_with(deploy.EngineFactory)
mock_itersubclasses.assert_called_with(engine.EngineFactory)
self.assertIsNone(status)
@mock.patch(DISCOVER + ".itersubclasses",

View File

@ -18,7 +18,7 @@
import jsonschema
from rally import consts
from rally import deploy
from rally.deploy import engine as deploy_engine
from rally.deploy.engines import existing
from tests.unit import test
@ -70,6 +70,6 @@ class TestExistingCloud(test.TestCase):
def test_is_in_factory(self):
name = self.deployment["config"]["type"]
engine = deploy.EngineFactory.get_engine(name,
self.deployment)
engine = deploy_engine.EngineFactory.get_engine(name,
self.deployment)
self.assertIsInstance(engine, existing.ExistingCloud)

View File

@ -18,7 +18,7 @@
import mock
from rally import consts
from rally import deploy
from rally.deploy import engine
from rally import exceptions
from tests.unit import test
@ -55,8 +55,8 @@ class FakeDeployment(object):
pass
@deploy.configure(name="FakeEngine")
class FakeEngine(deploy.EngineFactory):
@engine.configure(name="FakeEngine")
class FakeEngine(engine.EngineFactory):
"""Fake deployment engine.
Used for tests.
@ -89,7 +89,7 @@ class EngineFactoryTestCase(test.TestCase):
def test_get_engine_not_found(self):
deployment = make_fake_deployment()
self.assertRaises(exceptions.PluginNotFound,
deploy.EngineFactory.get_engine,
engine.EngineFactory.get_engine,
"non_existing_engine", deployment)
self.assertEqual(consts.DeployStatus.DEPLOY_FAILED,
deployment["status"])
@ -204,9 +204,9 @@ class EngineFactoryTestCase(test.TestCase):
def test_get_engine(self):
deployment = make_fake_deployment()
engine_inst = deploy.EngineFactory.get_engine("FakeEngine",
engine_inst = engine.EngineFactory.get_engine("FakeEngine",
deployment)
self.assertIsInstance(engine_inst, FakeEngine)
def test_engine_factory_is_abstract(self):
self.assertRaises(TypeError, deploy.EngineFactory)
self.assertRaises(TypeError, engine.EngineFactory)

View File

@ -17,7 +17,7 @@
import mock
from rally import consts
from rally import deploy
from rally.deploy import engine
from tests.unit import fakes
from tests.unit import test
@ -49,8 +49,8 @@ class TestMultihostEngine(test.TestCase):
uuid="905b2f16-6453-4b86-8ba5-6d32025fcfa6",
config=self.config,
)
self.engine = deploy.engine.EngineFactory.get_engine("MultihostEngine",
self.deployment)
self.engine = engine.EngineFactory.get_engine("MultihostEngine",
self.deployment)
@mock.patch(MOD + "objects.Deployment")
@mock.patch(MOD + "engine.EngineFactory")

View File

@ -17,7 +17,7 @@ from rally.benchmark.scenarios import base
from rally.benchmark import sla
from rally.common.plugin import discover
from rally.common import utils
from rally import deploy
from rally.deploy import engine
from rally.deploy.serverprovider import provider
from tests.unit import test
@ -81,7 +81,7 @@ class DocstringsTestCase(test.TestCase):
long_description=False)
def test_all_deploy_engines_have_docstrings(self):
for deploy_engine in deploy.EngineFactory.get_all():
for deploy_engine in engine.EngineFactory.get_all():
self._assert_class_has_docstrings(deploy_engine)
def test_all_server_providers_have_docstrings(self):