Merge "Handle not having cinderclient.v1 available"
This commit is contained in:
commit
02f492ae4c
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from cinderclient.v1 import volume_snapshots
|
from cinderclient.v3 import volume_snapshots
|
||||||
from cinderclient.v1 import volumes
|
from cinderclient.v3 import volumes
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
|
|
||||||
|
@ -131,7 +131,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,7 +148,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
'--availability-zone', self.new_volume.availability_zone,
|
'--availability-zone', self.new_volume.availability_zone,
|
||||||
'--consistency-group', consistency_group.id,
|
'--consistency-group', consistency_group.id,
|
||||||
'--hint', 'k=v',
|
'--hint', 'k=v',
|
||||||
'--multi-attach',
|
|
||||||
self.new_volume.name,
|
self.new_volume.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
@ -159,7 +157,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
('availability_zone', self.new_volume.availability_zone),
|
('availability_zone', self.new_volume.availability_zone),
|
||||||
('consistency_group', consistency_group.id),
|
('consistency_group', consistency_group.id),
|
||||||
('hint', {'k': 'v'}),
|
('hint', {'k': 'v'}),
|
||||||
('multi_attach', True),
|
|
||||||
('name', self.new_volume.name),
|
('name', self.new_volume.name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -180,7 +177,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=consistency_group.id,
|
consistencygroup_id=consistency_group.id,
|
||||||
multiattach=True,
|
|
||||||
scheduler_hints={'k': 'v'},
|
scheduler_hints={'k': 'v'},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -251,7 +247,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -290,7 +285,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=image.id,
|
imageRef=image.id,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -329,7 +323,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=image.id,
|
imageRef=image.id,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -367,7 +360,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -406,7 +398,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -449,7 +440,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -501,7 +491,6 @@ class TestVolumeCreate(TestVolume):
|
|||||||
imageRef=None,
|
imageRef=None,
|
||||||
source_volid=None,
|
source_volid=None,
|
||||||
consistencygroup_id=None,
|
consistencygroup_id=None,
|
||||||
multiattach=False,
|
|
||||||
scheduler_hints=None,
|
scheduler_hints=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,13 +37,20 @@ def make_client(instance):
|
|||||||
|
|
||||||
# Defer client imports until we actually need them
|
# Defer client imports until we actually need them
|
||||||
from cinderclient import extension
|
from cinderclient import extension
|
||||||
from cinderclient.v1.contrib import list_extensions
|
from cinderclient.v3.contrib import list_extensions
|
||||||
from cinderclient.v1 import volume_snapshots
|
from cinderclient.v3 import volume_snapshots
|
||||||
from cinderclient.v1 import volumes
|
from cinderclient.v3 import volumes
|
||||||
|
|
||||||
# Monkey patch for v1 cinderclient
|
# Try a small import to check if cinderclient v1 is supported
|
||||||
volumes.Volume.NAME_ATTR = 'display_name'
|
try:
|
||||||
volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
|
from cinderclient.v1 import services # noqa
|
||||||
|
except Exception:
|
||||||
|
del API_VERSIONS['1']
|
||||||
|
|
||||||
|
if instance._api_version[API_NAME] == '1':
|
||||||
|
# Monkey patch for v1 cinderclient
|
||||||
|
volumes.Volume.NAME_ATTR = 'display_name'
|
||||||
|
volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
|
||||||
|
|
||||||
volume_client = utils.get_client_class(
|
volume_client = utils.get_client_class(
|
||||||
API_NAME,
|
API_NAME,
|
||||||
|
@ -212,6 +212,9 @@ class CreateVolume(command.ShowOne):
|
|||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
_("ERROR: --user is deprecated, please use"
|
_("ERROR: --user is deprecated, please use"
|
||||||
" --os-username instead."))
|
" --os-username instead."))
|
||||||
|
if parsed_args.multi_attach:
|
||||||
|
LOG.warning(_("'--multi-attach' option is no longer supported by "
|
||||||
|
"the block storage service."))
|
||||||
|
|
||||||
volume = volume_client.volumes.create(
|
volume = volume_client.volumes.create(
|
||||||
size=size,
|
size=size,
|
||||||
@ -224,7 +227,6 @@ class CreateVolume(command.ShowOne):
|
|||||||
imageRef=image,
|
imageRef=image,
|
||||||
source_volid=source_volume,
|
source_volid=source_volume,
|
||||||
consistencygroup_id=consistency_group,
|
consistencygroup_id=consistency_group,
|
||||||
multiattach=parsed_args.multi_attach,
|
|
||||||
scheduler_hints=parsed_args.hint,
|
scheduler_hints=parsed_args.hint,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user