def do_instance_mapper_list(cs, args): """list all instance mapper""" instance_mappers = cs.instance_mapper.list() columns = _columns_get(instance_mappers, DEFAULT_INSTANCE_MAPPER_KEYS) utils.print_list(instance_mappers, columns)
def do_project_mapper_list(cs, args): """list all project mapper""" project_mappers = cs.project_mapper.list() columns = _columns_get(project_mappers, DEFAULT_PROJECT_MAPPER_KEYS) utils.print_list(project_mappers, columns)
def do_flavor_mapper_list(cs, args): """list all flavor mapper""" flavor_mappers = cs.flavor_mapper.list() columns = _columns_get(flavor_mappers, DEFAULT_FLAVOR_MAPPER_KEYS) utils.print_list(flavor_mappers, columns)
def do_image_mapper_list(cs, args): """list all image mapper""" image_mappers = cs.image_mapper.list() columns = _columns_get(image_mappers, DEFAULT_IMAGE_MAPPER_KEYS) utils.print_list(image_mappers, columns)
def _dump_timings(self, timings): class Tyme(object): def __init__(self, url, seconds): self.url = url self.seconds = seconds results = [Tyme(url, end - start) for url, start, end in timings] total = 0.0 for tyme in results: total += tyme.seconds results.append(Tyme("Total", total)) utils.print_list(results, ["url", "seconds"], sortby_index=None)
def test_print_unicode_list(self): objs = [_FakeResult("k", u'\u2026')] utils.print_list(objs, ["Name", "Value"]) if six.PY3: s = u'\u2026' else: s = encodeutils.safe_encode(u'\u2026') self.assertEqual('+------+-------+\n' '| Name | Value |\n' '+------+-------+\n' '| k | %s |\n' '+------+-------+\n' % s, sys.stdout.getvalue())
def test_print_list_sort_by_none(self): objs = [_FakeResult("k1", 1), _FakeResult("k3", 3), _FakeResult("k2", 2)] utils.print_list(objs, ["Name", "Value"], sortby_index=None) self.assertEqual('+------+-------+\n' '| Name | Value |\n' '+------+-------+\n' '| k1 | 1 |\n' '| k3 | 3 |\n' '| k2 | 2 |\n' '+------+-------+\n', sys.stdout.getvalue())
def _print_flavor_list(flavors, show_extra_specs=False): _translate_flavor_keys(flavors) headers = [ 'ID', 'Name', 'Memory_MB', 'Disk', 'Ephemeral', 'Swap', 'VCPUs', 'RXTX_Factor', 'Is_Public', ] if show_extra_specs: formatters = {'extra_specs': _print_flavor_extra_specs} headers.append('extra_specs') else: formatters = {} utils.print_list(flavors, headers, formatters)
def _print_volume_type_list(vtypes): utils.print_list(vtypes, ['ID', 'Name', 'Description', 'Is_Public'])