[OSC] Don't use default type with snapshot clones
When creating a share with OSC, the client looks up the default share type when one is unspecified. However, one doesn't need to specify a share type when creating a share from a snapshot. Change-Id: I39984c2b953b16d2cdbc92ecaf5f3b701a33b283 Closes-Bug: #1980985 Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
parent
992a94247a
commit
06f7ea6255
|
@ -156,8 +156,9 @@ class CreateShare(command.ShowOne):
|
||||||
'--share-type',
|
'--share-type',
|
||||||
metavar='<share-type>',
|
metavar='<share-type>',
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Optional share type. Use of optional shares type '
|
help=_('The share type to create the share with. If not '
|
||||||
'is deprecated. (Default=Default)')
|
'specified, unless creating from a snapshot, the default '
|
||||||
|
'share type will be used.')
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--availability-zone',
|
'--availability-zone',
|
||||||
|
@ -191,7 +192,6 @@ class CreateShare(command.ShowOne):
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
# TODO(s0ru): the table shows 'Field', 'Value'
|
|
||||||
share_client = self.app.client_manager.share
|
share_client = self.app.client_manager.share
|
||||||
|
|
||||||
if parsed_args.name:
|
if parsed_args.name:
|
||||||
|
@ -199,10 +199,11 @@ class CreateShare(command.ShowOne):
|
||||||
raise apiclient_exceptions.CommandError(
|
raise apiclient_exceptions.CommandError(
|
||||||
"Share name cannot be with the value 'None'")
|
"Share name cannot be with the value 'None'")
|
||||||
|
|
||||||
|
share_type = None
|
||||||
if parsed_args.share_type:
|
if parsed_args.share_type:
|
||||||
share_type = apiutils.find_resource(share_client.share_types,
|
share_type = apiutils.find_resource(share_client.share_types,
|
||||||
parsed_args.share_type).id
|
parsed_args.share_type).id
|
||||||
else:
|
elif not parsed_args.snapshot_id:
|
||||||
try:
|
try:
|
||||||
share_type = apiutils.find_resource(
|
share_type = apiutils.find_resource(
|
||||||
share_client.share_types, 'default').id
|
share_client.share_types, 'default').id
|
||||||
|
|
|
@ -230,20 +230,24 @@ class TestShareCreate(TestShare):
|
||||||
arglist = [
|
arglist = [
|
||||||
self.new_share.share_proto,
|
self.new_share.share_proto,
|
||||||
str(self.new_share.size),
|
str(self.new_share.size),
|
||||||
'--share-type', self.share_type.id,
|
|
||||||
'--snapshot-id', self.share_snapshot.id
|
'--snapshot-id', self.share_snapshot.id
|
||||||
|
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('share_proto', self.new_share.share_proto),
|
('share_proto', self.new_share.share_proto),
|
||||||
('size', self.new_share.size),
|
('size', self.new_share.size),
|
||||||
('share_type', self.share_type.id),
|
|
||||||
('snapshot_id', self.share_snapshot.id)
|
('snapshot_id', self.share_snapshot.id)
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
with mock.patch(
|
||||||
|
'manilaclient.common.apiclient.utils.find_resource',
|
||||||
|
mock.Mock(return_value=self.share_snapshot)):
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
osc_shares.apiutils.find_resource.assert_called_once_with(
|
||||||
|
mock.ANY, self.share_snapshot.id)
|
||||||
|
|
||||||
self.shares_mock.create.assert_called_with(
|
self.shares_mock.create.assert_called_with(
|
||||||
availability_zone=None,
|
availability_zone=None,
|
||||||
|
@ -254,12 +258,11 @@ class TestShareCreate(TestShare):
|
||||||
share_group_id=None,
|
share_group_id=None,
|
||||||
share_network=None,
|
share_network=None,
|
||||||
share_proto=self.new_share.share_proto,
|
share_proto=self.new_share.share_proto,
|
||||||
share_type=self.share_type.id,
|
share_type=None,
|
||||||
size=self.new_share.size,
|
size=self.new_share.size,
|
||||||
snapshot_id=self.share_snapshot.id,
|
snapshot_id=self.share_snapshot.id,
|
||||||
scheduler_hints={}
|
scheduler_hints={}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertCountEqual(self.columns, columns)
|
self.assertCountEqual(self.columns, columns)
|
||||||
self.assertCountEqual(self.datalist, data)
|
self.assertCountEqual(self.datalist, data)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
When creating a share from snapshot with 'openstack share create', the
|
||||||
|
client no longer forces the use of a share type. See `bug #1980985
|
||||||
|
<https://launchpad.net/bugs/1980985>`_ for more information.
|
Loading…
Reference in New Issue