File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1602,6 +1602,12 @@ def _match_image(image_api, wanted_properties):
16021602 ]
16031603 elif parsed_args .boot_from_volume :
16041604 # Tell nova to create a root volume from the image provided.
1605+ if not image :
1606+ msg = _ (
1607+ "An image (--image or --image-property) is required "
1608+ "to support --boot-from-volume option"
1609+ )
1610+ raise exceptions .CommandError (msg )
16051611 block_device_mapping_v2 = [
16061612 {
16071613 'uuid' : image .id ,
Original file line number Diff line number Diff line change @@ -3414,6 +3414,34 @@ def test_server_create_volume_boot_from_volume_conflict(self):
34143414 '--volume is not allowed with --boot-from-volume' , str (ex )
34153415 )
34163416
3417+ def test_server_create_boot_from_volume_no_image (self ):
3418+ # Test --boot-from-volume option without --image or
3419+ # --image-property.
3420+ arglist = [
3421+ '--flavor' ,
3422+ self .flavor .id ,
3423+ '--boot-from-volume' ,
3424+ '1' ,
3425+ self .new_server .name ,
3426+ ]
3427+ verifylist = [
3428+ ('flavor' , self .flavor .id ),
3429+ ('boot_from_volume' , 1 ),
3430+ ('config_drive' , False ),
3431+ ('server_name' , self .new_server .name ),
3432+ ]
3433+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
3434+
3435+ ex = self .assertRaises (
3436+ exceptions .CommandError , self .cmd .take_action , parsed_args
3437+ )
3438+ # Assert it is the error we expect.
3439+ self .assertIn (
3440+ 'An image (--image or --image-property) is required '
3441+ 'to support --boot-from-volume option' ,
3442+ str (ex ),
3443+ )
3444+
34173445 def test_server_create_image_property (self ):
34183446 arglist = [
34193447 '--image-property' ,
You can’t perform that action at this time.
0 commit comments