Skip to content

Commit ee98cb9

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Change volume create --snapshot-id to --snapshot"
2 parents 00988d4 + 60ef8b0 commit ee98cb9

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎doc/source/command-objects/volume.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Create new volume
1414
1515
os volume create
1616
--size <size>
17-
[--snapshot-id <snapshot-id>]
17+
[--snapshot <snapshot>]
1818
[--description <description>]
1919
[--type <volume-type>]
2020
[--user <user>]
@@ -29,9 +29,9 @@ Create new volume
2929

3030
New volume size in GB
3131

32-
.. option:: --snapshot-id <snapshot-id>
32+
.. option:: --snapshot <snapshot>
3333

34-
Use <snapshot-id> as source of new volume
34+
Use <snapshot> as source of new volume
3535

3636
.. option:: --description <description>
3737

‎openstackclient/volume/v1/volume.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
"""Volume v1 Volume action implementations"""
1717

18+
import argparse
1819
import logging
1920
import six
2021

@@ -45,10 +46,16 @@ def get_parser(self, prog_name):
4546
type=int,
4647
help='New volume size in GB',
4748
)
48-
parser.add_argument(
49+
snapshot_group = parser.add_mutually_exclusive_group()
50+
snapshot_group.add_argument(
51+
'--snapshot',
52+
metavar='<snapshot>',
53+
help='Use <snapshot> as source of new volume',
54+
)
55+
snapshot_group.add_argument(
4956
'--snapshot-id',
5057
metavar='<snapshot-id>',
51-
help='Use <snapshot-id> as source of new volume',
58+
help=argparse.SUPPRESS,
5259
)
5360
parser.add_argument(
5461
'--description',
@@ -130,9 +137,11 @@ def take_action(self, parsed_args):
130137
parsed_args.image,
131138
).id
132139

140+
snapshot = parsed_args.snapshot or parsed_args.snapshot_id
141+
133142
volume = volume_client.volumes.create(
134143
parsed_args.size,
135-
parsed_args.snapshot_id,
144+
snapshot,
136145
source_volume,
137146
parsed_args.name,
138147
parsed_args.description,

0 commit comments

Comments
 (0)