Replacing ' with " in rally/cmd
Partial bug: 1405884 Change-Id: I0a7b8e3d7d8ba2100f49083cd2cfc77f7d08afe5
This commit is contained in:
parent
216f443906
commit
7683f6b225
@ -32,15 +32,15 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
def main():
|
||||
# Initialize configuration and logging.
|
||||
CONF(sys.argv[1:], project='rally')
|
||||
logging.setup('rally')
|
||||
CONF(sys.argv[1:], project="rally")
|
||||
logging.setup("rally")
|
||||
# Prepare application and bind to the service socket.
|
||||
host = CONF.rest.host
|
||||
port = CONF.rest.port
|
||||
app = rally_app.make_app()
|
||||
server = simple_server.make_server(host, port, app)
|
||||
# Start application.
|
||||
LOG.info(_('Starting server in PID %s') % os.getpid())
|
||||
LOG.info(_("Starting server in PID %s") % os.getpid())
|
||||
LOG.info(_("Configuration:"))
|
||||
CONF.log_opt_values(LOG, logging.INFO)
|
||||
try:
|
||||
@ -49,5 +49,5 @@ def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -114,7 +114,7 @@ def pretty_float_formatter(field, ndigits=None):
|
||||
|
||||
def args(*args, **kwargs):
|
||||
def _decorator(func):
|
||||
func.__dict__.setdefault('args', []).insert(0, (args, kwargs))
|
||||
func.__dict__.setdefault("args", []).insert(0, (args, kwargs))
|
||||
return func
|
||||
return _decorator
|
||||
|
||||
@ -189,10 +189,10 @@ def _add_command_parsers(categories, subparsers):
|
||||
# 'subparsers' parameter of this function (categories and actions).
|
||||
subparsers._parser_class = CategoryParser
|
||||
|
||||
parser = subparsers.add_parser('version')
|
||||
parser = subparsers.add_parser("version")
|
||||
|
||||
parser = subparsers.add_parser('bash-completion')
|
||||
parser.add_argument('query_category', nargs='?')
|
||||
parser = subparsers.add_parser("bash-completion")
|
||||
parser.add_argument("query_category", nargs="?")
|
||||
|
||||
for category in categories:
|
||||
command_object = categories[category]()
|
||||
@ -202,7 +202,7 @@ def _add_command_parsers(categories, subparsers):
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.set_defaults(command_object=command_object)
|
||||
|
||||
category_subparsers = parser.add_subparsers(dest='action')
|
||||
category_subparsers = parser.add_subparsers(dest="action")
|
||||
|
||||
for action, action_fn in _methods_of(command_object):
|
||||
descr = _compose_action_description(action_fn)
|
||||
@ -212,17 +212,17 @@ def _add_command_parsers(categories, subparsers):
|
||||
description=descr, help=descr)
|
||||
|
||||
action_kwargs = []
|
||||
for args, kwargs in getattr(action_fn, 'args', []):
|
||||
for args, kwargs in getattr(action_fn, "args", []):
|
||||
# FIXME(markmc): hack to assume dest is the arg name without
|
||||
# the leading hyphens if no dest is supplied
|
||||
kwargs.setdefault('dest', args[0][2:])
|
||||
action_kwargs.append(kwargs['dest'])
|
||||
kwargs['dest'] = 'action_kwarg_' + kwargs['dest']
|
||||
kwargs.setdefault("dest", args[0][2:])
|
||||
action_kwargs.append(kwargs["dest"])
|
||||
kwargs["dest"] = "action_kwarg_" + kwargs["dest"]
|
||||
parser.add_argument(*args, **kwargs)
|
||||
|
||||
parser.set_defaults(action_fn=action_fn)
|
||||
parser.set_defaults(action_kwargs=action_kwargs)
|
||||
parser.add_argument('action_args', nargs='*')
|
||||
parser.add_argument("action_args", nargs="*")
|
||||
|
||||
|
||||
def validate_deprecated_args(argv, fn):
|
||||
@ -237,17 +237,17 @@ def validate_deprecated_args(argv, fn):
|
||||
|
||||
def run(argv, categories):
|
||||
parser = lambda subparsers: _add_command_parsers(categories, subparsers)
|
||||
category_opt = cfg.SubCommandOpt('category',
|
||||
title='Command categories',
|
||||
help='Available categories',
|
||||
category_opt = cfg.SubCommandOpt("category",
|
||||
title="Command categories",
|
||||
help="Available categories",
|
||||
handler=parser)
|
||||
|
||||
CONF.register_cli_opt(category_opt)
|
||||
|
||||
try:
|
||||
CONF(argv[1:], project='rally', version=version.version_string())
|
||||
CONF(argv[1:], project="rally", version=version.version_string())
|
||||
logging.setup("rally")
|
||||
if not CONF.get('log_config_append'):
|
||||
if not CONF.get("log_config_append"):
|
||||
# The below two lines are to disable noise from request module. The
|
||||
# standard way should be we make such lots of settings on the root
|
||||
# rally. However current oslo codes doesn't support such interface.
|
||||
@ -266,11 +266,11 @@ def run(argv, categories):
|
||||
st = os.stat(cfgfile)
|
||||
print(_("Could not read %s. Re-running with sudo") % cfgfile)
|
||||
try:
|
||||
os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
|
||||
os.execvp("sudo", ["sudo", "-u", "#%s" % st.st_uid] + sys.argv)
|
||||
except Exception:
|
||||
print(_('sudo failed, continuing as if nothing happened'))
|
||||
print(_("sudo failed, continuing as if nothing happened"))
|
||||
|
||||
print(_('Please re-run %s as root.') % argv[0])
|
||||
print(_("Please re-run %s as root.") % argv[0])
|
||||
return(2)
|
||||
|
||||
if CONF.category.name == "version":
|
||||
@ -282,14 +282,14 @@ def run(argv, categories):
|
||||
return(0)
|
||||
|
||||
fn = CONF.category.action_fn
|
||||
fn_args = [arg.decode('utf-8') for arg in CONF.category.action_args]
|
||||
fn_args = [arg.decode("utf-8") for arg in CONF.category.action_args]
|
||||
fn_kwargs = {}
|
||||
for k in CONF.category.action_kwargs:
|
||||
v = getattr(CONF.category, 'action_kwarg_' + k)
|
||||
v = getattr(CONF.category, "action_kwarg_" + k)
|
||||
if v is None:
|
||||
continue
|
||||
if isinstance(v, six.string_types):
|
||||
v = v.decode('utf-8')
|
||||
v = v.decode("utf-8")
|
||||
fn_kwargs[k] = v
|
||||
|
||||
# call the action with the remaining arguments
|
||||
@ -305,7 +305,7 @@ def run(argv, categories):
|
||||
print("Missing arguments:")
|
||||
for missing in e.missing:
|
||||
for arg in fn.args:
|
||||
if arg[1].get('dest', '').endswith(missing):
|
||||
if arg[1].get("dest", "").endswith(missing):
|
||||
print(" " + arg[0][0])
|
||||
break
|
||||
return(1)
|
||||
@ -359,7 +359,7 @@ _rally()
|
||||
COMPREPLY=($(compgen -W "${SUBCOMMANDS[${prev}]}" -- ${cur}))
|
||||
else
|
||||
if [ $prev == "--filename" ] ; then
|
||||
_filedir '@(json|ya?ml)'
|
||||
_filedir "@(json|ya?ml)"
|
||||
elif [ $prev == "--output-file" ] || [ $prev == "--out" ]; then
|
||||
_filedir
|
||||
else
|
||||
|
@ -40,16 +40,16 @@ from rally import osclients
|
||||
class DeploymentCommands(object):
|
||||
"""Set of commands that allow you to manage deployments."""
|
||||
|
||||
@cliutils.args('--name', type=str, required=True,
|
||||
help='A name of the deployment.')
|
||||
@cliutils.args('--fromenv', action='store_true',
|
||||
help='Read environment variables instead of config file')
|
||||
@cliutils.args('--filename', type=str, required=False,
|
||||
help='A path to the configuration file of the '
|
||||
'deployment.')
|
||||
@cliutils.args('--no-use', action='store_false', dest='do_use',
|
||||
help='Don\'t set new deployment as default for'
|
||||
' future operations')
|
||||
@cliutils.args("--name", type=str, required=True,
|
||||
help="A name of the deployment.")
|
||||
@cliutils.args("--fromenv", action="store_true",
|
||||
help="Read environment variables instead of config file")
|
||||
@cliutils.args("--filename", type=str, required=False,
|
||||
help="A path to the configuration file of the "
|
||||
"deployment.")
|
||||
@cliutils.args("--no-use", action="store_false", dest="do_use",
|
||||
help="Don\'t set new deployment as default for"
|
||||
" future operations")
|
||||
def create(self, name, fromenv=False, filename=None, do_use=False):
|
||||
"""Create new deployment.
|
||||
|
||||
@ -89,27 +89,27 @@ class DeploymentCommands(object):
|
||||
if v not in os.environ]
|
||||
if unavailable_vars:
|
||||
print("The following environment variables are required but "
|
||||
"not set: %s" % ' '.join(unavailable_vars))
|
||||
"not set: %s" % " ".join(unavailable_vars))
|
||||
return(1)
|
||||
|
||||
config = {
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": os.environ['OS_AUTH_URL'],
|
||||
"auth_url": os.environ["OS_AUTH_URL"],
|
||||
"admin": {
|
||||
"username": os.environ['OS_USERNAME'],
|
||||
"password": os.environ['OS_PASSWORD'],
|
||||
"tenant_name": os.environ['OS_TENANT_NAME']
|
||||
"username": os.environ["OS_USERNAME"],
|
||||
"password": os.environ["OS_PASSWORD"],
|
||||
"tenant_name": os.environ["OS_TENANT_NAME"]
|
||||
}
|
||||
}
|
||||
region_name = os.environ.get('OS_REGION_NAME')
|
||||
if region_name and region_name != 'None':
|
||||
config['region_name'] = region_name
|
||||
region_name = os.environ.get("OS_REGION_NAME")
|
||||
if region_name and region_name != "None":
|
||||
config["region_name"] = region_name
|
||||
else:
|
||||
if not filename:
|
||||
print("Either --filename or --fromenv is required")
|
||||
return(1)
|
||||
filename = os.path.expanduser(filename)
|
||||
with open(filename, 'rb') as deploy_file:
|
||||
with open(filename, "rb") as deploy_file:
|
||||
config = yaml.safe_load(deploy_file.read())
|
||||
|
||||
try:
|
||||
@ -123,13 +123,13 @@ class DeploymentCommands(object):
|
||||
|
||||
self.list(deployment_list=[deployment])
|
||||
if do_use:
|
||||
use.UseCommands().deployment(deployment['uuid'])
|
||||
use.UseCommands().deployment(deployment["uuid"])
|
||||
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment.')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment.")
|
||||
@envutils.with_default_deployment()
|
||||
def recreate(self, deployment=None):
|
||||
"""Destroy and create an existing deployment.
|
||||
@ -144,8 +144,8 @@ class DeploymentCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment.')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment.")
|
||||
@envutils.with_default_deployment()
|
||||
def destroy(self, deployment=None):
|
||||
"""Destroy existing deployment.
|
||||
@ -161,8 +161,8 @@ class DeploymentCommands(object):
|
||||
def list(self, deployment_list=None):
|
||||
"""List existing deployments."""
|
||||
|
||||
headers = ['uuid', 'created_at', 'name', 'status', 'active']
|
||||
current_deployment = envutils.get_global('RALLY_DEPLOYMENT')
|
||||
headers = ["uuid", "created_at", "name", "status", "active"]
|
||||
current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
|
||||
deployment_list = deployment_list or db.deployment_list()
|
||||
|
||||
table_rows = []
|
||||
@ -173,7 +173,7 @@ class DeploymentCommands(object):
|
||||
table_rows.append(utils.Struct(**dict(zip(headers, r))))
|
||||
common_cliutils.print_list(table_rows, headers,
|
||||
sortby_index=headers.index(
|
||||
'created_at'))
|
||||
"created_at"))
|
||||
else:
|
||||
print(_("There are no deployments. "
|
||||
"To create a new deployment, use:"
|
||||
@ -182,8 +182,8 @@ class DeploymentCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment.')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment.")
|
||||
@envutils.with_default_deployment()
|
||||
def config(self, deployment=None):
|
||||
"""Display configuration of the deployment.
|
||||
@ -200,8 +200,8 @@ class DeploymentCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment.')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment.")
|
||||
@envutils.with_default_deployment()
|
||||
def show(self, deployment=None):
|
||||
"""Show the endpoints of the deployment.
|
||||
@ -209,8 +209,8 @@ class DeploymentCommands(object):
|
||||
:param deployment: a UUID or name of the deployment
|
||||
"""
|
||||
|
||||
headers = ['auth_url', 'username', 'password', 'tenant_name',
|
||||
'region_name', 'endpoint_type']
|
||||
headers = ["auth_url", "username", "password", "tenant_name",
|
||||
"region_name", "endpoint_type"]
|
||||
table_rows = []
|
||||
|
||||
deployment = db.deployment_get(deployment)
|
||||
@ -219,15 +219,15 @@ class DeploymentCommands(object):
|
||||
endpoints = users + [admin] if admin else users
|
||||
|
||||
for ep in endpoints:
|
||||
data = [ep.get(m, '') for m in headers]
|
||||
data = [ep.get(m, "") for m in headers]
|
||||
table_rows.append(utils.Struct(**dict(zip(headers, data))))
|
||||
common_cliutils.print_list(table_rows, headers)
|
||||
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment.')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment.")
|
||||
@envutils.with_default_deployment()
|
||||
def check(self, deployment=None):
|
||||
"""Check keystone authentication and list all available services.
|
||||
@ -235,10 +235,10 @@ class DeploymentCommands(object):
|
||||
:param deployment: a UUID or name of the deployment
|
||||
"""
|
||||
|
||||
headers = ['services', 'type', 'status']
|
||||
headers = ["services", "type", "status"]
|
||||
table_rows = []
|
||||
try:
|
||||
admin = db.deployment_get(deployment)['admin']
|
||||
admin = db.deployment_get(deployment)["admin"]
|
||||
# TODO(boris-42): make this work for users in future
|
||||
for endpoint_dict in [admin]:
|
||||
clients = osclients.Clients(objects.Endpoint(**endpoint_dict))
|
||||
@ -246,10 +246,10 @@ class DeploymentCommands(object):
|
||||
print("keystone endpoints are valid and following "
|
||||
"services are available:")
|
||||
for service in client.services.list():
|
||||
data = [service.name, service.type, 'Available']
|
||||
data = [service.name, service.type, "Available"]
|
||||
table_rows.append(utils.Struct(**dict(zip(headers, data))))
|
||||
except exceptions.InvalidArgumentsException:
|
||||
data = ['keystone', 'identity', 'Error']
|
||||
data = ["keystone", "identity", "Error"]
|
||||
table_rows.append(utils.Struct(**dict(zip(headers, data))))
|
||||
print(_("Authentication Issues: %s.")
|
||||
% sys.exc_info()[1])
|
||||
|
@ -128,7 +128,7 @@ class InfoCommands(object):
|
||||
"\n\n"
|
||||
"Scenarios in Rally are put together in groups. Each "
|
||||
"scenario group is concentrated on some specific \nOpenStack "
|
||||
'functionality. For example, the "NovaServers" scenario '
|
||||
"functionality. For example, the 'NovaServers' scenario "
|
||||
"group contains scenarios that employ\nseveral basic "
|
||||
"operations available in Nova."
|
||||
"\n\n" +
|
||||
@ -192,9 +192,9 @@ class InfoCommands(object):
|
||||
"configuration file as its parameter. This file may look "
|
||||
"like:\n"
|
||||
"{\n"
|
||||
' "type": "ExistingCloud",\n'
|
||||
' "auth_url": "http://example.net:5000/v2.0/",\n'
|
||||
' "admin": { <credentials> },\n'
|
||||
" \"type\": \"ExistingCloud\",\n"
|
||||
" \"auth_url\": \"http://example.net:5000/v2.0/\",\n"
|
||||
" \"admin\": { <credentials> },\n"
|
||||
" ...\n"
|
||||
"}"
|
||||
"\n\n" +
|
||||
@ -230,10 +230,11 @@ class InfoCommands(object):
|
||||
"configuration files\npassed to the 'rally deployment create'"
|
||||
" command, e.g.:\n"
|
||||
"{\n"
|
||||
' "type": "DevstackEngine",\n'
|
||||
' "provider": {\n'
|
||||
' "type": "ExistingServers",\n'
|
||||
' "credentials": [{"user": "root", "host": "10.2.0.8"}]\n'
|
||||
" \"type\": \"DevstackEngine\",\n"
|
||||
" \"provider\": {\n"
|
||||
" \"type\": \"ExistingServers\",\n"
|
||||
" \"credentials\": [{\"user\": \"root\",\n"
|
||||
" \"host\": \"10.2.0.8\"}]\n"
|
||||
" }\n"
|
||||
"}"
|
||||
"\n\n" +
|
||||
|
@ -45,8 +45,8 @@ class ShowCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--deploy-id", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment")
|
||||
@envutils.with_default_deployment(cli_arg_name="deployment")
|
||||
def images(self, deployment=None):
|
||||
"""Display available images.
|
||||
@ -54,8 +54,8 @@ class ShowCommands(object):
|
||||
:param deployment: UUID or name of a deployment
|
||||
"""
|
||||
|
||||
headers = ['UUID', 'Name', 'Size (B)']
|
||||
mixed_case_fields = ['UUID', 'Name']
|
||||
headers = ["UUID", "Name", "Size (B)"]
|
||||
mixed_case_fields = ["UUID", "Name"]
|
||||
float_cols = ["Size (B)"]
|
||||
table_rows = []
|
||||
formatters = dict(zip(float_cols,
|
||||
@ -82,8 +82,8 @@ class ShowCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--deploy-id", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment")
|
||||
@envutils.with_default_deployment(cli_arg_name="deployment")
|
||||
def flavors(self, deployment=None):
|
||||
"""Display available flavors.
|
||||
@ -91,9 +91,9 @@ class ShowCommands(object):
|
||||
:param deployment: UUID or name of a deployment
|
||||
"""
|
||||
|
||||
headers = ['ID', 'Name', 'vCPUs', 'RAM (MB)', 'Swap (MB)', 'Disk (GB)']
|
||||
mixed_case_fields = ['ID', 'Name', 'vCPUs']
|
||||
float_cols = ['RAM (MB)', 'Swap (MB)', 'Disk (GB)']
|
||||
headers = ["ID", "Name", "vCPUs", "RAM (MB)", "Swap (MB)", "Disk (GB)"]
|
||||
mixed_case_fields = ["ID", "Name", "vCPUs"]
|
||||
float_cols = ["RAM (MB)", "Swap (MB)", "Disk (GB)"]
|
||||
formatters = dict(zip(float_cols,
|
||||
[cliutils.pretty_float_formatter(col)
|
||||
for col in float_cols]))
|
||||
@ -119,14 +119,14 @@ class ShowCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--deploy-id", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment")
|
||||
@envutils.with_default_deployment(cli_arg_name="deployment")
|
||||
def networks(self, deployment=None):
|
||||
"""Display configured networks."""
|
||||
|
||||
headers = ['ID', 'Label', 'CIDR']
|
||||
mixed_case_fields = ['ID', 'Label', 'CIDR']
|
||||
headers = ["ID", "Label", "CIDR"]
|
||||
mixed_case_fields = ["ID", "Label", "CIDR"]
|
||||
table_rows = []
|
||||
try:
|
||||
for endpoint_dict in self._get_endpoints(deployment):
|
||||
@ -146,14 +146,14 @@ class ShowCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--deploy-id", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment")
|
||||
@envutils.with_default_deployment(cli_arg_name="deployment")
|
||||
def secgroups(self, deployment=None):
|
||||
"""Display security groups."""
|
||||
|
||||
headers = ['ID', 'Name', 'Description']
|
||||
mixed_case_fields = ['ID', 'Name', 'Description']
|
||||
headers = ["ID", "Name", "Description"]
|
||||
mixed_case_fields = ["ID", "Name", "Description"]
|
||||
table_rows = []
|
||||
try:
|
||||
for endpoint_dict in self._get_endpoints(deployment):
|
||||
@ -176,14 +176,14 @@ class ShowCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--deploy-id", dest="deployment", type=str,
|
||||
required=False, help="UUID of the deployment.")
|
||||
@cliutils.args('--deployment', dest='deployment', type=str,
|
||||
required=False, help='UUID or name of a deployment')
|
||||
@cliutils.args("--deployment", dest="deployment", type=str,
|
||||
required=False, help="UUID or name of a deployment")
|
||||
@envutils.with_default_deployment(cli_arg_name="deployment")
|
||||
def keypairs(self, deployment=None):
|
||||
"""Display available ssh keypairs."""
|
||||
|
||||
headers = ['Name', 'Fingerprint']
|
||||
mixed_case_fields = ['Name', 'Fingerprint']
|
||||
headers = ["Name", "Fingerprint"]
|
||||
mixed_case_fields = ["Name", "Fingerprint"]
|
||||
table_rows = []
|
||||
try:
|
||||
for endpoint_dict in self._get_endpoints(deployment):
|
||||
|
@ -488,10 +488,10 @@ class TaskCommands(object):
|
||||
|
||||
@cliutils.args("--tasks", dest="tasks", nargs="+",
|
||||
help="uuids of tasks or json files with task results")
|
||||
@cliutils.args('--out', type=str, dest='out', required=True,
|
||||
help='Path to output file.')
|
||||
@cliutils.args('--open', dest='open_it', action='store_true',
|
||||
help='Open it in browser.')
|
||||
@cliutils.args("--out", type=str, dest="out", required=True,
|
||||
help="Path to output file.")
|
||||
@cliutils.args("--open", dest="open_it", action="store_true",
|
||||
help="Open it in browser.")
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="tasks", nargs="+",
|
||||
help="uuids of tasks or json files with task results")
|
||||
|
@ -31,29 +31,29 @@ class UseCommands(object):
|
||||
"""
|
||||
|
||||
def _update_openrc_deployment_file(self, deployment, endpoint):
|
||||
openrc_path = os.path.expanduser('~/.rally/openrc-%s' % deployment)
|
||||
openrc_path = os.path.expanduser("~/.rally/openrc-%s" % deployment)
|
||||
# NOTE(msdubov): In case of multiple endpoints write the first one.
|
||||
with open(openrc_path, 'w+') as env_file:
|
||||
env_file.write('export OS_AUTH_URL=%(auth_url)s\n'
|
||||
'export OS_USERNAME=%(username)s\n'
|
||||
'export OS_PASSWORD=%(password)s\n'
|
||||
'export OS_TENANT_NAME=%(tenant_name)s\n'
|
||||
with open(openrc_path, "w+") as env_file:
|
||||
env_file.write("export OS_AUTH_URL=%(auth_url)s\n"
|
||||
"export OS_USERNAME=%(username)s\n"
|
||||
"export OS_PASSWORD=%(password)s\n"
|
||||
"export OS_TENANT_NAME=%(tenant_name)s\n"
|
||||
% endpoint)
|
||||
if endpoint.get('region_name'):
|
||||
env_file.write('export OS_REGION_NAME=%(region_name)s\n'
|
||||
if endpoint.get("region_name"):
|
||||
env_file.write("export OS_REGION_NAME=%(region_name)s\n"
|
||||
% endpoint)
|
||||
expanded_path = os.path.expanduser('~/.rally/openrc')
|
||||
expanded_path = os.path.expanduser("~/.rally/openrc")
|
||||
if os.path.exists(expanded_path):
|
||||
os.remove(expanded_path)
|
||||
os.symlink(openrc_path, expanded_path)
|
||||
|
||||
def _update_attribute_in_global_file(self, attribute, value):
|
||||
expanded_path = os.path.expanduser('~/.rally/globals')
|
||||
fileutils.update_env_file(expanded_path, attribute, '%s\n' % value)
|
||||
expanded_path = os.path.expanduser("~/.rally/globals")
|
||||
fileutils.update_env_file(expanded_path, attribute, "%s\n" % value)
|
||||
|
||||
def _ensure_rally_configuration_dir_exists(self):
|
||||
if not os.path.exists(os.path.expanduser('~/.rally/')):
|
||||
os.makedirs(os.path.expanduser('~/.rally/'))
|
||||
if not os.path.exists(os.path.expanduser("~/.rally/")):
|
||||
os.makedirs(os.path.expanduser("~/.rally/"))
|
||||
|
||||
@cliutils.deprecated_args(
|
||||
"--uuid", dest="deployment", type=str,
|
||||
@ -61,8 +61,8 @@ class UseCommands(object):
|
||||
@cliutils.deprecated_args(
|
||||
"--name", dest="deployment", type=str,
|
||||
required=False, help="Name of the deployment.")
|
||||
@cliutils.args('--deployment', type=str, dest='deployment',
|
||||
help='UUID or name of the deployment')
|
||||
@cliutils.args("--deployment", type=str, dest="deployment",
|
||||
help="UUID or name of the deployment")
|
||||
def deployment(self, deployment=None):
|
||||
"""Set active deployment.
|
||||
|
||||
@ -71,34 +71,34 @@ class UseCommands(object):
|
||||
|
||||
try:
|
||||
deploy = db.deployment_get(deployment)
|
||||
print('Using deployment: %s' % deploy['uuid'])
|
||||
print("Using deployment: %s" % deploy["uuid"])
|
||||
self._ensure_rally_configuration_dir_exists()
|
||||
self._update_attribute_in_global_file('RALLY_DEPLOYMENT',
|
||||
deploy['uuid'])
|
||||
self._update_attribute_in_global_file("RALLY_DEPLOYMENT",
|
||||
deploy["uuid"])
|
||||
self._update_openrc_deployment_file(
|
||||
deploy['uuid'], deploy.get('admin') or deploy.get('users')[0])
|
||||
print ('~/.rally/openrc was updated\n\nHINTS:\n'
|
||||
'* To get your cloud resources, run:\n\t'
|
||||
'rally show [flavors|images|keypairs|networks|secgroups]\n'
|
||||
'\n* To use standard OpenStack clients, set up your env by '
|
||||
'running:\n\tsource ~/.rally/openrc\n'
|
||||
' OpenStack clients are now configured, e.g run:\n\t'
|
||||
'glance image-list')
|
||||
deploy["uuid"], deploy.get("admin") or deploy.get("users")[0])
|
||||
print ("~/.rally/openrc was updated\n\nHINTS:\n"
|
||||
"* To get your cloud resources, run:\n\t"
|
||||
"rally show [flavors|images|keypairs|networks|secgroups]\n"
|
||||
"\n* To use standard OpenStack clients, set up your env by "
|
||||
"running:\n\tsource ~/.rally/openrc\n"
|
||||
" OpenStack clients are now configured, e.g run:\n\t"
|
||||
"glance image-list")
|
||||
except exceptions.DeploymentNotFound:
|
||||
print('Deployment %s is not found.' % deployment)
|
||||
print("Deployment %s is not found." % deployment)
|
||||
return 1
|
||||
|
||||
@cliutils.args('--uuid', type=str, dest='task_id', required=False,
|
||||
help='UUID of the task')
|
||||
@cliutils.args("--uuid", type=str, dest="task_id", required=False,
|
||||
help="UUID of the task")
|
||||
def task(self, task_id):
|
||||
"""Set active task.
|
||||
|
||||
:param task_id: a UUID of task
|
||||
"""
|
||||
print('Using task: %s' % task_id)
|
||||
print("Using task: %s" % task_id)
|
||||
self._ensure_rally_configuration_dir_exists()
|
||||
db.task_get(task_id)
|
||||
self._update_attribute_in_global_file('RALLY_TASK', task_id)
|
||||
self._update_attribute_in_global_file("RALLY_TASK", task_id)
|
||||
|
||||
@cliutils.args("--uuid", type=str, dest="verification_id", required=False,
|
||||
help="UUID of the verification")
|
||||
@ -107,8 +107,8 @@ class UseCommands(object):
|
||||
|
||||
:param verification_id: a UUID of verification
|
||||
"""
|
||||
print('Verification UUID: %s' % verification_id)
|
||||
print("Verification UUID: %s" % verification_id)
|
||||
self._ensure_rally_configuration_dir_exists()
|
||||
db.verification_get(verification_id)
|
||||
self._update_attribute_in_global_file('RALLY_VERIFICATION',
|
||||
self._update_attribute_in_global_file("RALLY_VERIFICATION",
|
||||
verification_id)
|
||||
|
@ -30,9 +30,9 @@ MSG_MISSING_ARG = _("Missing argument: --%(arg_name)s")
|
||||
|
||||
|
||||
def clear_global(global_key):
|
||||
path = os.path.expanduser('~/.rally/globals')
|
||||
path = os.path.expanduser("~/.rally/globals")
|
||||
if os.path.exists(path):
|
||||
fileutils.update_env_file(path, global_key, '\n')
|
||||
fileutils.update_env_file(path, global_key, "\n")
|
||||
if global_key in os.environ:
|
||||
os.environ.pop(global_key)
|
||||
|
||||
@ -44,10 +44,10 @@ def clear_env():
|
||||
|
||||
def get_global(global_key, do_raise=False):
|
||||
if global_key not in os.environ:
|
||||
fileutils.load_env_file(os.path.expanduser('~/.rally/globals'))
|
||||
fileutils.load_env_file(os.path.expanduser("~/.rally/globals"))
|
||||
value = os.environ.get(global_key)
|
||||
if not value and do_raise:
|
||||
raise exceptions.InvalidArgumentsException('%s env is missing'
|
||||
raise exceptions.InvalidArgumentsException("%s env is missing"
|
||||
% global_key)
|
||||
return value
|
||||
|
||||
@ -77,6 +77,6 @@ def with_default_deployment(cli_arg_name="uuid"):
|
||||
"the --%(arg_name)s argument of "
|
||||
"this command"))
|
||||
|
||||
with_default_task_id = default_from_global('task_id', ENV_TASK, "uuid")
|
||||
with_default_task_id = default_from_global("task_id", ENV_TASK, "uuid")
|
||||
with_default_verification_id = default_from_global(
|
||||
"verification_uuid", ENV_VERIFICATION, "uuid")
|
||||
|
@ -29,17 +29,17 @@ from rally.cmd.commands import verify
|
||||
|
||||
|
||||
categories = {
|
||||
'deployment': deployment.DeploymentCommands,
|
||||
'info': info.InfoCommands,
|
||||
'show': show.ShowCommands,
|
||||
'task': task.TaskCommands,
|
||||
'use': use.UseCommands,
|
||||
'verify': verify.VerifyCommands
|
||||
"deployment": deployment.DeploymentCommands,
|
||||
"info": info.InfoCommands,
|
||||
"show": show.ShowCommands,
|
||||
"task": task.TaskCommands,
|
||||
"use": use.UseCommands,
|
||||
"verify": verify.VerifyCommands
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
return cliutils.run(sys.argv, categories)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -52,10 +52,10 @@ class TempestCommands(object):
|
||||
|
||||
|
||||
def main():
|
||||
categories = {'db': DBCommands,
|
||||
'tempest': TempestCommands}
|
||||
categories = {"db": DBCommands,
|
||||
"tempest": TempestCommands}
|
||||
cliutils.run(sys.argv, categories)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -65,7 +65,7 @@ _rally()
|
||||
COMPREPLY=($(compgen -W "${SUBCOMMANDS[${prev}]}" -- ${cur}))
|
||||
else
|
||||
if [ $prev == "--filename" ] ; then
|
||||
_filedir '@(json|ya?ml)'
|
||||
_filedir "@(json|ya?ml)"
|
||||
elif [ $prev == "--output-file" ] || [ $prev == "--out" ]; then
|
||||
_filedir
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user