summaryrefslogtreecommitdiff
path: root/cinderclient/tests
diff options
context:
space:
mode:
authorJohn Griffith <john.griffith8@gmail.com>2018-04-06 12:51:24 -0600
committerSean McGinnis <sean.mcginnis@gmail.com>2018-07-17 15:58:46 -0500
commit90727008876ef35d3135d494aeb45bdf2f63e8fc (patch)
tree876df9b96f2425aef73b44b9c1e767d12031c3c1 /cinderclient/tests
parent8f933a9a341cec9cf87b4a4d3bf7da80b24c18ef (diff)
downloadpython-cinderclient-90727008876ef35d3135d494aeb45bdf2f63e8fc.tar.gz
Add mode option to attachment-create
We introduce a mode option in attachment-create starting with microversion 3.54. The mode option is the new/preferred way of setting ro mode (as opposed to admin-metadata). This patch adds the support for the mode option to the client for endpoints that support 3.54. Depends-on: https://review.openstack.org/532702/ Change-Id: I22cfddd0192c4a72b8f844f23d1fa51b96c57e06
Diffstat (limited to 'cinderclient/tests')
-rw-r--r--cinderclient/tests/unit/v3/test_attachments.py3
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py43
2 files changed, 45 insertions, 1 deletions
diff --git a/cinderclient/tests/unit/v3/test_attachments.py b/cinderclient/tests/unit/v3/test_attachments.py
index 2ac6486..1802334 100644
--- a/cinderclient/tests/unit/v3/test_attachments.py
+++ b/cinderclient/tests/unit/v3/test_attachments.py
@@ -26,7 +26,8 @@ class AttachmentsTest(utils.TestCase):
att = cs.attachments.create(
'e84fda45-4de4-4ce4-8f39-fc9d3b0aa05e',
{},
- '557ad76c-ce54-40a3-9e91-c40d21665cc3')
+ '557ad76c-ce54-40a3-9e91-c40d21665cc3',
+ 'null')
cs.assert_called('POST', '/attachments')
self.assertEqual(fakes.fake_attachment['attachment'], att)
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index 43fb097..cdf1f36 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -324,6 +324,49 @@ class ShellTest(utils.TestCase):
self.assertTrue(mock_find_volume.called)
self.assert_called('POST', '/attachments', body=expected)
+ @ddt.data({'cmd': '1234 1233',
+ 'body': {'instance_uuid': '1233',
+ 'connector': {},
+ 'volume_uuid': '1234',
+ 'mode': 'ro'}},
+ {'cmd': '1234 1233 '
+ '--connect True '
+ '--ip 10.23.12.23 --host server01 '
+ '--platform x86_xx '
+ '--ostype 123 '
+ '--multipath true '
+ '--mountpoint /123 '
+ '--initiator aabbccdd',
+ 'body': {'instance_uuid': '1233',
+ 'connector': {'ip': '10.23.12.23',
+ 'host': 'server01',
+ 'os_type': '123',
+ 'multipath': 'true',
+ 'mountpoint': '/123',
+ 'initiator': 'aabbccdd',
+ 'platform': 'x86_xx'},
+ 'volume_uuid': '1234',
+ 'mode': 'ro'}},
+ {'cmd': 'abc 1233',
+ 'body': {'instance_uuid': '1233',
+ 'connector': {},
+ 'volume_uuid': '1234',
+ 'mode': 'ro'}})
+ @mock.patch('cinderclient.utils.find_resource')
+ @ddt.unpack
+ def test_attachment_create_with_mode(self, mock_find_volume, cmd, body):
+ mock_find_volume.return_value = volumes.Volume(self,
+ {'id': '1234'},
+ loaded=True)
+ command = ('--os-volume-api-version 3.54 '
+ 'attachment-create '
+ '--mode ro ')
+ command += cmd
+ self.run_command(command)
+ expected = {'attachment': body}
+ self.assertTrue(mock_find_volume.called)
+ 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'},