summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openstackclient/tests/unit/volume/test_find_resource.py4
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume.py11
-rw-r--r--openstackclient/volume/client.py21
-rw-r--r--openstackclient/volume/v2/volume.py4
4 files changed, 19 insertions, 21 deletions
diff --git a/openstackclient/tests/unit/volume/test_find_resource.py b/openstackclient/tests/unit/volume/test_find_resource.py
index dbf9592..60591ef 100644
--- a/openstackclient/tests/unit/volume/test_find_resource.py
+++ b/openstackclient/tests/unit/volume/test_find_resource.py
@@ -15,8 +15,8 @@
15 15
16import mock 16import mock
17 17
18from cinderclient.v1 import volume_snapshots 18from cinderclient.v3 import volume_snapshots
19from cinderclient.v1 import volumes 19from cinderclient.v3 import volumes
20from osc_lib import exceptions 20from osc_lib import exceptions
21from osc_lib import utils 21from osc_lib import utils
22 22
diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py
index bb6263b..183fb22 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume.py
@@ -131,7 +131,6 @@ class TestVolumeCreate(TestVolume):
131 imageRef=None, 131 imageRef=None,
132 source_volid=None, 132 source_volid=None,
133 consistencygroup_id=None, 133 consistencygroup_id=None,
134 multiattach=False,
135 scheduler_hints=None, 134 scheduler_hints=None,
136 ) 135 )
137 136
@@ -149,7 +148,6 @@ class TestVolumeCreate(TestVolume):
149 '--availability-zone', self.new_volume.availability_zone, 148 '--availability-zone', self.new_volume.availability_zone,
150 '--consistency-group', consistency_group.id, 149 '--consistency-group', consistency_group.id,
151 '--hint', 'k=v', 150 '--hint', 'k=v',
152 '--multi-attach',
153 self.new_volume.name, 151 self.new_volume.name,
154 ] 152 ]
155 verifylist = [ 153 verifylist = [
@@ -159,7 +157,6 @@ class TestVolumeCreate(TestVolume):
159 ('availability_zone', self.new_volume.availability_zone), 157 ('availability_zone', self.new_volume.availability_zone),
160 ('consistency_group', consistency_group.id), 158 ('consistency_group', consistency_group.id),
161 ('hint', {'k': 'v'}), 159 ('hint', {'k': 'v'}),
162 ('multi_attach', True),
163 ('name', self.new_volume.name), 160 ('name', self.new_volume.name),
164 ] 161 ]
165 parsed_args = self.check_parser(self.cmd, arglist, verifylist) 162 parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -180,7 +177,6 @@ class TestVolumeCreate(TestVolume):
180 imageRef=None, 177 imageRef=None,
181 source_volid=None, 178 source_volid=None,
182 consistencygroup_id=consistency_group.id, 179 consistencygroup_id=consistency_group.id,
183 multiattach=True,
184 scheduler_hints={'k': 'v'}, 180 scheduler_hints={'k': 'v'},
185 ) 181 )
186 182
@@ -251,7 +247,6 @@ class TestVolumeCreate(TestVolume):
251 imageRef=None, 247 imageRef=None,
252 source_volid=None, 248 source_volid=None,
253 consistencygroup_id=None, 249 consistencygroup_id=None,
254 multiattach=False,
255 scheduler_hints=None, 250 scheduler_hints=None,
256 ) 251 )
257 252
@@ -290,7 +285,6 @@ class TestVolumeCreate(TestVolume):
290 imageRef=image.id, 285 imageRef=image.id,
291 source_volid=None, 286 source_volid=None,
292 consistencygroup_id=None, 287 consistencygroup_id=None,
293 multiattach=False,
294 scheduler_hints=None, 288 scheduler_hints=None,
295 ) 289 )
296 290
@@ -329,7 +323,6 @@ class TestVolumeCreate(TestVolume):
329 imageRef=image.id, 323 imageRef=image.id,
330 source_volid=None, 324 source_volid=None,
331 consistencygroup_id=None, 325 consistencygroup_id=None,
332 multiattach=False,
333 scheduler_hints=None, 326 scheduler_hints=None,
334 ) 327 )
335 328
@@ -367,7 +360,6 @@ class TestVolumeCreate(TestVolume):
367 imageRef=None, 360 imageRef=None,
368 source_volid=None, 361 source_volid=None,
369 consistencygroup_id=None, 362 consistencygroup_id=None,
370 multiattach=False,
371 scheduler_hints=None, 363 scheduler_hints=None,
372 ) 364 )
373 365
@@ -406,7 +398,6 @@ class TestVolumeCreate(TestVolume):
406 imageRef=None, 398 imageRef=None,
407 source_volid=None, 399 source_volid=None,
408 consistencygroup_id=None, 400 consistencygroup_id=None,
409 multiattach=False,
410 scheduler_hints=None, 401 scheduler_hints=None,
411 ) 402 )
412 403
@@ -449,7 +440,6 @@ class TestVolumeCreate(TestVolume):
449 imageRef=None, 440 imageRef=None,
450 source_volid=None, 441 source_volid=None,
451 consistencygroup_id=None, 442 consistencygroup_id=None,
452 multiattach=False,
453 scheduler_hints=None, 443 scheduler_hints=None,
454 ) 444 )
455 445
@@ -501,7 +491,6 @@ class TestVolumeCreate(TestVolume):
501 imageRef=None, 491 imageRef=None,
502 source_volid=None, 492 source_volid=None,
503 consistencygroup_id=None, 493 consistencygroup_id=None,
504 multiattach=False,
505 scheduler_hints=None, 494 scheduler_hints=None,
506 ) 495 )
507 496
diff --git a/openstackclient/volume/client.py b/openstackclient/volume/client.py
index c4b0dfc..e0e670a 100644
--- a/openstackclient/volume/client.py
+++ b/openstackclient/volume/client.py
@@ -37,13 +37,20 @@ def make_client(instance):
37 37
38 # Defer client imports until we actually need them 38 # Defer client imports until we actually need them
39 from cinderclient import extension 39 from cinderclient import extension
40 from cinderclient.v1.contrib import list_extensions 40 from cinderclient.v3.contrib import list_extensions
41 from cinderclient.v1 import volume_snapshots 41 from cinderclient.v3 import volume_snapshots
42 from cinderclient.v1 import volumes 42 from cinderclient.v3 import volumes
43 43
44 # Monkey patch for v1 cinderclient 44 # Try a small import to check if cinderclient v1 is supported
45 volumes.Volume.NAME_ATTR = 'display_name' 45 try:
46 volume_snapshots.Snapshot.NAME_ATTR = 'display_name' 46 from cinderclient.v1 import services # noqa
47 except Exception:
48 del API_VERSIONS['1']
49
50 if instance._api_version[API_NAME] == '1':
51 # Monkey patch for v1 cinderclient
52 volumes.Volume.NAME_ATTR = 'display_name'
53 volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
47 54
48 volume_client = utils.get_client_class( 55 volume_client = utils.get_client_class(
49 API_NAME, 56 API_NAME,
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index 8ab61d2..7a5c207 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -212,6 +212,9 @@ class CreateVolume(command.ShowOne):
212 raise exceptions.CommandError( 212 raise exceptions.CommandError(
213 _("ERROR: --user is deprecated, please use" 213 _("ERROR: --user is deprecated, please use"
214 " --os-username instead.")) 214 " --os-username instead."))
215 if parsed_args.multi_attach:
216 LOG.warning(_("'--multi-attach' option is no longer supported by "
217 "the block storage service."))
215 218
216 volume = volume_client.volumes.create( 219 volume = volume_client.volumes.create(
217 size=size, 220 size=size,
@@ -224,7 +227,6 @@ class CreateVolume(command.ShowOne):
224 imageRef=image, 227 imageRef=image,
225 source_volid=source_volume, 228 source_volid=source_volume,
226 consistencygroup_id=consistency_group, 229 consistencygroup_id=consistency_group,
227 multiattach=parsed_args.multi_attach,
228 scheduler_hints=parsed_args.hint, 230 scheduler_hints=parsed_args.hint,
229 ) 231 )
230 232