Fix issue while creating share from snapshot

Fixed the issue that didn't allow users to create share from
snapshot when the snapshot name was specified instead of the id.

Now, the manila client will search for snapshots regardless if the
name or id of the snapshot was specified.

Closes-Bug: #1798229
Change-Id: I2b29b6d2ba232aa390e7c3708ee589c82e3e7e72
This commit is contained in:
Luisa Ferraz do Amaral 2021-07-22 11:53:30 -03:00
parent 402d073376
commit 616f3acf60
2 changed files with 15 additions and 3 deletions

View File

@ -843,9 +843,11 @@ def do_rate_limits(cs, args):
@cliutils.arg(
'--snapshot-id',
'--snapshot_id',
metavar='<snapshot-id>',
'--snapshot',
metavar='<snapshot>',
action='single_alias',
help='Optional snapshot ID to create the share from. (Default=None)',
help='Optional snapshot ID or name to create the share from.'
' (Default=None)',
default=None)
@cliutils.arg(
'--name',
@ -918,11 +920,15 @@ def do_create(cs, args):
if args.share_network:
share_network = _find_share_network(cs, args.share_network)
snapshot = None
if args.snapshot_id:
snapshot = _find_share_snapshot(cs, args.snapshot_id).id
if args.name == 'None':
raise exceptions.CommandError(
"Share name cannot be with the value 'None'")
share = cs.shares.create(args.share_protocol, args.size, args.snapshot_id,
share = cs.shares.create(args.share_protocol, args.size, snapshot,
args.name, args.description,
metadata=share_metadata,
share_network=share_network,

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the issue in which users were unable to create a share from a
snapshot, specifing the snapshot's name. For more details, please refer to
`launchpad bug 1798229 <https://bugs.launchpad.net/python-manilaclient/+bug/1798229>`_