3131from openstackclient .common import pagination
3232from openstackclient .i18n import _
3333from openstackclient .identity import common as identity_common
34- from openstackclient .volume .v2 import volume as volume_v2
3534
3635
3736LOG = logging .getLogger (__name__ )
@@ -91,7 +90,7 @@ def human_readable(self):
9190 return msg
9291
9392
94- class CreateVolume (volume_v2 . CreateVolume ):
93+ class CreateVolume (command . ShowOne ):
9594 _description = _ ("Create new volume" )
9695
9796 @staticmethod
@@ -117,8 +116,48 @@ def _check_size_arg(args):
117116 raise exceptions .CommandError (msg )
118117
119118 def get_parser (self , prog_name ):
120- parser , source_group = self ._get_parser (prog_name )
121-
119+ parser = super ().get_parser (prog_name )
120+ parser .add_argument (
121+ "name" ,
122+ metavar = "<name>" ,
123+ nargs = "?" ,
124+ help = _ ("Volume name" ),
125+ )
126+ parser .add_argument (
127+ "--size" ,
128+ metavar = "<size>" ,
129+ type = int ,
130+ help = _ (
131+ "Volume size in GB (required unless --snapshot or "
132+ "--source specified)"
133+ ),
134+ )
135+ parser .add_argument (
136+ "--type" ,
137+ metavar = "<volume-type>" ,
138+ help = _ ("Set the type of volume" ),
139+ )
140+ source_group = parser .add_mutually_exclusive_group ()
141+ source_group .add_argument (
142+ "--image" ,
143+ metavar = "<image>" ,
144+ help = _ ("Use <image> as source of volume (name or ID)" ),
145+ )
146+ source_group .add_argument (
147+ "--snapshot" ,
148+ metavar = "<snapshot>" ,
149+ help = _ ("Use <snapshot> as source of volume (name or ID)" ),
150+ )
151+ source_group .add_argument (
152+ "--source" ,
153+ metavar = "<volume>" ,
154+ help = _ ("Volume to clone (name or ID)" ),
155+ )
156+ source_group .add_argument (
157+ "--source-replicated" ,
158+ metavar = "<replicated-volume>" ,
159+ help = argparse .SUPPRESS ,
160+ )
122161 source_group .add_argument (
123162 "--backup" ,
124163 metavar = "<backup>" ,
@@ -138,6 +177,72 @@ def get_parser(self, prog_name):
138177 "--remote-source source-id=test_id')"
139178 ),
140179 )
180+ parser .add_argument (
181+ "--description" ,
182+ metavar = "<description>" ,
183+ help = _ ("Volume description" ),
184+ )
185+ parser .add_argument (
186+ "--availability-zone" ,
187+ metavar = "<availability-zone>" ,
188+ help = _ ("Create volume in <availability-zone>" ),
189+ )
190+ parser .add_argument (
191+ "--consistency-group" ,
192+ metavar = "consistency-group>" ,
193+ help = _ ("Consistency group where the new volume belongs to" ),
194+ )
195+ parser .add_argument (
196+ "--property" ,
197+ metavar = "<key=value>" ,
198+ action = parseractions .KeyValueAction ,
199+ dest = "properties" ,
200+ help = _ (
201+ "Set a property to this volume "
202+ "(repeat option to set multiple properties)"
203+ ),
204+ )
205+ parser .add_argument (
206+ "--hint" ,
207+ metavar = "<key=value>" ,
208+ action = KeyValueHintAction ,
209+ help = _ (
210+ "Arbitrary scheduler hint key-value pairs to help creating "
211+ "a volume. Repeat the option to set multiple hints. "
212+ "'same_host' and 'different_host' get values appended when "
213+ "repeated, all other keys take the last given value"
214+ ),
215+ )
216+ bootable_group = parser .add_mutually_exclusive_group ()
217+ bootable_group .add_argument (
218+ "--bootable" ,
219+ action = "store_true" ,
220+ dest = "bootable" ,
221+ default = None ,
222+ help = _ ("Mark volume as bootable" ),
223+ )
224+ bootable_group .add_argument (
225+ "--non-bootable" ,
226+ action = "store_false" ,
227+ dest = "bootable" ,
228+ default = None ,
229+ help = _ ("Mark volume as non-bootable (default)" ),
230+ )
231+ readonly_group = parser .add_mutually_exclusive_group ()
232+ readonly_group .add_argument (
233+ "--read-only" ,
234+ action = "store_true" ,
235+ dest = "read_only" ,
236+ default = None ,
237+ help = _ ("Set volume to read-only access mode" ),
238+ )
239+ readonly_group .add_argument (
240+ "--read-write" ,
241+ action = "store_false" ,
242+ dest = "read_only" ,
243+ default = None ,
244+ help = _ ("Set volume to read-write access mode (default)" ),
245+ )
141246 parser .add_argument (
142247 "--host" ,
143248 metavar = "<host>" ,
@@ -160,7 +265,7 @@ def get_parser(self, prog_name):
160265 return parser
161266
162267 def take_action (self , parsed_args ):
163- CreateVolume ._check_size_arg (parsed_args )
268+ self ._check_size_arg (parsed_args )
164269 # size is validated in the above call to
165270 # _check_size_arg where we check that size
166271 # should be passed if we are not creating a
@@ -351,11 +456,33 @@ def take_action(self, parsed_args):
351456 return zip (* sorted (volume ._info .items ()))
352457
353458
354- class DeleteVolume (volume_v2 . DeleteVolume ):
459+ class DeleteVolume (command . Command ):
355460 _description = _ ("Delete volume(s)" )
356461
357462 def get_parser (self , prog_name ):
358463 parser = super ().get_parser (prog_name )
464+ parser .add_argument (
465+ "volumes" ,
466+ metavar = "<volume>" ,
467+ nargs = "+" ,
468+ help = _ ("Volume(s) to delete (name or ID)" ),
469+ )
470+ group = parser .add_mutually_exclusive_group ()
471+ group .add_argument (
472+ "--force" ,
473+ action = "store_true" ,
474+ help = _ (
475+ "Attempt forced removal of volume(s), regardless of state "
476+ "(defaults to False)"
477+ ),
478+ )
479+ group .add_argument (
480+ "--purge" ,
481+ action = "store_true" ,
482+ help = _ (
483+ "Remove any snapshots along with volume(s) (defaults to False)"
484+ ),
485+ )
359486 parser .add_argument (
360487 '--remote' ,
361488 action = 'store_true' ,
0 commit comments