Move print operations to shell_utils
Move more code to shell_utils that is only used for shell operations. The benefit of this is that the cinderclient library becomes lighter-weight, because users of the lib no longer have to import prettytable and extra code. Change-Id: I7bf6bd91ee5746d1ad4bd4504f3a056d03ae86a9
This commit is contained in:
parent
6f67187b82
commit
2d7ae2cd38
|
@ -15,6 +15,8 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import prettytable
|
||||||
|
|
||||||
from cinderclient import exceptions
|
from cinderclient import exceptions
|
||||||
from cinderclient import utils
|
from cinderclient import utils
|
||||||
|
|
||||||
|
@ -24,13 +26,109 @@ _quota_resources = ['volumes', 'snapshots', 'gigabytes',
|
||||||
_quota_infos = ['Type', 'In_use', 'Reserved', 'Limit', 'Allocated']
|
_quota_infos = ['Type', 'In_use', 'Reserved', 'Limit', 'Allocated']
|
||||||
|
|
||||||
|
|
||||||
|
def _print(pt, order):
|
||||||
|
print(pt.get_string(sortby=order))
|
||||||
|
|
||||||
|
|
||||||
|
def _pretty_format_dict(data_dict):
|
||||||
|
formatted_data = []
|
||||||
|
|
||||||
|
for k in sorted(data_dict):
|
||||||
|
formatted_data.append("%s : %s" % (k, data_dict[k]))
|
||||||
|
|
||||||
|
return "\n".join(formatted_data)
|
||||||
|
|
||||||
|
|
||||||
|
def print_list(objs, fields, exclude_unavailable=False, formatters=None,
|
||||||
|
sortby_index=0):
|
||||||
|
'''Prints a list of objects.
|
||||||
|
|
||||||
|
@param objs: Objects to print
|
||||||
|
@param fields: Fields on each object to be printed
|
||||||
|
@param exclude_unavailable: Boolean to decide if unavailable fields are
|
||||||
|
removed
|
||||||
|
@param formatters: Custom field formatters
|
||||||
|
@param sortby_index: Results sorted against the key in the fields list at
|
||||||
|
this index; if None then the object order is not
|
||||||
|
altered
|
||||||
|
'''
|
||||||
|
formatters = formatters or {}
|
||||||
|
mixed_case_fields = ['serverId']
|
||||||
|
removed_fields = []
|
||||||
|
rows = []
|
||||||
|
|
||||||
|
for o in objs:
|
||||||
|
row = []
|
||||||
|
for field in fields:
|
||||||
|
if field in removed_fields:
|
||||||
|
continue
|
||||||
|
if field in formatters:
|
||||||
|
row.append(formatters[field](o))
|
||||||
|
else:
|
||||||
|
if field in mixed_case_fields:
|
||||||
|
field_name = field.replace(' ', '_')
|
||||||
|
else:
|
||||||
|
field_name = field.lower().replace(' ', '_')
|
||||||
|
if isinstance(o, dict) and field in o:
|
||||||
|
data = o[field]
|
||||||
|
else:
|
||||||
|
if not hasattr(o, field_name) and exclude_unavailable:
|
||||||
|
removed_fields.append(field)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
data = getattr(o, field_name, '')
|
||||||
|
if data is None:
|
||||||
|
data = '-'
|
||||||
|
if isinstance(data, str) and "\r" in data:
|
||||||
|
data = data.replace("\r", " ")
|
||||||
|
row.append(data)
|
||||||
|
rows.append(row)
|
||||||
|
|
||||||
|
for f in removed_fields:
|
||||||
|
fields.remove(f)
|
||||||
|
|
||||||
|
pt = prettytable.PrettyTable((f for f in fields), caching=False)
|
||||||
|
pt.align = 'l'
|
||||||
|
for row in rows:
|
||||||
|
count = 0
|
||||||
|
# Converts unicode values in dictionary to string
|
||||||
|
for part in row:
|
||||||
|
count = count + 1
|
||||||
|
if isinstance(part, dict):
|
||||||
|
row[count - 1] = part
|
||||||
|
pt.add_row(row)
|
||||||
|
|
||||||
|
if sortby_index is None:
|
||||||
|
order_by = None
|
||||||
|
else:
|
||||||
|
order_by = fields[sortby_index]
|
||||||
|
_print(pt, order_by)
|
||||||
|
|
||||||
|
|
||||||
|
def print_dict(d, property="Property", formatters=None):
|
||||||
|
pt = prettytable.PrettyTable([property, 'Value'], caching=False)
|
||||||
|
pt.align = 'l'
|
||||||
|
formatters = formatters or {}
|
||||||
|
|
||||||
|
for r in d.items():
|
||||||
|
r = list(r)
|
||||||
|
|
||||||
|
if r[0] in formatters:
|
||||||
|
if isinstance(r[1], dict):
|
||||||
|
r[1] = _pretty_format_dict(r[1])
|
||||||
|
if isinstance(r[1], str) and "\r" in r[1]:
|
||||||
|
r[1] = r[1].replace("\r", " ")
|
||||||
|
pt.add_row(r)
|
||||||
|
_print(pt, property)
|
||||||
|
|
||||||
|
|
||||||
def print_volume_image(image_resp_tuple):
|
def print_volume_image(image_resp_tuple):
|
||||||
# image_resp_tuple = tuple (response, body)
|
# image_resp_tuple = tuple (response, body)
|
||||||
image = image_resp_tuple[1]
|
image = image_resp_tuple[1]
|
||||||
vt = image['os-volume_upload_image'].get('volume_type')
|
vt = image['os-volume_upload_image'].get('volume_type')
|
||||||
if vt is not None:
|
if vt is not None:
|
||||||
image['os-volume_upload_image']['volume_type'] = vt.get('name')
|
image['os-volume_upload_image']['volume_type'] = vt.get('name')
|
||||||
utils.print_dict(image['os-volume_upload_image'])
|
print_dict(image['os-volume_upload_image'])
|
||||||
|
|
||||||
|
|
||||||
def poll_for_status(poll_fn, obj_id, action, final_ok_states,
|
def poll_for_status(poll_fn, obj_id, action, final_ok_states,
|
||||||
|
@ -120,7 +218,7 @@ def find_message(cs, message):
|
||||||
|
|
||||||
|
|
||||||
def print_volume_snapshot(snapshot):
|
def print_volume_snapshot(snapshot):
|
||||||
utils.print_dict(snapshot._info)
|
print_dict(snapshot._info)
|
||||||
|
|
||||||
|
|
||||||
def translate_keys(collection, convert):
|
def translate_keys(collection, convert):
|
||||||
|
@ -188,16 +286,16 @@ def extract_metadata(args, type='user_metadata'):
|
||||||
|
|
||||||
|
|
||||||
def print_volume_type_list(vtypes):
|
def print_volume_type_list(vtypes):
|
||||||
utils.print_list(vtypes, ['ID', 'Name', 'Description', 'Is_Public'])
|
print_list(vtypes, ['ID', 'Name', 'Description', 'Is_Public'])
|
||||||
|
|
||||||
|
|
||||||
def print_group_type_list(gtypes):
|
def print_group_type_list(gtypes):
|
||||||
utils.print_list(gtypes, ['ID', 'Name', 'Description'])
|
print_list(gtypes, ['ID', 'Name', 'Description'])
|
||||||
|
|
||||||
|
|
||||||
def print_resource_filter_list(filters):
|
def print_resource_filter_list(filters):
|
||||||
formatter = {'Filters': lambda resource: ', '.join(resource.filters)}
|
formatter = {'Filters': lambda resource: ', '.join(resource.filters)}
|
||||||
utils.print_list(filters, ['Resource', 'Filters'], formatters=formatter)
|
print_list(filters, ['Resource', 'Filters'], formatters=formatter)
|
||||||
|
|
||||||
|
|
||||||
def quota_show(quotas):
|
def quota_show(quotas):
|
||||||
|
@ -211,7 +309,7 @@ def quota_show(quotas):
|
||||||
if not good_name:
|
if not good_name:
|
||||||
continue
|
continue
|
||||||
quota_dict[resource] = getattr(quotas, resource, None)
|
quota_dict[resource] = getattr(quotas, resource, None)
|
||||||
utils.print_dict(quota_dict)
|
print_dict(quota_dict)
|
||||||
|
|
||||||
|
|
||||||
def quota_usage_show(quotas):
|
def quota_usage_show(quotas):
|
||||||
|
@ -228,7 +326,7 @@ def quota_usage_show(quotas):
|
||||||
quota_info['Type'] = resource
|
quota_info['Type'] = resource
|
||||||
quota_info = dict((k.capitalize(), v) for k, v in quota_info.items())
|
quota_info = dict((k.capitalize(), v) for k, v in quota_info.items())
|
||||||
quota_list.append(quota_info)
|
quota_list.append(quota_info)
|
||||||
utils.print_list(quota_list, _quota_infos)
|
print_list(quota_list, _quota_infos)
|
||||||
|
|
||||||
|
|
||||||
def quota_update(manager, identifier, args):
|
def quota_update(manager, identifier, args):
|
||||||
|
@ -266,26 +364,26 @@ def print_volume_encryption_type_list(encryption_types):
|
||||||
|
|
||||||
:param encryption_types: a list of :class: VolumeEncryptionType instances
|
:param encryption_types: a list of :class: VolumeEncryptionType instances
|
||||||
"""
|
"""
|
||||||
utils.print_list(encryption_types, ['Volume Type ID', 'Provider',
|
print_list(encryption_types, ['Volume Type ID', 'Provider',
|
||||||
'Cipher', 'Key Size',
|
'Cipher', 'Key Size',
|
||||||
'Control Location'])
|
'Control Location'])
|
||||||
|
|
||||||
|
|
||||||
def print_qos_specs(qos_specs):
|
def print_qos_specs(qos_specs):
|
||||||
# formatters defines field to be converted from unicode to string
|
# formatters defines field to be converted from unicode to string
|
||||||
utils.print_dict(qos_specs._info, formatters=['specs'])
|
print_dict(qos_specs._info, formatters=['specs'])
|
||||||
|
|
||||||
|
|
||||||
def print_qos_specs_list(q_specs):
|
def print_qos_specs_list(q_specs):
|
||||||
utils.print_list(q_specs, ['ID', 'Name', 'Consumer', 'specs'])
|
print_list(q_specs, ['ID', 'Name', 'Consumer', 'specs'])
|
||||||
|
|
||||||
|
|
||||||
def print_qos_specs_and_associations_list(q_specs):
|
def print_qos_specs_and_associations_list(q_specs):
|
||||||
utils.print_list(q_specs, ['ID', 'Name', 'Consumer', 'specs'])
|
print_list(q_specs, ['ID', 'Name', 'Consumer', 'specs'])
|
||||||
|
|
||||||
|
|
||||||
def print_associations_list(associations):
|
def print_associations_list(associations):
|
||||||
utils.print_list(associations, ['Association_Type', 'Name', 'ID'])
|
print_list(associations, ['Association_Type', 'Name', 'ID'])
|
||||||
|
|
||||||
|
|
||||||
def _poll_for_status(poll_fn, obj_id, info, action, final_ok_states,
|
def _poll_for_status(poll_fn, obj_id, info, action, final_ok_states,
|
||||||
|
@ -305,7 +403,7 @@ def _poll_for_status(poll_fn, obj_id, info, action, final_ok_states,
|
||||||
if status in final_ok_states:
|
if status in final_ok_states:
|
||||||
break
|
break
|
||||||
elif status == "error":
|
elif status == "error":
|
||||||
utils.print_dict(info)
|
print_dict(info)
|
||||||
if global_request_id:
|
if global_request_id:
|
||||||
search_opts = {
|
search_opts = {
|
||||||
'request_id': global_request_id
|
'request_id': global_request_id
|
||||||
|
@ -317,5 +415,5 @@ def _poll_for_status(poll_fn, obj_id, info, action, final_ok_states,
|
||||||
fault_msg = "Unknown error. Operation failed."
|
fault_msg = "Unknown error. Operation failed."
|
||||||
raise exceptions.ResourceInErrorState(obj, fault_msg)
|
raise exceptions.ResourceInErrorState(obj, fault_msg)
|
||||||
elif time_elapsed == timeout_period:
|
elif time_elapsed == timeout_period:
|
||||||
utils.print_dict(info)
|
print_dict(info)
|
||||||
raise exceptions.TimeoutException(obj, action)
|
raise exceptions.TimeoutException(obj, action)
|
||||||
|
|
|
@ -545,7 +545,7 @@ class TestLoadVersionedActions(utils.TestCase):
|
||||||
|
|
||||||
class ShellUtilsTest(utils.TestCase):
|
class ShellUtilsTest(utils.TestCase):
|
||||||
|
|
||||||
@mock.patch.object(cinderclient.utils, 'print_dict')
|
@mock.patch.object(cinderclient.shell_utils, 'print_dict')
|
||||||
def test_print_volume_image(self, mock_print_dict):
|
def test_print_volume_image(self, mock_print_dict):
|
||||||
response = {'os-volume_upload_image': {'name': 'myimg1'}}
|
response = {'os-volume_upload_image': {'name': 'myimg1'}}
|
||||||
image_resp_tuple = (202, response)
|
image_resp_tuple = (202, response)
|
||||||
|
|
|
@ -220,7 +220,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||||
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
|
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(to_print, ['a', 'b'])
|
shell_utils.print_list(to_print, ['a', 'b'])
|
||||||
# Output should be sorted by the first key (a)
|
# Output should be sorted by the first key (a)
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+---+
|
+---+---+
|
||||||
|
@ -235,7 +235,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||||
to_print = [Row(a=3, b=None), Row(a=1, b=2)]
|
to_print = [Row(a=3, b=None), Row(a=1, b=2)]
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(to_print, ['a', 'b'])
|
shell_utils.print_list(to_print, ['a', 'b'])
|
||||||
# Output should be sorted by the first key (a)
|
# Output should be sorted by the first key (a)
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+---+
|
+---+---+
|
||||||
|
@ -250,7 +250,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||||
to_print = [Row(a=4, b=3), Row(a=2, b=1)]
|
to_print = [Row(a=4, b=3), Row(a=2, b=1)]
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(to_print, ['a', 'b'], sortby_index=1)
|
shell_utils.print_list(to_print, ['a', 'b'], sortby_index=1)
|
||||||
# Output should be sorted by the second key (b)
|
# Output should be sorted by the second key (b)
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+---+
|
+---+---+
|
||||||
|
@ -265,7 +265,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||||
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
|
to_print = [Row(a=3, b=4), Row(a=1, b=2)]
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(to_print, ['a', 'b'], sortby_index=None)
|
shell_utils.print_list(to_print, ['a', 'b'], sortby_index=None)
|
||||||
# Output should be in the order given
|
# Output should be in the order given
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+---+
|
+---+---+
|
||||||
|
@ -283,7 +283,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
for row in [Row(a=1, b=2), Row(a=3, b=4)]:
|
for row in [Row(a=1, b=2), Row(a=3, b=4)]:
|
||||||
yield row
|
yield row
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(gen_rows(), ['a', 'b'])
|
shell_utils.print_list(gen_rows(), ['a', 'b'])
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+---+
|
+---+---+
|
||||||
| a | b |
|
| a | b |
|
||||||
|
@ -297,7 +297,7 @@ class PrintListTestCase(test_utils.TestCase):
|
||||||
Row = collections.namedtuple('Row', ['a', 'b'])
|
Row = collections.namedtuple('Row', ['a', 'b'])
|
||||||
to_print = [Row(a=3, b='a\r'), Row(a=1, b='c\rd')]
|
to_print = [Row(a=3, b='a\r'), Row(a=1, b='c\rd')]
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_list(to_print, ['a', 'b'])
|
shell_utils.print_list(to_print, ['a', 'b'])
|
||||||
# Output should be sorted by the first key (a)
|
# Output should be sorted by the first key (a)
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+---+-----+
|
+---+-----+
|
||||||
|
@ -314,13 +314,13 @@ class PrintDictTestCase(test_utils.TestCase):
|
||||||
def test__pretty_format_dict(self):
|
def test__pretty_format_dict(self):
|
||||||
content = {'key1': 'value1', 'key2': 'value2'}
|
content = {'key1': 'value1', 'key2': 'value2'}
|
||||||
expected = "key1 : value1\nkey2 : value2"
|
expected = "key1 : value1\nkey2 : value2"
|
||||||
result = utils._pretty_format_dict(content)
|
result = shell_utils._pretty_format_dict(content)
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
def test_print_dict_with_return(self):
|
def test_print_dict_with_return(self):
|
||||||
d = {'a': 'A', 'b': 'B', 'c': 'C', 'd': 'test\rcarriage\n\rreturn'}
|
d = {'a': 'A', 'b': 'B', 'c': 'C', 'd': 'test\rcarriage\n\rreturn'}
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_dict(d)
|
shell_utils.print_dict(d)
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+----------+---------------+
|
+----------+---------------+
|
||||||
| Property | Value |
|
| Property | Value |
|
||||||
|
@ -337,7 +337,7 @@ class PrintDictTestCase(test_utils.TestCase):
|
||||||
content = {'a': 'A', 'b': 'B', 'f_key':
|
content = {'a': 'A', 'b': 'B', 'f_key':
|
||||||
{'key1': 'value1', 'key2': 'value2'}}
|
{'key1': 'value1', 'key2': 'value2'}}
|
||||||
with CaptureStdout() as cso:
|
with CaptureStdout() as cso:
|
||||||
utils.print_dict(content, formatters='f_key')
|
shell_utils.print_dict(content, formatters='f_key')
|
||||||
self.assertEqual("""\
|
self.assertEqual("""\
|
||||||
+----------+---------------+
|
+----------+---------------+
|
||||||
| Property | Value |
|
| Property | Value |
|
||||||
|
|
|
@ -344,7 +344,7 @@ class ShellTest(utils.TestCase):
|
||||||
self.run_command(command)
|
self.run_command(command)
|
||||||
self.assert_called('GET', '/volumes/detail?group_id=fake_id')
|
self.assert_called('GET', '/volumes/detail?group_id=fake_id')
|
||||||
|
|
||||||
@mock.patch("cinderclient.utils.print_list")
|
@mock.patch("cinderclient.shell_utils.print_list")
|
||||||
def test_list_duplicate_fields(self, mock_print):
|
def test_list_duplicate_fields(self, mock_print):
|
||||||
self.run_command('list --field Status,id,Size,status')
|
self.run_command('list --field Status,id,Size,status')
|
||||||
self.assert_called('GET', '/volumes/detail')
|
self.assert_called('GET', '/volumes/detail')
|
||||||
|
@ -520,7 +520,7 @@ class ShellTest(utils.TestCase):
|
||||||
self.run_command(command)
|
self.run_command(command)
|
||||||
self.assert_called('GET', '/attachments%s' % expected)
|
self.assert_called('GET', '/attachments%s' % expected)
|
||||||
|
|
||||||
@mock.patch('cinderclient.utils.print_list')
|
@mock.patch('cinderclient.shell_utils.print_list')
|
||||||
@mock.patch.object(cinderclient.v3.attachments.VolumeAttachmentManager,
|
@mock.patch.object(cinderclient.v3.attachments.VolumeAttachmentManager,
|
||||||
'list')
|
'list')
|
||||||
def test_attachment_list_setattr(self, mock_list, mock_print):
|
def test_attachment_list_setattr(self, mock_list, mock_print):
|
||||||
|
@ -1209,7 +1209,7 @@ class ShellTest(utils.TestCase):
|
||||||
get_levels_mock.assert_not_called()
|
get_levels_mock.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
|
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
|
||||||
@mock.patch('cinderclient.utils.print_list')
|
@mock.patch('cinderclient.shell_utils.print_list')
|
||||||
def test_service_get_log_no_params(self, print_mock, get_levels_mock):
|
def test_service_get_log_no_params(self, print_mock, get_levels_mock):
|
||||||
self.run_command('--os-volume-api-version 3.32 service-get-log')
|
self.run_command('--os-volume-api-version 3.32 service-get-log')
|
||||||
get_levels_mock.assert_called_once_with('', '', '')
|
get_levels_mock.assert_called_once_with('', '', '')
|
||||||
|
@ -1220,7 +1220,7 @@ class ShellTest(utils.TestCase):
|
||||||
@ddt.data('*', 'cinder-api', 'cinder-volume', 'cinder-scheduler',
|
@ddt.data('*', 'cinder-api', 'cinder-volume', 'cinder-scheduler',
|
||||||
'cinder-backup')
|
'cinder-backup')
|
||||||
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
|
@mock.patch('cinderclient.v3.services.ServiceManager.get_log_levels')
|
||||||
@mock.patch('cinderclient.utils.print_list')
|
@mock.patch('cinderclient.shell_utils.print_list')
|
||||||
def test_service_get_log(self, binary, print_mock, get_levels_mock):
|
def test_service_get_log(self, binary, print_mock, get_levels_mock):
|
||||||
server = 'host1'
|
server = 'host1'
|
||||||
prefix = 'sqlalchemy'
|
prefix = 'sqlalchemy'
|
||||||
|
@ -1378,7 +1378,7 @@ class ShellTest(utils.TestCase):
|
||||||
'availability_zone': 'AZ2'}}
|
'availability_zone': 'AZ2'}}
|
||||||
self.assert_called('POST', '/backups', body=expected)
|
self.assert_called('POST', '/backups', body=expected)
|
||||||
|
|
||||||
@mock.patch("cinderclient.utils.print_list")
|
@mock.patch("cinderclient.shell_utils.print_list")
|
||||||
def test_snapshot_list(self, mock_print_list):
|
def test_snapshot_list(self, mock_print_list):
|
||||||
"""Ensure we always present all existing fields when listing snaps."""
|
"""Ensure we always present all existing fields when listing snaps."""
|
||||||
self.run_command('--os-volume-api-version 3.65 snapshot-list')
|
self.run_command('--os-volume-api-version 3.65 snapshot-list')
|
||||||
|
@ -1847,7 +1847,7 @@ class ShellTest(utils.TestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
@mock.patch('cinderclient.utils.print_dict')
|
@mock.patch('cinderclient.shell_utils.print_dict')
|
||||||
@mock.patch('cinderclient.tests.unit.v3.fakes_base._stub_restore')
|
@mock.patch('cinderclient.tests.unit.v3.fakes_base._stub_restore')
|
||||||
def test_do_backup_restore(self,
|
def test_do_backup_restore(self,
|
||||||
mock_stub_restore,
|
mock_stub_restore,
|
||||||
|
|
|
@ -18,7 +18,6 @@ import os
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import prettytable
|
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
from cinderclient import exceptions
|
from cinderclient import exceptions
|
||||||
|
@ -106,76 +105,6 @@ def isunauthenticated(f):
|
||||||
return getattr(f, 'unauthenticated', False)
|
return getattr(f, 'unauthenticated', False)
|
||||||
|
|
||||||
|
|
||||||
def _print(pt, order):
|
|
||||||
print(pt.get_string(sortby=order))
|
|
||||||
|
|
||||||
|
|
||||||
def print_list(objs, fields, exclude_unavailable=False, formatters=None,
|
|
||||||
sortby_index=0):
|
|
||||||
'''Prints a list of objects.
|
|
||||||
|
|
||||||
@param objs: Objects to print
|
|
||||||
@param fields: Fields on each object to be printed
|
|
||||||
@param exclude_unavailable: Boolean to decide if unavailable fields are
|
|
||||||
removed
|
|
||||||
@param formatters: Custom field formatters
|
|
||||||
@param sortby_index: Results sorted against the key in the fields list at
|
|
||||||
this index; if None then the object order is not
|
|
||||||
altered
|
|
||||||
'''
|
|
||||||
formatters = formatters or {}
|
|
||||||
mixed_case_fields = ['serverId']
|
|
||||||
removed_fields = []
|
|
||||||
rows = []
|
|
||||||
|
|
||||||
for o in objs:
|
|
||||||
row = []
|
|
||||||
for field in fields:
|
|
||||||
if field in removed_fields:
|
|
||||||
continue
|
|
||||||
if field in formatters:
|
|
||||||
row.append(formatters[field](o))
|
|
||||||
else:
|
|
||||||
if field in mixed_case_fields:
|
|
||||||
field_name = field.replace(' ', '_')
|
|
||||||
else:
|
|
||||||
field_name = field.lower().replace(' ', '_')
|
|
||||||
if isinstance(o, dict) and field in o:
|
|
||||||
data = o[field]
|
|
||||||
else:
|
|
||||||
if not hasattr(o, field_name) and exclude_unavailable:
|
|
||||||
removed_fields.append(field)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
data = getattr(o, field_name, '')
|
|
||||||
if data is None:
|
|
||||||
data = '-'
|
|
||||||
if isinstance(data, str) and "\r" in data:
|
|
||||||
data = data.replace("\r", " ")
|
|
||||||
row.append(data)
|
|
||||||
rows.append(row)
|
|
||||||
|
|
||||||
for f in removed_fields:
|
|
||||||
fields.remove(f)
|
|
||||||
|
|
||||||
pt = prettytable.PrettyTable((f for f in fields), caching=False)
|
|
||||||
pt.align = 'l'
|
|
||||||
for row in rows:
|
|
||||||
count = 0
|
|
||||||
# Converts unicode values in dictionary to string
|
|
||||||
for part in row:
|
|
||||||
count = count + 1
|
|
||||||
if isinstance(part, dict):
|
|
||||||
row[count - 1] = part
|
|
||||||
pt.add_row(row)
|
|
||||||
|
|
||||||
if sortby_index is None:
|
|
||||||
order_by = None
|
|
||||||
else:
|
|
||||||
order_by = fields[sortby_index]
|
|
||||||
_print(pt, order_by)
|
|
||||||
|
|
||||||
|
|
||||||
def build_query_param(params, sort=False):
|
def build_query_param(params, sort=False):
|
||||||
"""parse list to url query parameters"""
|
"""parse list to url query parameters"""
|
||||||
|
|
||||||
|
@ -206,32 +135,6 @@ def build_query_param(params, sort=False):
|
||||||
return query_string
|
return query_string
|
||||||
|
|
||||||
|
|
||||||
def _pretty_format_dict(data_dict):
|
|
||||||
formatted_data = []
|
|
||||||
|
|
||||||
for k in sorted(data_dict):
|
|
||||||
formatted_data.append("%s : %s" % (k, data_dict[k]))
|
|
||||||
|
|
||||||
return "\n".join(formatted_data)
|
|
||||||
|
|
||||||
|
|
||||||
def print_dict(d, property="Property", formatters=None):
|
|
||||||
pt = prettytable.PrettyTable([property, 'Value'], caching=False)
|
|
||||||
pt.align = 'l'
|
|
||||||
formatters = formatters or {}
|
|
||||||
|
|
||||||
for r in d.items():
|
|
||||||
r = list(r)
|
|
||||||
|
|
||||||
if r[0] in formatters:
|
|
||||||
if isinstance(r[1], dict):
|
|
||||||
r[1] = _pretty_format_dict(r[1])
|
|
||||||
if isinstance(r[1], str) and "\r" in r[1]:
|
|
||||||
r[1] = r[1].replace("\r", " ")
|
|
||||||
pt.add_row(r)
|
|
||||||
_print(pt, property)
|
|
||||||
|
|
||||||
|
|
||||||
def find_resource(manager, name_or_id, **kwargs):
|
def find_resource(manager, name_or_id, **kwargs):
|
||||||
"""Helper for the _find_* methods."""
|
"""Helper for the _find_* methods."""
|
||||||
is_group = kwargs.pop('is_group', False)
|
is_group = kwargs.pop('is_group', False)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from cinderclient import base
|
from cinderclient import base
|
||||||
from cinderclient import utils
|
from cinderclient import shell_utils
|
||||||
|
|
||||||
|
|
||||||
class ListExtResource(base.Resource):
|
class ListExtResource(base.Resource):
|
||||||
|
@ -41,4 +41,4 @@ def do_list_extensions(client, _args):
|
||||||
"""Lists all available os-api extensions."""
|
"""Lists all available os-api extensions."""
|
||||||
extensions = client.list_extensions.show_all()
|
extensions = client.list_extensions.show_all()
|
||||||
fields = ["Name", "Summary", "Alias", "Updated"]
|
fields = ["Name", "Summary", "Alias", "Updated"]
|
||||||
utils.print_list(extensions, fields)
|
shell_utils.print_list(extensions, fields)
|
||||||
|
|
|
@ -197,7 +197,7 @@ def do_backup_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(backups, columns, sortby_index=sortby_index)
|
shell_utils.print_list(backups, columns, sortby_index=sortby_index)
|
||||||
if show_count:
|
if show_count:
|
||||||
print("Backup in total: %s" % total_count)
|
print("Backup in total: %s" % total_count)
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ def do_backup_restore(cs, args):
|
||||||
info.update(restore._info)
|
info.update(restore._info)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--detail',
|
@utils.arg('--detail',
|
||||||
|
@ -316,7 +316,7 @@ def do_get_pools(cs, args):
|
||||||
backend['name'] = info['name']
|
backend['name'] = info['name']
|
||||||
if args.detail:
|
if args.detail:
|
||||||
backend.update(info['capabilities'])
|
backend.update(info['capabilities'])
|
||||||
utils.print_dict(backend)
|
shell_utils.print_dict(backend)
|
||||||
AppendFilters.filters = []
|
AppendFilters.filters = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ def do_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(volumes, key_list, exclude_unavailable=True,
|
shell_utils.print_list(volumes, key_list, exclude_unavailable=True,
|
||||||
sortby_index=sortby_index)
|
sortby_index=sortby_index)
|
||||||
if show_count:
|
if show_count:
|
||||||
print("Volume in total: %s" % total_count)
|
print("Volume in total: %s" % total_count)
|
||||||
|
@ -747,7 +747,7 @@ def do_create(cs, args):
|
||||||
volume = cs.volumes.get(volume.id)
|
volume = cs.volumes.get(volume.id)
|
||||||
info.update(volume._info)
|
info.update(volume._info)
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
with cs.volumes.completion_cache('uuid',
|
with cs.volumes.completion_cache('uuid',
|
||||||
cinderclient.v3.volumes.Volume,
|
cinderclient.v3.volumes.Volume,
|
||||||
|
@ -812,7 +812,7 @@ def do_summary(cs, args):
|
||||||
if cs.api_version >= api_versions.APIVersion("3.36"):
|
if cs.api_version >= api_versions.APIVersion("3.36"):
|
||||||
formatters.append('metadata')
|
formatters.append('metadata')
|
||||||
|
|
||||||
utils.print_dict(info['volume-summary'], formatters=formatters)
|
shell_utils.print_dict(info['volume-summary'], formatters=formatters)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.11')
|
@api_versions.wraps('3.11')
|
||||||
|
@ -853,7 +853,7 @@ def do_group_type_show(cs, args):
|
||||||
info.update(gtype._info)
|
info.update(gtype._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info, formatters=['group_specs'])
|
shell_utils.print_dict(info, formatters=['group_specs'])
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.11')
|
@api_versions.wraps('3.11')
|
||||||
|
@ -881,7 +881,7 @@ def do_group_type_update(cs, args):
|
||||||
def do_group_specs_list(cs, args):
|
def do_group_specs_list(cs, args):
|
||||||
"""Lists current group types and specs."""
|
"""Lists current group types and specs."""
|
||||||
gtypes = cs.group_types.list()
|
gtypes = cs.group_types.list()
|
||||||
utils.print_list(gtypes, ['ID', 'Name', 'group_specs'])
|
shell_utils.print_list(gtypes, ['ID', 'Name', 'group_specs'])
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.11')
|
@api_versions.wraps('3.11')
|
||||||
|
@ -1170,7 +1170,7 @@ def do_cluster_list(cs, args):
|
||||||
if args.detailed:
|
if args.detailed:
|
||||||
columns.extend(('Num Hosts', 'Num Down Hosts', 'Last Heartbeat',
|
columns.extend(('Num Hosts', 'Num Down Hosts', 'Last Heartbeat',
|
||||||
'Disabled Reason', 'Created At', 'Updated at'))
|
'Disabled Reason', 'Created At', 'Updated at'))
|
||||||
utils.print_list(clusters, columns)
|
shell_utils.print_list(clusters, columns)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.7')
|
@api_versions.wraps('3.7')
|
||||||
|
@ -1181,7 +1181,7 @@ def do_cluster_list(cs, args):
|
||||||
def do_cluster_show(cs, args):
|
def do_cluster_show(cs, args):
|
||||||
"""Show detailed information on a clustered service."""
|
"""Show detailed information on a clustered service."""
|
||||||
cluster = cs.clusters.show(args.name, args.binary)
|
cluster = cs.clusters.show(args.name, args.binary)
|
||||||
utils.print_dict(cluster.to_dict())
|
shell_utils.print_dict(cluster.to_dict())
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.7')
|
@api_versions.wraps('3.7')
|
||||||
|
@ -1192,7 +1192,7 @@ def do_cluster_show(cs, args):
|
||||||
def do_cluster_enable(cs, args):
|
def do_cluster_enable(cs, args):
|
||||||
"""Enables clustered services."""
|
"""Enables clustered services."""
|
||||||
cluster = cs.clusters.update(args.name, args.binary, disabled=False)
|
cluster = cs.clusters.update(args.name, args.binary, disabled=False)
|
||||||
utils.print_dict(cluster.to_dict())
|
shell_utils.print_dict(cluster.to_dict())
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.7')
|
@api_versions.wraps('3.7')
|
||||||
|
@ -1206,7 +1206,7 @@ def do_cluster_disable(cs, args):
|
||||||
"""Disables clustered services."""
|
"""Disables clustered services."""
|
||||||
cluster = cs.clusters.update(args.name, args.binary, disabled=True,
|
cluster = cs.clusters.update(args.name, args.binary, disabled=True,
|
||||||
disabled_reason=args.reason)
|
disabled_reason=args.reason)
|
||||||
utils.print_dict(cluster.to_dict())
|
shell_utils.print_dict(cluster.to_dict())
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.24')
|
@api_versions.wraps('3.24')
|
||||||
|
@ -1251,12 +1251,12 @@ def do_work_cleanup(cs, args):
|
||||||
|
|
||||||
if cleaning:
|
if cleaning:
|
||||||
print('Following services will be cleaned:')
|
print('Following services will be cleaned:')
|
||||||
utils.print_list(cleaning, columns)
|
shell_utils.print_list(cleaning, columns)
|
||||||
|
|
||||||
if unavailable:
|
if unavailable:
|
||||||
print('There are no alternative nodes to do cleanup for the following '
|
print('There are no alternative nodes to do cleanup for the following '
|
||||||
'services:')
|
'services:')
|
||||||
utils.print_list(unavailable, columns)
|
shell_utils.print_list(unavailable, columns)
|
||||||
|
|
||||||
if not (cleaning or unavailable):
|
if not (cleaning or unavailable):
|
||||||
print('No cleanable services matched cleanup criteria.')
|
print('No cleanable services matched cleanup criteria.')
|
||||||
|
@ -1337,7 +1337,7 @@ def do_manage(cs, args):
|
||||||
volume = cs.volumes.get(volume.id)
|
volume = cs.volumes.get(volume.id)
|
||||||
info.update(volume._info)
|
info.update(volume._info)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.8')
|
@api_versions.wraps('3.8')
|
||||||
|
@ -1394,7 +1394,7 @@ def do_manageable_list(cs, args):
|
||||||
columns = ['reference', 'size', 'safe_to_manage']
|
columns = ['reference', 'size', 'safe_to_manage']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
utils.print_list(volumes, columns, sortby_index=None)
|
shell_utils.print_list(volumes, columns, sortby_index=None)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.13')
|
@api_versions.wraps('3.13')
|
||||||
|
@ -1427,7 +1427,7 @@ def do_group_list(cs, args):
|
||||||
groups = cs.groups.list(search_opts=search_opts)
|
groups = cs.groups.list(search_opts=search_opts)
|
||||||
|
|
||||||
columns = ['ID', 'Status', 'Name']
|
columns = ['ID', 'Status', 'Name']
|
||||||
utils.print_list(groups, columns)
|
shell_utils.print_list(groups, columns)
|
||||||
|
|
||||||
with cs.groups.completion_cache(
|
with cs.groups.completion_cache(
|
||||||
'uuid',
|
'uuid',
|
||||||
|
@ -1469,7 +1469,7 @@ def do_group_show(cs, args):
|
||||||
info.update(group._info)
|
info.update(group._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.13')
|
@api_versions.wraps('3.13')
|
||||||
|
@ -1505,7 +1505,7 @@ def do_group_create(cs, args):
|
||||||
info.update(group._info)
|
info.update(group._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
with cs.groups.completion_cache('uuid',
|
with cs.groups.completion_cache('uuid',
|
||||||
cinderclient.v3.groups.Group,
|
cinderclient.v3.groups.Group,
|
||||||
|
@ -1556,7 +1556,7 @@ def do_group_create_from_src(cs, args):
|
||||||
args.description)
|
args.description)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.13')
|
@api_versions.wraps('3.13')
|
||||||
|
@ -1696,7 +1696,8 @@ def do_group_list_replication_targets(cs, args):
|
||||||
cs, args.group).list_replication_targets()
|
cs, args.group).list_replication_targets()
|
||||||
rep_targets = replication_targets.get('replication_targets')
|
rep_targets = replication_targets.get('replication_targets')
|
||||||
if rep_targets and len(rep_targets) > 0:
|
if rep_targets and len(rep_targets) > 0:
|
||||||
utils.print_list(rep_targets, [key for key in rep_targets[0].keys()])
|
shell_utils.print_list(rep_targets,
|
||||||
|
[key for key in rep_targets[0].keys()])
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.14')
|
@api_versions.wraps('3.14')
|
||||||
|
@ -1743,7 +1744,7 @@ def do_group_snapshot_list(cs, args):
|
||||||
group_snapshots = cs.group_snapshots.list(search_opts=search_opts)
|
group_snapshots = cs.group_snapshots.list(search_opts=search_opts)
|
||||||
|
|
||||||
columns = ['ID', 'Status', 'Name']
|
columns = ['ID', 'Status', 'Name']
|
||||||
utils.print_list(group_snapshots, columns)
|
shell_utils.print_list(group_snapshots, columns)
|
||||||
AppendFilters.filters = []
|
AppendFilters.filters = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -1758,7 +1759,7 @@ def do_group_snapshot_show(cs, args):
|
||||||
info.update(group_snapshot._info)
|
info.update(group_snapshot._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.14')
|
@api_versions.wraps('3.14')
|
||||||
|
@ -1786,7 +1787,7 @@ def do_group_snapshot_create(cs, args):
|
||||||
info.update(group_snapshot._info)
|
info.update(group_snapshot._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.14')
|
@api_versions.wraps('3.14')
|
||||||
|
@ -1841,7 +1842,7 @@ def do_service_list(cs, args):
|
||||||
columns.append("Disabled Reason")
|
columns.append("Disabled Reason")
|
||||||
if cs.api_version.matches('3.49'):
|
if cs.api_version.matches('3.49'):
|
||||||
columns.extend(["Backend State"])
|
columns.extend(["Backend State"])
|
||||||
utils.print_list(result, columns)
|
shell_utils.print_list(result, columns)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.8')
|
@api_versions.wraps('3.8')
|
||||||
|
@ -1900,7 +1901,7 @@ def do_snapshot_manageable_list(cs, args):
|
||||||
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
utils.print_list(snapshots, columns, sortby_index=None)
|
shell_utils.print_list(snapshots, columns, sortby_index=None)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps("3.0")
|
@api_versions.wraps("3.0")
|
||||||
|
@ -1908,7 +1909,7 @@ def do_api_version(cs, args):
|
||||||
"""Display the server API version information."""
|
"""Display the server API version information."""
|
||||||
columns = ['ID', 'Status', 'Version', 'Min_version']
|
columns = ['ID', 'Status', 'Version', 'Min_version']
|
||||||
response = cs.services.server_api_version()
|
response = cs.services.server_api_version()
|
||||||
utils.print_list(response, columns)
|
shell_utils.print_list(response, columns)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps("3.40")
|
@api_versions.wraps("3.40")
|
||||||
|
@ -2010,7 +2011,7 @@ def do_message_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(messages, columns, sortby_index=sortby_index)
|
shell_utils.print_list(messages, columns, sortby_index=sortby_index)
|
||||||
AppendFilters.filters = []
|
AppendFilters.filters = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -2024,7 +2025,7 @@ def do_message_show(cs, args):
|
||||||
message = shell_utils.find_message(cs, args.message)
|
message = shell_utils.find_message(cs, args.message)
|
||||||
info.update(message._info)
|
info.update(message._info)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps("3.3")
|
@api_versions.wraps("3.3")
|
||||||
|
@ -2179,11 +2180,11 @@ def do_snapshot_list(cs, args):
|
||||||
# It's the server's responsibility to return the appropriate fields for the
|
# It's the server's responsibility to return the appropriate fields for the
|
||||||
# requested microversion, we present all known fields and skip those that
|
# requested microversion, we present all known fields and skip those that
|
||||||
# are missing.
|
# are missing.
|
||||||
utils.print_list(snapshots,
|
shell_utils.print_list(snapshots,
|
||||||
['ID', 'Volume ID', 'Status', 'Name', 'Size',
|
['ID', 'Volume ID', 'Status', 'Name', 'Size',
|
||||||
'Consumes Quota', 'User ID'],
|
'Consumes Quota', 'User ID'],
|
||||||
exclude_unavailable=True,
|
exclude_unavailable=True,
|
||||||
sortby_index=sortby_index)
|
sortby_index=sortby_index)
|
||||||
if show_count:
|
if show_count:
|
||||||
print("Snapshot in total: %s" % total_count)
|
print("Snapshot in total: %s" % total_count)
|
||||||
|
|
||||||
|
@ -2409,7 +2410,7 @@ def do_attachment_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(attachments, columns, sortby_index=sortby_index)
|
shell_utils.print_list(attachments, columns, sortby_index=sortby_index)
|
||||||
AppendFilters.filters = []
|
AppendFilters.filters = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -2422,13 +2423,13 @@ def do_attachment_show(cs, args):
|
||||||
attachment = cs.attachments.show(args.attachment)
|
attachment = cs.attachments.show(args.attachment)
|
||||||
attachment_dict = attachment.to_dict()
|
attachment_dict = attachment.to_dict()
|
||||||
connection_dict = attachment_dict.pop('connection_info', {})
|
connection_dict = attachment_dict.pop('connection_info', {})
|
||||||
utils.print_dict(attachment_dict)
|
shell_utils.print_dict(attachment_dict)
|
||||||
|
|
||||||
# TODO(jdg): Need to add checks here like admin/policy for displaying the
|
# TODO(jdg): Need to add checks here like admin/policy for displaying the
|
||||||
# connection_info, this is still experimental so we'll leave it enabled for
|
# connection_info, this is still experimental so we'll leave it enabled for
|
||||||
# now
|
# now
|
||||||
if connection_dict:
|
if connection_dict:
|
||||||
utils.print_dict(connection_dict)
|
shell_utils.print_dict(connection_dict)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.27')
|
@api_versions.wraps('3.27')
|
||||||
|
@ -2501,9 +2502,9 @@ def do_attachment_create(cs, args):
|
||||||
mode)
|
mode)
|
||||||
|
|
||||||
connector_dict = attachment.pop('connection_info', None)
|
connector_dict = attachment.pop('connection_info', None)
|
||||||
utils.print_dict(attachment)
|
shell_utils.print_dict(attachment)
|
||||||
if connector_dict:
|
if connector_dict:
|
||||||
utils.print_dict(connector_dict)
|
shell_utils.print_dict(connector_dict)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.27')
|
@api_versions.wraps('3.27')
|
||||||
|
@ -2555,9 +2556,9 @@ def do_attachment_update(cs, args):
|
||||||
connector)
|
connector)
|
||||||
attachment_dict = attachment.to_dict()
|
attachment_dict = attachment.to_dict()
|
||||||
connector_dict = attachment_dict.pop('connection_info', None)
|
connector_dict = attachment_dict.pop('connection_info', None)
|
||||||
utils.print_dict(attachment_dict)
|
shell_utils.print_dict(attachment_dict)
|
||||||
if connector_dict:
|
if connector_dict:
|
||||||
utils.print_dict(connector_dict)
|
shell_utils.print_dict(connector_dict)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.27')
|
@api_versions.wraps('3.27')
|
||||||
|
@ -2596,7 +2597,7 @@ def do_version_list(cs, args):
|
||||||
{'v': api_versions.MAX_VERSION})
|
{'v': api_versions.MAX_VERSION})
|
||||||
|
|
||||||
print("\nServer supported API versions:")
|
print("\nServer supported API versions:")
|
||||||
utils.print_list(result, columns)
|
shell_utils.print_list(result, columns)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.32')
|
@api_versions.wraps('3.32')
|
||||||
|
@ -2639,7 +2640,7 @@ def do_service_get_log(cs, args):
|
||||||
log_levels = cs.services.get_log_levels(args.binary, args.server,
|
log_levels = cs.services.get_log_levels(args.binary, args.server,
|
||||||
args.prefix)
|
args.prefix)
|
||||||
columns = ('Binary', 'Host', 'Prefix', 'Level')
|
columns = ('Binary', 'Host', 'Prefix', 'Level')
|
||||||
utils.print_list(log_levels, columns)
|
shell_utils.print_list(log_levels, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
|
@ -2716,7 +2717,7 @@ def do_backup_create(cs, args):
|
||||||
if 'links' in info:
|
if 'links' in info:
|
||||||
info.pop('links')
|
info.pop('links')
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
with cs.backups.completion_cache(
|
with cs.backups.completion_cache(
|
||||||
'uuid',
|
'uuid',
|
||||||
|
@ -2757,7 +2758,7 @@ def do_transfer_create(cs, args):
|
||||||
info.update(transfer._info)
|
info.update(transfer._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--all-tenants',
|
@utils.arg('--all-tenants',
|
||||||
|
@ -2805,7 +2806,7 @@ def do_transfer_list(cs, args):
|
||||||
|
|
||||||
transfers = cs.transfers.list(search_opts=search_opts, sort=sort)
|
transfers = cs.transfers.list(search_opts=search_opts, sort=sort)
|
||||||
columns = ['ID', 'Volume ID', 'Name']
|
columns = ['ID', 'Volume ID', 'Name']
|
||||||
utils.print_list(transfers, columns)
|
shell_utils.print_list(transfers, columns)
|
||||||
AppendFilters.filters = []
|
AppendFilters.filters = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -2822,7 +2823,7 @@ def do_default_type_set(cs, args):
|
||||||
project = args.project
|
project = args.project
|
||||||
|
|
||||||
default_type = cs.default_types.create(volume_type, project)
|
default_type = cs.default_types.create(volume_type, project)
|
||||||
utils.print_dict(default_type._info)
|
shell_utils.print_dict(default_type._info)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.62')
|
@api_versions.wraps('3.62')
|
||||||
|
@ -2837,9 +2838,9 @@ def do_default_type_list(cs, args):
|
||||||
default_types = cs.default_types.list(project_id)
|
default_types = cs.default_types.list(project_id)
|
||||||
columns = ['Volume Type ID', 'Project ID']
|
columns = ['Volume Type ID', 'Project ID']
|
||||||
if project_id:
|
if project_id:
|
||||||
utils.print_dict(default_types._info)
|
shell_utils.print_dict(default_types._info)
|
||||||
else:
|
else:
|
||||||
utils.print_list(default_types, columns)
|
shell_utils.print_list(default_types, columns)
|
||||||
|
|
||||||
|
|
||||||
@api_versions.wraps('3.62')
|
@api_versions.wraps('3.62')
|
||||||
|
|
|
@ -163,7 +163,7 @@ def do_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(volumes, key_list, exclude_unavailable=True,
|
shell_utils.print_list(volumes, key_list, exclude_unavailable=True,
|
||||||
sortby_index=sortby_index)
|
sortby_index=sortby_index)
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ def do_show(cs, args):
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
info = _translate_attachments(info)
|
info = _translate_attachments(info)
|
||||||
utils.print_dict(info,
|
shell_utils.print_dict(info,
|
||||||
formatters=['metadata', 'volume_image_metadata',
|
formatters=['metadata', 'volume_image_metadata',
|
||||||
'attachment_ids', 'attached_servers'])
|
'attachment_ids', 'attached_servers'])
|
||||||
|
|
||||||
|
|
||||||
class CheckSizeArgForCreate(argparse.Action):
|
class CheckSizeArgForCreate(argparse.Action):
|
||||||
|
@ -325,7 +325,7 @@ def do_create(cs, args):
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
info = _translate_attachments(info)
|
info = _translate_attachments(info)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--cascade',
|
@utils.arg('--cascade',
|
||||||
|
@ -581,9 +581,9 @@ def do_snapshot_list(cs, args):
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
|
|
||||||
utils.print_list(snapshots,
|
shell_utils.print_list(snapshots,
|
||||||
['ID', 'Volume ID', 'Status', 'Name', 'Size'],
|
['ID', 'Volume ID', 'Status', 'Name', 'Size'],
|
||||||
sortby_index=sortby_index)
|
sortby_index=sortby_index)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot',
|
@utils.arg('snapshot',
|
||||||
|
@ -714,7 +714,7 @@ def do_type_show(cs, args):
|
||||||
info.update(vtype._info)
|
info.update(vtype._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info, formatters=['extra_specs'])
|
shell_utils.print_dict(info, formatters=['extra_specs'])
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('id',
|
@utils.arg('id',
|
||||||
|
@ -746,7 +746,7 @@ def do_type_update(cs, args):
|
||||||
def do_extra_specs_list(cs, args):
|
def do_extra_specs_list(cs, args):
|
||||||
"""Lists current volume types and extra specs."""
|
"""Lists current volume types and extra specs."""
|
||||||
vtypes = cs.volume_types.list()
|
vtypes = cs.volume_types.list()
|
||||||
utils.print_list(vtypes, ['ID', 'Name', 'extra_specs'])
|
shell_utils.print_list(vtypes, ['ID', 'Name', 'extra_specs'])
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('name',
|
@utils.arg('name',
|
||||||
|
@ -821,7 +821,7 @@ def do_type_access_list(cs, args):
|
||||||
access_list = cs.volume_type_access.list(volume_type)
|
access_list = cs.volume_type_access.list(volume_type)
|
||||||
|
|
||||||
columns = ['Volume_type_ID', 'Project_ID']
|
columns = ['Volume_type_ID', 'Project_ID']
|
||||||
utils.print_list(access_list, columns)
|
shell_utils.print_list(access_list, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--volume-type', metavar='<volume_type>', required=True,
|
@utils.arg('--volume-type', metavar='<volume_type>', required=True,
|
||||||
|
@ -972,7 +972,7 @@ def do_absolute_limits(cs, args):
|
||||||
"""Lists absolute limits for a user."""
|
"""Lists absolute limits for a user."""
|
||||||
limits = cs.limits.get(args.tenant).absolute
|
limits = cs.limits.get(args.tenant).absolute
|
||||||
columns = ['Name', 'Value']
|
columns = ['Name', 'Value']
|
||||||
utils.print_list(limits, columns)
|
shell_utils.print_list(limits, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('tenant',
|
@utils.arg('tenant',
|
||||||
|
@ -984,7 +984,7 @@ def do_rate_limits(cs, args):
|
||||||
"""Lists rate limits for a user."""
|
"""Lists rate limits for a user."""
|
||||||
limits = cs.limits.get(args.tenant).rate
|
limits = cs.limits.get(args.tenant).rate
|
||||||
columns = ['Verb', 'URI', 'Value', 'Remain', 'Unit', 'Next_Available']
|
columns = ['Verb', 'URI', 'Value', 'Remain', 'Unit', 'Next_Available']
|
||||||
utils.print_list(limits, columns)
|
shell_utils.print_list(limits, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume',
|
@utils.arg('volume',
|
||||||
|
@ -1133,7 +1133,7 @@ def do_backup_create(cs, args):
|
||||||
if 'links' in info:
|
if 'links' in info:
|
||||||
info.pop('links')
|
info.pop('links')
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('backup', metavar='<backup>', help='Name or ID of backup.')
|
@utils.arg('backup', metavar='<backup>', help='Name or ID of backup.')
|
||||||
|
@ -1144,7 +1144,7 @@ def do_backup_show(cs, args):
|
||||||
info.update(backup._info)
|
info.update(backup._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--all-tenants',
|
@utils.arg('--all-tenants',
|
||||||
|
@ -1211,7 +1211,7 @@ def do_backup_list(cs, args):
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
else:
|
else:
|
||||||
sortby_index = 0
|
sortby_index = 0
|
||||||
utils.print_list(backups, columns, sortby_index=sortby_index)
|
shell_utils.print_list(backups, columns, sortby_index=sortby_index)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--force',
|
@utils.arg('--force',
|
||||||
|
@ -1273,7 +1273,7 @@ def do_backup_restore(cs, args):
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('backup', metavar='<backup>',
|
@utils.arg('backup', metavar='<backup>',
|
||||||
|
@ -1281,7 +1281,7 @@ def do_backup_restore(cs, args):
|
||||||
def do_backup_export(cs, args):
|
def do_backup_export(cs, args):
|
||||||
"""Export backup metadata record."""
|
"""Export backup metadata record."""
|
||||||
info = cs.backups.export_record(args.backup)
|
info = cs.backups.export_record(args.backup)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('backup_service', metavar='<backup_service>',
|
@utils.arg('backup_service', metavar='<backup_service>',
|
||||||
|
@ -1293,7 +1293,7 @@ def do_backup_import(cs, args):
|
||||||
info = cs.backups.import_record(args.backup_service, args.backup_url)
|
info = cs.backups.import_record(args.backup_service, args.backup_url)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
|
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('backup', metavar='<backup>', nargs='+',
|
@utils.arg('backup', metavar='<backup>', nargs='+',
|
||||||
|
@ -1345,7 +1345,7 @@ def do_transfer_create(cs, args):
|
||||||
info.update(transfer._info)
|
info.update(transfer._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('transfer', metavar='<transfer>',
|
@utils.arg('transfer', metavar='<transfer>',
|
||||||
|
@ -1367,7 +1367,7 @@ def do_transfer_accept(cs, args):
|
||||||
info.update(transfer._info)
|
info.update(transfer._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--all-tenants',
|
@utils.arg('--all-tenants',
|
||||||
|
@ -1391,7 +1391,7 @@ def do_transfer_list(cs, args):
|
||||||
}
|
}
|
||||||
transfers = cs.transfers.list(search_opts=search_opts)
|
transfers = cs.transfers.list(search_opts=search_opts)
|
||||||
columns = ['ID', 'Volume ID', 'Name']
|
columns = ['ID', 'Volume ID', 'Name']
|
||||||
utils.print_list(transfers, columns)
|
shell_utils.print_list(transfers, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('transfer', metavar='<transfer>',
|
@utils.arg('transfer', metavar='<transfer>',
|
||||||
|
@ -1403,7 +1403,7 @@ def do_transfer_show(cs, args):
|
||||||
info.update(transfer._info)
|
info.update(transfer._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
|
@ -1441,7 +1441,7 @@ def do_service_list(cs, args):
|
||||||
# so as not to add the column when the extended ext is not enabled.
|
# so as not to add the column when the extended ext is not enabled.
|
||||||
if result and hasattr(result[0], 'disabled_reason'):
|
if result and hasattr(result[0], 'disabled_reason'):
|
||||||
columns.append("Disabled Reason")
|
columns.append("Disabled Reason")
|
||||||
utils.print_list(result, columns)
|
shell_utils.print_list(result, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('host', metavar='<hostname>', help='Host name.')
|
@utils.arg('host', metavar='<hostname>', help='Host name.')
|
||||||
|
@ -1450,7 +1450,7 @@ def do_service_enable(cs, args):
|
||||||
"""Enables the service."""
|
"""Enables the service."""
|
||||||
result = cs.services.enable(args.host, args.binary)
|
result = cs.services.enable(args.host, args.binary)
|
||||||
columns = ["Host", "Binary", "Status"]
|
columns = ["Host", "Binary", "Status"]
|
||||||
utils.print_list([result], columns)
|
shell_utils.print_list([result], columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('host', metavar='<hostname>', help='Host name.')
|
@utils.arg('host', metavar='<hostname>', help='Host name.')
|
||||||
|
@ -1466,7 +1466,7 @@ def do_service_disable(cs, args):
|
||||||
args.reason)
|
args.reason)
|
||||||
else:
|
else:
|
||||||
result = cs.services.disable(args.host, args.binary)
|
result = cs.services.disable(args.host, args.binary)
|
||||||
utils.print_list([result], columns)
|
shell_utils.print_list([result], columns)
|
||||||
|
|
||||||
|
|
||||||
def treeizeAvailabilityZone(zone):
|
def treeizeAvailabilityZone(zone):
|
||||||
|
@ -1525,13 +1525,13 @@ def do_availability_zone_list(cs, _args):
|
||||||
for zone in availability_zones:
|
for zone in availability_zones:
|
||||||
result += treeizeAvailabilityZone(zone)
|
result += treeizeAvailabilityZone(zone)
|
||||||
shell_utils.translate_availability_zone_keys(result)
|
shell_utils.translate_availability_zone_keys(result)
|
||||||
utils.print_list(result, ['Name', 'Status'])
|
shell_utils.print_list(result, ['Name', 'Status'])
|
||||||
|
|
||||||
|
|
||||||
def do_encryption_type_list(cs, args):
|
def do_encryption_type_list(cs, args):
|
||||||
"""Shows encryption type details for volume types. Admin only."""
|
"""Shows encryption type details for volume types. Admin only."""
|
||||||
result = cs.volume_encryption_types.list()
|
result = cs.volume_encryption_types.list()
|
||||||
utils.print_list(result, ['Volume Type ID', 'Provider', 'Cipher',
|
shell_utils.print_list(result, ['Volume Type ID', 'Provider', 'Cipher',
|
||||||
'Key Size', 'Control Location'])
|
'Key Size', 'Control Location'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -1796,7 +1796,7 @@ def do_snapshot_metadata(cs, args):
|
||||||
|
|
||||||
if args.action == 'set':
|
if args.action == 'set':
|
||||||
metadata = snapshot.set_metadata(metadata)
|
metadata = snapshot.set_metadata(metadata)
|
||||||
utils.print_dict(metadata._info)
|
shell_utils.print_dict(metadata._info)
|
||||||
elif args.action == 'unset':
|
elif args.action == 'unset':
|
||||||
snapshot.delete_metadata(list(metadata.keys()))
|
snapshot.delete_metadata(list(metadata.keys()))
|
||||||
|
|
||||||
|
@ -1806,7 +1806,7 @@ def do_snapshot_metadata(cs, args):
|
||||||
def do_snapshot_metadata_show(cs, args):
|
def do_snapshot_metadata_show(cs, args):
|
||||||
"""Shows snapshot metadata."""
|
"""Shows snapshot metadata."""
|
||||||
snapshot = shell_utils.find_volume_snapshot(cs, args.snapshot)
|
snapshot = shell_utils.find_volume_snapshot(cs, args.snapshot)
|
||||||
utils.print_dict(snapshot._info['metadata'], 'Metadata-property')
|
shell_utils.print_dict(snapshot._info['metadata'], 'Metadata-property')
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
|
@ -1814,7 +1814,7 @@ def do_snapshot_metadata_show(cs, args):
|
||||||
def do_metadata_show(cs, args):
|
def do_metadata_show(cs, args):
|
||||||
"""Shows volume metadata."""
|
"""Shows volume metadata."""
|
||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
utils.print_dict(volume._info['metadata'], 'Metadata-property')
|
shell_utils.print_dict(volume._info['metadata'], 'Metadata-property')
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
|
@ -1823,7 +1823,7 @@ def do_image_metadata_show(cs, args):
|
||||||
"""Shows volume image metadata."""
|
"""Shows volume image metadata."""
|
||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
resp, body = volume.show_image_metadata(volume)
|
resp, body = volume.show_image_metadata(volume)
|
||||||
utils.print_dict(body['metadata'], 'Metadata-property')
|
shell_utils.print_dict(body['metadata'], 'Metadata-property')
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume',
|
@utils.arg('volume',
|
||||||
|
@ -1839,7 +1839,7 @@ def do_metadata_update_all(cs, args):
|
||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
metadata = shell_utils.extract_metadata(args)
|
metadata = shell_utils.extract_metadata(args)
|
||||||
metadata = volume.update_all_metadata(metadata)
|
metadata = volume.update_all_metadata(metadata)
|
||||||
utils.print_dict(metadata['metadata'], 'Metadata-property')
|
shell_utils.print_dict(metadata['metadata'], 'Metadata-property')
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot',
|
@utils.arg('snapshot',
|
||||||
|
@ -1855,7 +1855,7 @@ def do_snapshot_metadata_update_all(cs, args):
|
||||||
snapshot = shell_utils.find_volume_snapshot(cs, args.snapshot)
|
snapshot = shell_utils.find_volume_snapshot(cs, args.snapshot)
|
||||||
metadata = shell_utils.extract_metadata(args)
|
metadata = shell_utils.extract_metadata(args)
|
||||||
metadata = snapshot.update_all_metadata(metadata)
|
metadata = snapshot.update_all_metadata(metadata)
|
||||||
utils.print_dict(metadata)
|
shell_utils.print_dict(metadata)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>', help='ID of volume to update.')
|
@utils.arg('volume', metavar='<volume>', help='ID of volume to update.')
|
||||||
|
@ -1954,7 +1954,7 @@ def do_manage(cs, args):
|
||||||
volume = cs.volumes.get(volume.id)
|
volume = cs.volumes.get(volume.id)
|
||||||
info.update(volume._info)
|
info.update(volume._info)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
|
@ -1978,7 +1978,7 @@ def do_consisgroup_list(cs, args):
|
||||||
consistencygroups = cs.consistencygroups.list()
|
consistencygroups = cs.consistencygroups.list()
|
||||||
|
|
||||||
columns = ['ID', 'Status', 'Name']
|
columns = ['ID', 'Status', 'Name']
|
||||||
utils.print_list(consistencygroups, columns)
|
shell_utils.print_list(consistencygroups, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('consistencygroup',
|
@utils.arg('consistencygroup',
|
||||||
|
@ -1992,7 +1992,7 @@ def do_consisgroup_show(cs, args):
|
||||||
info.update(consistencygroup._info)
|
info.update(consistencygroup._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volumetypes',
|
@utils.arg('volumetypes',
|
||||||
|
@ -2023,7 +2023,7 @@ def do_consisgroup_create(cs, args):
|
||||||
info.update(consistencygroup._info)
|
info.update(consistencygroup._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--cgsnapshot',
|
@utils.arg('--cgsnapshot',
|
||||||
|
@ -2061,7 +2061,7 @@ def do_consisgroup_create_from_src(cs, args):
|
||||||
args.description)
|
args.description)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('consistencygroup',
|
@utils.arg('consistencygroup',
|
||||||
|
@ -2166,7 +2166,7 @@ def do_cgsnapshot_list(cs, args):
|
||||||
cgsnapshots = cs.cgsnapshots.list(search_opts=search_opts)
|
cgsnapshots = cs.cgsnapshots.list(search_opts=search_opts)
|
||||||
|
|
||||||
columns = ['ID', 'Status', 'Name']
|
columns = ['ID', 'Status', 'Name']
|
||||||
utils.print_list(cgsnapshots, columns)
|
shell_utils.print_list(cgsnapshots, columns)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('cgsnapshot',
|
@utils.arg('cgsnapshot',
|
||||||
|
@ -2179,7 +2179,7 @@ def do_cgsnapshot_show(cs, args):
|
||||||
info.update(cgsnapshot._info)
|
info.update(cgsnapshot._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('consistencygroup',
|
@utils.arg('consistencygroup',
|
||||||
|
@ -2207,7 +2207,7 @@ def do_cgsnapshot_create(cs, args):
|
||||||
info.update(cgsnapshot._info)
|
info.update(cgsnapshot._info)
|
||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('cgsnapshot',
|
@utils.arg('cgsnapshot',
|
||||||
|
@ -2241,7 +2241,7 @@ def do_get_pools(cs, args):
|
||||||
backend['name'] = info['name']
|
backend['name'] = info['name']
|
||||||
if args.detail:
|
if args.detail:
|
||||||
backend.update(info['capabilities'])
|
backend.update(info['capabilities'])
|
||||||
utils.print_dict(backend)
|
shell_utils.print_dict(backend)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('host',
|
@utils.arg('host',
|
||||||
|
@ -2256,9 +2256,9 @@ def do_get_capabilities(cs, args):
|
||||||
infos.update(capabilities._info)
|
infos.update(capabilities._info)
|
||||||
|
|
||||||
prop = infos.pop('properties', None)
|
prop = infos.pop('properties', None)
|
||||||
utils.print_dict(infos, "Volume stats")
|
shell_utils.print_dict(infos, "Volume stats")
|
||||||
utils.print_dict(prop, "Backend properties",
|
shell_utils.print_dict(prop, "Backend properties",
|
||||||
formatters=sorted(prop.keys()))
|
formatters=sorted(prop.keys()))
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume',
|
@utils.arg('volume',
|
||||||
|
@ -2308,7 +2308,7 @@ def do_snapshot_manage(cs, args):
|
||||||
snapshot = cs.volume_snapshots.get(snapshot.id)
|
snapshot = cs.volume_snapshots.get(snapshot.id)
|
||||||
info.update(snapshot._info)
|
info.update(snapshot._info)
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
shell_utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot', metavar='<snapshot>',
|
@utils.arg('snapshot', metavar='<snapshot>',
|
||||||
|
@ -2378,7 +2378,7 @@ def do_manageable_list(cs, args):
|
||||||
columns = ['reference', 'size', 'safe_to_manage']
|
columns = ['reference', 'size', 'safe_to_manage']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
utils.print_list(volumes, columns, sortby_index=None)
|
shell_utils.print_list(volumes, columns, sortby_index=None)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('host',
|
@utils.arg('host',
|
||||||
|
@ -2422,4 +2422,4 @@ def do_snapshot_manageable_list(cs, args):
|
||||||
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
columns = ['reference', 'size', 'safe_to_manage', 'source_reference']
|
||||||
if detailed:
|
if detailed:
|
||||||
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
columns.extend(['reason_not_safe', 'cinder_id', 'extra_info'])
|
||||||
utils.print_list(snapshots, columns, sortby_index=None)
|
shell_utils.print_list(snapshots, columns, sortby_index=None)
|
||||||
|
|
Loading…
Reference in New Issue