本文整理汇总了Python中rally.openstack.common.cliutils.print_list函数的典型用法代码示例。如果您正苦于以下问题:Python print_list函数的具体用法?Python print_list怎么用?Python print_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: images
def images(self, deployment=None):
"""Display available images.
:param deployment: UUID or name of a deployment
"""
headers = ['UUID', 'Name', 'Size (B)']
mixed_case_fields = ['UUID', 'Name']
float_cols = ["Size (B)"]
table_rows = []
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col)
for col in float_cols]))
try:
for endpoint_dict in self._get_endpoints(deployment):
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
glance_client = clients.glance()
for image in glance_client.images.list():
data = [image.id, image.name, image.size]
table_rows.append(utils.Struct(**dict(zip(headers, data))))
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters,
mixed_case_fields=mixed_case_fields)
except exceptions.InvalidArgumentsException as e:
print(_("Authentication Issues: %s") % e)
return(1)
示例2: images
def images(self, deploy_id=None):
"""Show the images that are available in a deployment.
:param deploy_id: the UUID of a deployment
"""
headers = ['UUID', 'Name', 'Size (B)']
mixed_case_fields = ['UUID', 'Name']
float_cols = ["Size (B)"]
table_rows = []
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col)
for col in float_cols]))
try:
endpoints = db.deployment_get(deploy_id)['endpoints']
for endpoint_dict in endpoints:
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
glance_client = clients.glance()
for image in glance_client.images.list():
data = [image.id, image.name, image.size]
table_rows.append(utils.Struct(**dict(zip(headers, data))))
except exceptions.InvalidArgumentsException:
print(_("Authentication Issues: %s") % sys.exc_info()[1])
return(1)
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters,
mixed_case_fields=mixed_case_fields)
示例3: sla_check
def sla_check(self, task_id=None, tojson=False):
"""Display SLA check results table.
:param task_id: Task uuid.
:returns: Number of failed criteria.
"""
results = objects.Task.get(task_id).get_results()
failed_criteria = 0
data = []
STATUS_PASS = "PASS"
STATUS_FAIL = "FAIL"
for result in results:
key = result["key"]
for sla in result["data"]["sla"]:
success = sla.pop("success")
sla["status"] = success and STATUS_PASS or STATUS_FAIL
sla["benchmark"] = key["name"]
sla["pos"] = key["pos"]
failed_criteria += int(not success)
data.append(sla if tojson else rutils.Struct(**sla))
if tojson:
print(json.dumps(data))
else:
common_cliutils.print_list(data, ("benchmark", "pos", "criterion",
"status", "detail"))
return failed_criteria
示例4: _print_iterations_data
def _print_iterations_data(raw_data):
headers = ["iteration", "full duration"]
float_cols = ["full duration"]
atomic_actions = []
for row in raw_data:
# find first non-error result to get atomic actions names
if not row["error"] and "atomic_actions" in row:
atomic_actions = row["atomic_actions"].keys()
for row in raw_data:
if row["atomic_actions"]:
for (c, a) in enumerate(atomic_actions, 1):
action = "%(no)i. %(action)s" % {"no": c, "action": a}
headers.append(action)
float_cols.append(action)
break
table_rows = []
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col, 3)
for col in float_cols]))
for (c, r) in enumerate(raw_data, 1):
dlist = [c]
if r["atomic_actions"]:
dlist.append(r["duration"])
for action in atomic_actions:
dlist.append(r["atomic_actions"].get(action) or 0)
table_rows.append(rutils.Struct(**dict(zip(headers,
dlist))))
else:
data = dlist + [None for i in range(1, len(headers))]
table_rows.append(rutils.Struct(**dict(zip(headers,
data))))
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters)
print()
示例5: check
def check(self, deployment=None):
"""Check keystone authentication and list all available services.
:param deployment: a UUID or name of the deployment
"""
headers = ['services', 'type', 'status']
table_rows = []
try:
admin = db.deployment_get(deployment)['admin']
# TODO(boris-42): make this work for users in future
for endpoint_dict in [admin]:
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
client = clients.verified_keystone()
print("keystone endpoints are valid and following "
"services are available:")
for service in client.services.list():
data = [service.name, service.type, 'Available']
table_rows.append(utils.Struct(**dict(zip(headers, data))))
except exceptions.InvalidArgumentsException:
data = ['keystone', 'identity', 'Error']
table_rows.append(utils.Struct(**dict(zip(headers, data))))
print(_("Authentication Issues: %s.")
% sys.exc_info()[1])
return(1)
common_cliutils.print_list(table_rows, headers)
示例6: _print_iterations_data
def _print_iterations_data(raw):
headers = ['iteration', "full duration"]
float_cols = ['full duration']
for i in range(0, len(raw)):
if raw[i]['atomic_actions']:
for (c, a) in enumerate(raw[i]['atomic_actions'], 1):
action = str(c) + "-" + a['action']
headers.append(action)
float_cols.append(action)
break
table_rows = []
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col, 3)
for col in float_cols]))
for (c, r) in enumerate(raw, 1):
dlist = [c]
d = []
if r['atomic_actions']:
for l in r['atomic_actions']:
d.append(l['duration'])
dlist.append(sum(d))
dlist = dlist + d
table_rows.append(rutils.Struct(**dict(zip(headers,
dlist))))
else:
data = dlist + ["N/A" for i in range(1, len(headers))]
table_rows.append(rutils.Struct(**dict(zip(headers,
data))))
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters)
print()
示例7: check
def check(self, deploy_id=None):
"""Check the deployment.
Check keystone authentication and list all available services.
:param deploy_id: a UUID of the deployment
"""
headers = ['services', 'type', 'status']
table_rows = []
try:
endpoints = db.deployment_get(deploy_id)['endpoints']
for endpoint_dict in endpoints:
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
client = clients.verified_keystone()
print("keystone endpoints are valid and following "
"services are available:")
for service in client.service_catalog.get_data():
data = [service['name'], service['type'], 'Available']
table_rows.append(utils.Struct(**dict(zip(headers, data))))
except exceptions.InvalidArgumentsException:
data = ['keystone', 'identity', 'Error']
table_rows.append(utils.Struct(**dict(zip(headers, data))))
print(_("Authentication Issues: %s.")
% sys.exc_info()[1])
return(1)
common_cliutils.print_list(table_rows, headers)
示例8: flavors
def flavors(self, deploy_id=None):
"""Show the flavors that are available in a deployment.
:param deploy_id: the UUID 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)']
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col)
for col in float_cols]))
table_rows = []
try:
endpoints = db.deployment_get(deploy_id)['endpoints']
for endpoint_dict in endpoints:
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
nova_client = clients.nova()
for flavor in nova_client.flavors.list():
data = [flavor.id, flavor.name, flavor.vcpus,
flavor.ram, flavor.swap, flavor.disk]
table_rows.append(utils.Struct(**dict(zip(headers, data))))
except exceptions.InvalidArgumentsException:
print(_("Authentication Issues: %s") % sys.exc_info()[1])
return(1)
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters,
mixed_case_fields=mixed_case_fields)
示例9: flavors
def flavors(self, deployment=None):
"""Display available flavors.
: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)']
formatters = dict(zip(float_cols,
[cliutils.pretty_float_formatter(col)
for col in float_cols]))
table_rows = []
try:
for endpoint_dict in self._get_endpoints(deployment):
clients = osclients.Clients(endpoint.Endpoint(**endpoint_dict))
nova_client = clients.nova()
for flavor in nova_client.flavors.list():
data = [flavor.id, flavor.name, flavor.vcpus,
flavor.ram, flavor.swap, flavor.disk]
table_rows.append(utils.Struct(**dict(zip(headers, data))))
common_cliutils.print_list(table_rows,
fields=headers,
formatters=formatters,
mixed_case_fields=mixed_case_fields)
except exceptions.InvalidArgumentsException as e:
print(_("Authentication Issues: %s") % e)
return(1)
示例10: list
def list(self, task_list=None):
"""Print a list of all tasks."""
headers = ['uuid', 'created_at', 'status', 'failed', 'tag']
task_list = task_list or db.task_list()
if task_list:
common_cliutils.print_list(task_list, headers)
else:
print(_("There are no tasks. To run a new task, use:"
"\nrally task start"))
示例11: list
def list(self):
"""Print a result list of verifications."""
fields = ['UUID', 'Deployment UUID', 'Set name', 'Tests', 'Failures',
'Created at', 'Status']
verifications = db.verification_list()
if verifications:
common_cliutils.print_list(verifications, fields, sortby_index=6)
else:
print(_("There are no results from verifier. To run a verifier, "
"use:\nrally verify start"))
示例12: list
def list(self, task_list=None):
"""List all tasks, started and finished."""
headers = ['uuid', 'created_at', 'status', 'failed', 'tag']
task_list = task_list or db.task_list()
if task_list:
common_cliutils.print_list(task_list, headers,
sortby_index=headers.index(
'created_at'))
else:
print(_("There are no tasks. To run a new task, use:"
"\nrally task start"))
示例13: list
def list(self):
"""Display all verifications table, started and finished."""
fields = ['UUID', 'Deployment UUID', 'Set name', 'Tests', 'Failures',
'Created at', 'Status']
verifications = db.verification_list()
if verifications:
common_cliutils.print_list(verifications, fields,
sortby_index=fields.index('Created at'))
else:
print(_("There are no results from verifier. To run a verifier, "
"use:\nrally verify start"))
示例14: endpoint
def endpoint(self, deploy_id=None):
"""Print endpoint of the deployment.
:param deploy_id: a UUID of the deployment
"""
headers = ['auth_url', 'username', 'password', 'tenant_name',
'region_name', 'use_public_urls', 'admin_port']
table_rows = []
endpoints = db.deployment_get(deploy_id)['endpoints']
for ep in endpoints:
data = [ep.get(m, '') for m in headers]
table_rows.append(utils.Struct(**dict(zip(headers, data))))
common_cliutils.print_list(table_rows, headers)
示例15: show
def show(self, verification_uuid=None, sort_by="name", detailed=False):
"""Display results table of the verification."""
try:
sortby_index = ("name", "duration").index(sort_by)
except ValueError:
print("Sorry, but verification results can't be sorted "
"by '%s'." % sort_by)
return 1
try:
verification = db.verification_get(verification_uuid)
tests = db.verification_result_get(verification_uuid)
except exceptions.NotFoundException as e:
print(six.text_type(e))
return 1
print ("Total results of verification:\n")
total_fields = ["UUID", "Deployment UUID", "Set name", "Tests",
"Failures", "Created at", "Status"]
common_cliutils.print_list([verification], fields=total_fields)
print ("\nTests:\n")
fields = ["name", "time", "status"]
values = map(objects.Verification,
six.itervalues(tests.data["test_cases"]))
common_cliutils.print_list(values, fields, sortby_index=sortby_index)
if detailed:
for test in six.itervalues(tests.data["test_cases"]):
if test["status"] == "FAIL":
formatted_test = (
"====================================================="
"=================\n"
"FAIL: %(name)s\n"
"Time: %(time)s\n"
"Type: %(type)s\n"
"-----------------------------------------------------"
"-----------------\n"
"%(log)s\n"
) % {
"name": test["name"], "time": test["time"],
"type": test["failure"]["type"],
"log": test["failure"]["log"]}
print (formatted_test)