Merge "Replace ' with " in rally/*.py"

This commit is contained in:
Jenkins 2015-01-18 09:19:21 +00:00 committed by Gerrit Code Review
commit f882c096e2
4 changed files with 56 additions and 56 deletions

View File

@ -46,13 +46,13 @@ def create_deploy(config, name):
LOG.exception(e)
raise
deployer = deploy.EngineFactory.get_engine(deployment['config']['type'],
deployer = deploy.EngineFactory.get_engine(deployment["config"]["type"],
deployment)
try:
deployer.validate()
except jsonschema.ValidationError:
LOG.error(_('Deployment %(uuid)s: Schema validation error.') %
{'uuid': deployment['uuid']})
LOG.error(_("Deployment %(uuid)s: Schema validation error.") %
{"uuid": deployment["uuid"]})
deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
raise
@ -72,10 +72,10 @@ def destroy_deploy(deployment):
# 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(deployment['config']['type'],
deployer = deploy.EngineFactory.get_engine(deployment["config"]["type"],
deployment)
tempest.Tempest(deployment['uuid']).uninstall()
tempest.Tempest(deployment["uuid"]).uninstall()
with deployer:
deployer.make_cleanup()
deployment.delete()
@ -87,7 +87,7 @@ def recreate_deploy(deployment):
:param deployment: UUID or name of the deployment
"""
deployment = objects.Deployment.get(deployment)
deployer = deploy.EngineFactory.get_engine(deployment['config']['type'],
deployer = deploy.EngineFactory.get_engine(deployment["config"]["type"],
deployment)
with deployer:
deployer.make_cleanup()
@ -135,7 +135,7 @@ def create_task(deployment, tag):
:param tag: tag for this task
"""
deployment_uuid = objects.Deployment.get(deployment)['uuid']
deployment_uuid = objects.Deployment.get(deployment)["uuid"]
return objects.Task(deployment_uuid=deployment_uuid, tag=tag)
@ -146,7 +146,7 @@ def task_validate(deployment, config):
:param config: a dict with a task configuration
"""
deployment = objects.Deployment.get(deployment)
task = objects.Task(deployment_uuid=deployment['uuid'])
task = objects.Task(deployment_uuid=deployment["uuid"])
benchmark_engine = engine.BenchmarkEngine(
config, task, admin=deployment["admin"], users=deployment["users"])
benchmark_engine.validate()
@ -162,9 +162,9 @@ def start_task(deployment, config, task=None):
:param config: a dict with a task configuration
"""
deployment = objects.Deployment.get(deployment)
task = task or objects.Task(deployment_uuid=deployment['uuid'])
LOG.info("Benchmark Task %s on Deployment %s" % (task['uuid'],
deployment['uuid']))
task = task or objects.Task(deployment_uuid=deployment["uuid"])
LOG.info("Benchmark Task %s on Deployment %s" % (task["uuid"],
deployment["uuid"]))
benchmark_engine = engine.BenchmarkEngine(
config, task, admin=deployment["admin"], users=deployment["users"])

View File

@ -53,17 +53,17 @@ class _TaskStatus(utils.ImmutableMixin, utils.EnumMixin):
class _DeployStatus(utils.ImmutableMixin, utils.EnumMixin):
DEPLOY_INIT = 'deploy->init'
DEPLOY_STARTED = 'deploy->started'
DEPLOY_SUBDEPLOY = 'deploy->subdeploy'
DEPLOY_FINISHED = 'deploy->finished'
DEPLOY_FAILED = 'deploy->failed'
DEPLOY_INIT = "deploy->init"
DEPLOY_STARTED = "deploy->started"
DEPLOY_SUBDEPLOY = "deploy->subdeploy"
DEPLOY_FINISHED = "deploy->finished"
DEPLOY_FAILED = "deploy->failed"
DEPLOY_INCONSISTENT = 'deploy->inconsistent'
DEPLOY_INCONSISTENT = "deploy->inconsistent"
CLEANUP_STARTED = 'cleanup->started'
CLEANUP_FINISHED = 'cleanup->finished'
CLEANUP_FAILED = 'cleanup->failed'
CLEANUP_STARTED = "cleanup->started"
CLEANUP_FINISHED = "cleanup->finished"
CLEANUP_FAILED = "cleanup->failed"
class _EndpointPermission(utils.ImmutableMixin, utils.EnumMixin):

View File

@ -24,9 +24,9 @@ from rally.common import log as logging
LOG = logging.getLogger(__name__)
exc_log_opts = [
cfg.BoolOpt('fatal_exception_format_errors',
cfg.BoolOpt("fatal_exception_format_errors",
default=False,
help='make exception message format errors fatal'),
help="make exception message format errors fatal"),
]
CONF = cfg.CONF
@ -37,7 +37,7 @@ class RallyException(Exception):
"""Base Rally Exception
To correctly use this class, inherit from it and define
a 'msg_fmt' property. That msg_fmt will get printf'd
a "msg_fmt" property. That msg_fmt will get printf'd
with the keyword arguments provided to the constructor.
"""
@ -73,7 +73,7 @@ class RallyException(Exception):
super(RallyException, self).__init__(message)
def format_message(self):
if self.__class__.__name__.endswith('_Remote'):
if self.__class__.__name__.endswith("_Remote"):
return self.args[0]
else:
return unicode(self)

View File

@ -54,9 +54,9 @@ def cached(func):
"""Cache client handles."""
def wrapper(self, *args, **kwargs):
key = '{0}{1}{2}'.format(func.__name__,
str(args) if args else '',
str(kwargs) if kwargs else '')
key = "{0}{1}{2}".format(func.__name__,
str(args) if args else "",
str(kwargs) if kwargs else "")
if key in self.cache:
return self.cache[key]
@ -69,13 +69,13 @@ def cached(func):
def create_keystone_client(args):
discover = keystone_discover.Discover(**args)
for version_data in discover.version_data():
version = version_data['version']
version = version_data["version"]
if version[0] <= 2:
return keystone_v2.Client(**args)
elif version[0] == 3:
return keystone_v3.Client(**args)
raise exceptions.RallyException(
'Failed to discover keystone version for url %(auth_url)s.', **args)
"Failed to discover keystone version for url %(auth_url)s.", **args)
class Clients(object):
@ -111,7 +111,7 @@ class Clients(object):
try:
# Ensure that user is admin
client = self.keystone()
if 'admin' not in [role.lower() for role in
if "admin" not in [role.lower() for role in
client.auth_ref.role_names]:
raise exceptions.InvalidAdminException(
username=self.endpoint.username)
@ -123,11 +123,11 @@ class Clients(object):
return client
@cached
def nova(self, version='2'):
def nova(self, version="2"):
"""Return nova client."""
kc = self.keystone()
compute_api_url = kc.service_catalog.url_for(
service_type='compute',
service_type="compute",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = nova.Client(version,
@ -140,11 +140,11 @@ class Clients(object):
return client
@cached
def neutron(self, version='2.0'):
def neutron(self, version="2.0"):
"""Return neutron client."""
kc = self.keystone()
network_api_url = kc.service_catalog.url_for(
service_type='network',
service_type="network",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = neutron.Client(version,
@ -156,11 +156,11 @@ class Clients(object):
return client
@cached
def glance(self, version='1'):
def glance(self, version="1"):
"""Return glance client."""
kc = self.keystone()
image_api_url = kc.service_catalog.url_for(
service_type='image',
service_type="image",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = glance.Client(version,
@ -172,11 +172,11 @@ class Clients(object):
return client
@cached
def heat(self, version='1'):
def heat(self, version="1"):
"""Return heat client."""
kc = self.keystone()
orchestration_api_url = kc.service_catalog.url_for(
service_type='orchestration',
service_type="orchestration",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = heat.Client(version,
@ -188,7 +188,7 @@ class Clients(object):
return client
@cached
def cinder(self, version='1'):
def cinder(self, version="1"):
"""Return cinder client."""
client = cinder.Client(version, None, None,
http_log_debug=logging.is_debug(),
@ -197,7 +197,7 @@ class Clients(object):
cacert=CONF.https_cacert)
kc = self.keystone()
volume_api_url = kc.service_catalog.url_for(
service_type='volume',
service_type="volume",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client.client.management_url = volume_api_url
@ -205,15 +205,15 @@ class Clients(object):
return client
@cached
def ceilometer(self, version='2'):
def ceilometer(self, version="2"):
"""Return ceilometer client."""
kc = self.keystone()
metering_api_url = kc.service_catalog.url_for(
service_type='metering',
service_type="metering",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
auth_token = kc.auth_token
if not hasattr(auth_token, '__call__'):
if not hasattr(auth_token, "__call__"):
# python-ceilometerclient requires auth_token to be a callable
auth_token = lambda: kc.auth_token
@ -226,11 +226,11 @@ class Clients(object):
return client
@cached
def ironic(self, version='1.0'):
def ironic(self, version="1.0"):
"""Return Ironic client."""
kc = self.keystone()
baremetal_api_url = kc.service_catalog.url_for(
service_type='baremetal',
service_type="baremetal",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = ironic.get_client(version,
@ -242,7 +242,7 @@ class Clients(object):
return client
@cached
def sahara(self, version='1.1'):
def sahara(self, version="1.1"):
"""Return Sahara client."""
client = sahara.Client(version,
username=self.endpoint.username,
@ -257,16 +257,16 @@ class Clients(object):
"""Return Zaqar client."""
kc = self.keystone()
messaging_api_url = kc.service_catalog.url_for(
service_type='messaging',
service_type="messaging",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
conf = {'auth_opts': {'backend': 'keystone', 'options': {
'os_username': self.endpoint.username,
'os_password': self.endpoint.password,
'os_project_name': self.endpoint.tenant_name,
'os_project_id': kc.auth_tenant_id,
'os_auth_url': self.endpoint.auth_url,
'insecure': CONF.https_insecure,
conf = {"auth_opts": {"backend": "keystone", "options": {
"os_username": self.endpoint.username,
"os_password": self.endpoint.password,
"os_project_name": self.endpoint.tenant_name,
"os_project_id": kc.auth_tenant_id,
"os_auth_url": self.endpoint.auth_url,
"insecure": CONF.https_insecure,
}}}
client = zaqar.Client(url=messaging_api_url,
version=version,
@ -278,7 +278,7 @@ class Clients(object):
"""Return designate client."""
kc = self.keystone()
dns_api_url = kc.service_catalog.url_for(
service_type='dns',
service_type="dns",
endpoint_type=self.endpoint.endpoint_type,
region_name=self.endpoint.region_name)
client = designate.Client(
@ -288,7 +288,7 @@ class Clients(object):
return client
@cached
def trove(self, version='1.0'):
def trove(self, version="1.0"):
"""Returns trove client."""
client = trove.Client(version,
username=self.endpoint.username,