Merge "Cinder attachment-* does not support names"
This commit is contained in:
@@ -23,6 +23,7 @@ import six
|
|||||||
from cinderclient import client
|
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.v3 import volumes
|
from cinderclient.v3 import volumes
|
||||||
from cinderclient.v3 import volume_snapshots
|
from cinderclient.v3 import volume_snapshots
|
||||||
from cinderclient.tests.unit import utils
|
from cinderclient.tests.unit import utils
|
||||||
@@ -248,15 +249,36 @@ class ShellTest(utils.TestCase):
|
|||||||
'mountpoint': '/123',
|
'mountpoint': '/123',
|
||||||
'initiator': 'aabbccdd',
|
'initiator': 'aabbccdd',
|
||||||
'platform': 'x86_xx'},
|
'platform': 'x86_xx'},
|
||||||
|
'volume_uuid': '1234'}},
|
||||||
|
{'cmd': 'abc 1233',
|
||||||
|
'body': {'instance_uuid': '1233',
|
||||||
|
'connector': {},
|
||||||
'volume_uuid': '1234'}})
|
'volume_uuid': '1234'}})
|
||||||
|
@mock.patch.object(cinderclient_utils, 'find_volume')
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
def test_attachment_create(self, cmd, body):
|
def test_attachment_create(self, mock_find_volume, cmd, body):
|
||||||
|
mock_find_volume.return_value = volumes.Volume(self,
|
||||||
|
{'id': '1234'},
|
||||||
|
loaded=True)
|
||||||
command = '--os-volume-api-version 3.27 attachment-create '
|
command = '--os-volume-api-version 3.27 attachment-create '
|
||||||
command += cmd
|
command += cmd
|
||||||
self.run_command(command)
|
self.run_command(command)
|
||||||
expected = {'attachment': body}
|
expected = {'attachment': body}
|
||||||
|
self.assertTrue(mock_find_volume.called)
|
||||||
self.assert_called('POST', '/attachments', body=expected)
|
self.assert_called('POST', '/attachments', body=expected)
|
||||||
|
|
||||||
|
@mock.patch.object(volumes.VolumeManager, 'findall')
|
||||||
|
def test_attachment_create_duplicate_name_vol(self, mock_findall):
|
||||||
|
found = [volumes.Volume(self, {'id': '7654', 'name': 'abc'},
|
||||||
|
loaded=True),
|
||||||
|
volumes.Volume(self, {'id': '9876', 'name': 'abc'},
|
||||||
|
loaded=True)]
|
||||||
|
mock_findall.return_value = found
|
||||||
|
self.assertRaises(exceptions.CommandError,
|
||||||
|
self.run_command,
|
||||||
|
'--os-volume-api-version 3.27 '
|
||||||
|
'attachment-create abc 789')
|
||||||
|
|
||||||
@ddt.data({'cmd': '',
|
@ddt.data({'cmd': '',
|
||||||
'expected': ''},
|
'expected': ''},
|
||||||
{'cmd': '--volume-id 1234',
|
{'cmd': '--volume-id 1234',
|
||||||
|
|||||||
@@ -1828,7 +1828,8 @@ def do_attachment_create(cs, args):
|
|||||||
'os_type': args.ostype,
|
'os_type': args.ostype,
|
||||||
'multipath': args.multipath,
|
'multipath': args.multipath,
|
||||||
'mountpoint': args.mountpoint}
|
'mountpoint': args.mountpoint}
|
||||||
attachment = cs.attachments.create(args.volume,
|
volume = utils.find_volume(cs, args.volume)
|
||||||
|
attachment = cs.attachments.create(volume.id,
|
||||||
connector,
|
connector,
|
||||||
args.server_id)
|
args.server_id)
|
||||||
connector_dict = attachment.pop('connection_info', None)
|
connector_dict = attachment.pop('connection_info', None)
|
||||||
|
|||||||
Reference in New Issue
Block a user