@@ -2470,7 +2470,7 @@ def test_server_create_with_volume(self):
24702470 'admin_pass' : None ,
24712471 'block_device_mapping_v2' : [{
24722472 'uuid' : self .volume .id ,
2473- 'boot_index' : '0' ,
2473+ 'boot_index' : 0 ,
24742474 'source_type' : 'volume' ,
24752475 'destination_type' : 'volume' ,
24762476 }],
@@ -2521,7 +2521,7 @@ def test_server_create_with_snapshot(self):
25212521 'admin_pass' : None ,
25222522 'block_device_mapping_v2' : [{
25232523 'uuid' : self .snapshot .id ,
2524- 'boot_index' : '0' ,
2524+ 'boot_index' : 0 ,
25252525 'source_type' : 'snapshot' ,
25262526 'destination_type' : 'volume' ,
25272527 'delete_on_termination' : False ,
@@ -2544,20 +2544,20 @@ def test_server_create_with_snapshot(self):
25442544 self .assertEqual (self .datalist (), data )
25452545
25462546 def test_server_create_with_block_device (self ):
2547- block_device = f'uuid={ self .volume .id } ,source_type=volume'
2547+ block_device = f'uuid={ self .volume .id } ,source_type=volume,boot_index=0 '
25482548 arglist = [
2549- '--image' , 'image1' ,
25502549 '--flavor' , self .flavor .id ,
25512550 '--block-device' , block_device ,
25522551 self .new_server .name ,
25532552 ]
25542553 verifylist = [
2555- ('image' , 'image1' ),
2554+ ('image' , None ),
25562555 ('flavor' , self .flavor .id ),
25572556 ('block_devices' , [
25582557 {
25592558 'uuid' : self .volume .id ,
25602559 'source_type' : 'volume' ,
2560+ 'boot_index' : '0' ,
25612561 },
25622562 ]),
25632563 ('server_name' , self .new_server .name ),
@@ -2584,6 +2584,7 @@ def test_server_create_with_block_device(self):
25842584 'uuid' : self .volume .id ,
25852585 'source_type' : 'volume' ,
25862586 'destination_type' : 'volume' ,
2587+ 'boot_index' : 0 ,
25872588 },
25882589 ],
25892590 'nics' : [],
@@ -2593,7 +2594,7 @@ def test_server_create_with_block_device(self):
25932594 # ServerManager.create(name, image, flavor, **kwargs)
25942595 self .servers_mock .create .assert_called_with (
25952596 self .new_server .name ,
2596- self . image ,
2597+ None ,
25972598 self .flavor ,
25982599 ** kwargs
25992600 )
@@ -3521,6 +3522,37 @@ def test_server_create_image_property_with_image_list(self):
35213522 self .assertEqual (self .columns , columns )
35223523 self .assertEqual (self .datalist (), data )
35233524
3525+ def test_server_create_no_boot_device (self ):
3526+ block_device = f'uuid={ self .volume .id } ,source_type=volume,boot_index=1'
3527+ arglist = [
3528+ '--block-device' , block_device ,
3529+ '--flavor' , self .flavor .id ,
3530+ self .new_server .name ,
3531+ ]
3532+ verifylist = [
3533+ ('image' , None ),
3534+ ('flavor' , self .flavor .id ),
3535+ ('block_devices' , [
3536+ {
3537+ 'uuid' : self .volume .id ,
3538+ 'source_type' : 'volume' ,
3539+ 'boot_index' : '1' ,
3540+ },
3541+ ]),
3542+ ('server_name' , self .new_server .name ),
3543+ ]
3544+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
3545+ exc = self .assertRaises (
3546+ exceptions .CommandError ,
3547+ self .cmd .take_action ,
3548+ parsed_args ,
3549+ )
3550+ self .assertIn (
3551+ 'An image (--image, --image-property) or bootable volume '
3552+ '(--volume, --snapshot, --block-device) is required' ,
3553+ str (exc ),
3554+ )
3555+
35243556 def test_server_create_with_swap (self ):
35253557 arglist = [
35263558 '--image' , 'image1' ,
0 commit comments