Skip to content

Commit

Permalink
Merge "Replace ' with " in rally/*.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 18, 2015
2 parents b5da99a + a25069b commit f882c09
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 56 deletions.
22 changes: 11 additions & 11 deletions rally/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)


Expand All @@ -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()
Expand All @@ -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"])

Expand Down
18 changes: 9 additions & 9 deletions rally/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions rally/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
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
Expand All @@ -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.
"""
Expand Down Expand Up @@ -73,7 +73,7 @@ def __init__(self, message=None, **kwargs):
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)
Expand Down
64 changes: 32 additions & 32 deletions rally/osclients.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -69,13 +69,13 @@ def wrapper(self, *args, **kwargs):
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):
Expand Down Expand Up @@ -111,7 +111,7 @@ def verified_keystone(self):
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)
Expand All @@ -123,11 +123,11 @@ def verified_keystone(self):
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,
Expand All @@ -140,11 +140,11 @@ def nova(self, version='2'):
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,
Expand All @@ -156,11 +156,11 @@ def neutron(self, version='2.0'):
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,
Expand All @@ -172,11 +172,11 @@ def glance(self, version='1'):
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,
Expand All @@ -188,7 +188,7 @@ def heat(self, version='1'):
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(),
Expand All @@ -197,23 +197,23 @@ def cinder(self, version='1'):
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
client.client.auth_token = kc.auth_token
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

Expand All @@ -226,11 +226,11 @@ def ceilometer(self, version='2'):
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,
Expand All @@ -242,7 +242,7 @@ def ironic(self, version='1.0'):
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,
Expand All @@ -257,16 +257,16 @@ def zaqar(self, version=1.1):
"""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,
Expand All @@ -278,7 +278,7 @@ def designate(self):
"""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(
Expand All @@ -288,7 +288,7 @@ def designate(self):
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,
Expand Down

0 comments on commit f882c09

Please sign in to comment.