Merge "Add missed 'Server ID' output in attachment-list" into stable/queens
This commit is contained in:
commit
61fb7b4452
|
@ -30,6 +30,18 @@ fake_attachment = {'attachment': {
|
||||||
'instance': 'e84fda45-4de4-4ce4-8f39-fc9d3b0aa05e',
|
'instance': 'e84fda45-4de4-4ce4-8f39-fc9d3b0aa05e',
|
||||||
'volume_id': '557ad76c-ce54-40a3-9e91-c40d21665cc3', }}
|
'volume_id': '557ad76c-ce54-40a3-9e91-c40d21665cc3', }}
|
||||||
|
|
||||||
|
fake_attachment_list = {'attachments': [
|
||||||
|
{'instance': 'instance_1',
|
||||||
|
'name': 'attachment-1',
|
||||||
|
'volume_id': 'fake_volume_1',
|
||||||
|
'status': 'reserved',
|
||||||
|
'id': 'attachmentid_1'},
|
||||||
|
{'instance': 'instance_2',
|
||||||
|
'name': 'attachment-2',
|
||||||
|
'volume_id': 'fake_volume_2',
|
||||||
|
'status': 'reserverd',
|
||||||
|
'id': 'attachmentid_2'}]}
|
||||||
|
|
||||||
fake_connection_info = {
|
fake_connection_info = {
|
||||||
'auth_password': 'i6h9E5HQqSkcGX3H',
|
'auth_password': 'i6h9E5HQqSkcGX3H',
|
||||||
'attachment_id': 'a232e9ae',
|
'attachment_id': 'a232e9ae',
|
||||||
|
@ -289,15 +301,7 @@ class FakeHTTPClient(fake_v2.FakeHTTPClient):
|
||||||
return (200, {}, fake_attachment)
|
return (200, {}, fake_attachment)
|
||||||
|
|
||||||
def get_attachments(self, **kw):
|
def get_attachments(self, **kw):
|
||||||
return (200, {}, {
|
return (200, {}, fake_attachment_list)
|
||||||
'attachments': [{'instance': 1,
|
|
||||||
'name': 'attachment-1',
|
|
||||||
'volume_id': 'fake_volume_1',
|
|
||||||
'status': 'reserved'},
|
|
||||||
{'instance': 2,
|
|
||||||
'name': 'attachment-2',
|
|
||||||
'volume_id': 'fake_volume_2',
|
|
||||||
'status': 'reserverd'}]})
|
|
||||||
|
|
||||||
def post_attachments_a232e9ae_action(self, **kw): # noqa: E501
|
def post_attachments_a232e9ae_action(self, **kw): # noqa: E501
|
||||||
attached_fake = fake_attachment
|
attached_fake = fake_attachment
|
||||||
|
|
|
@ -51,6 +51,7 @@ from cinderclient import client
|
||||||
from cinderclient import exceptions
|
from cinderclient import exceptions
|
||||||
from cinderclient import shell
|
from cinderclient import shell
|
||||||
from cinderclient import utils as cinderclient_utils
|
from cinderclient import utils as cinderclient_utils
|
||||||
|
from cinderclient.v3 import attachments
|
||||||
from cinderclient.v3 import volume_snapshots
|
from cinderclient.v3 import volume_snapshots
|
||||||
from cinderclient.v3 import volumes
|
from cinderclient.v3 import volumes
|
||||||
|
|
||||||
|
@ -336,6 +337,21 @@ 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.object(cinderclient.v3.attachments.VolumeAttachmentManager,
|
||||||
|
'list')
|
||||||
|
def test_attachment_list_setattr(self, mock_list, mock_print):
|
||||||
|
command = '--os-volume-api-version 3.27 attachment-list '
|
||||||
|
fake_attachment = [attachments.VolumeAttachment(mock.ANY, attachment)
|
||||||
|
for attachment in fakes.fake_attachment_list['attachments']]
|
||||||
|
mock_list.return_value = fake_attachment
|
||||||
|
self.run_command(command)
|
||||||
|
for attach in fake_attachment:
|
||||||
|
setattr(attach, 'server_id', getattr(attach, 'instance'))
|
||||||
|
columns = ['ID', 'Volume ID', 'Status', 'Server ID']
|
||||||
|
mock_print.assert_called_once_with(fake_attachment, columns,
|
||||||
|
sortby_index=0)
|
||||||
|
|
||||||
def test_revert_to_snapshot(self):
|
def test_revert_to_snapshot(self):
|
||||||
original = cinderclient_utils.find_resource
|
original = cinderclient_utils.find_resource
|
||||||
|
|
||||||
|
|
|
@ -2069,6 +2069,8 @@ def do_attachment_list(cs, args):
|
||||||
marker=args.marker,
|
marker=args.marker,
|
||||||
limit=args.limit,
|
limit=args.limit,
|
||||||
sort=args.sort)
|
sort=args.sort)
|
||||||
|
for attachment in attachments:
|
||||||
|
setattr(attachment, 'server_id', getattr(attachment, 'instance', None))
|
||||||
columns = ['ID', 'Volume ID', 'Status', 'Server ID']
|
columns = ['ID', 'Volume ID', 'Status', 'Server ID']
|
||||||
if args.sort:
|
if args.sort:
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
|
|
Loading…
Reference in New Issue