File tree Expand file tree Collapse file tree
doc/source/command-objects
openstackclient/volume/v1 Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1515
1616"""Volume v1 Volume action implementations"""
1717
18+ import argparse
1819import logging
1920import 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 ,
You can’t perform that action at this time.
0 commit comments