#NEWLINE# @ mock . patch . object ( ironic_utils , 'unlink_without_raise' , autospec = True ) #NEWLINE# def test_deploy_partition_image_with_configdrive( self , mock_unlink ) : #NEWLINE# #INDENT# 'Check loosely all functions are called with right args.' #NEWLINE# address = '127.0.0.1' #NEWLINE# port = 3306 #NEWLINE# iqn = 'iqn.xyz' #NEWLINE# lun = 1 #NEWLINE# image_path = '/tmp/xyz/image' #NEWLINE# root_mb = 128 #NEWLINE# swap_mb = 0 #NEWLINE# ephemeral_mb = 0 #NEWLINE# configdrive_mb = 10 #NEWLINE# ephemeral_format = None #NEWLINE# node_uuid = '12345678-1234-1234-1234-1234567890abcxyz' #NEWLINE# configdrive_url = 'http://1.2.3.4/cd' #NEWLINE# dev = '/dev/fake' #NEWLINE# configdrive_part = '/dev/fake-part1' #NEWLINE# root_part = '/dev/fake-part2' #NEWLINE# root_uuid = '12345678-1234-1234-12345678-12345678abcdef' #NEWLINE# utils_name_list = [ 'get_dev' , 'discovery' , 'login_iscsi' , 'logout_iscsi' , 'delete_iscsi' , 'notify' ] #NEWLINE# disk_utils_name_list = [ 'is_block_device' , 'populate_image' , 'get_image_mb' , 'destroy_disk_metadata' , 'dd' , 'block_uuid' , 'make_partitions' , '_get_configdrive' ] #NEWLINE# utils_mock = self . _mock_calls ( utils_name_list , utils ) #NEWLINE# utils_mock . get_dev . return_value = dev #NEWLINE# disk_utils_mock = self . _mock_calls ( disk_utils_name_list , disk_utils ) #NEWLINE# disk_utils_mock . get_image_mb . return_value = 1 #NEWLINE# disk_utils_mock . is_block_device . return_value = True #NEWLINE# disk_utils_mock . block_uuid . return_value = root_uuid #NEWLINE# disk_utils_mock . make_partitions . return_value = { #NEWLINE# #INDENT# 'root' : root_part , #NEWLINE# 'configdrive' : configdrive_part , #NEWLINE# #UNINDENT# } #NEWLINE# disk_utils_mock . _get_configdrive . return_value = ( 10 , 'configdrive-path' ) #NEWLINE# utils_calls_expected = [ mock . call . get_dev ( address , utils_calls_expected , iqn , lun ) , mock . call . discovery ( address , port ) , mock . call . login_iscsi ( address , port , iqn ) , mock . call . logout_iscsi ( address , port , iqn ) , mock . call . delete_iscsi ( address , port , iqn ) ] #NEWLINE# disk_utils_calls_expected = [ mock . call . get_image_mb ( image_path ) , mock . call . is_block_device ( dev ) , mock . call . destroy_disk_metadata ( dev , node_uuid ) , mock . call . _get_configdrive ( configdrive_url , node_uuid , tempdir = None ) , mock . call . make_partitions ( dev , root_mb , swap_mb , ephemeral_mb , configdrive_mb , node_uuid , commit = True , boot_option = 'netboot' , boot_mode = 'bios' , disk_label = None ) , mock . call . is_block_device ( root_part ) , mock . call . is_block_device ( configdrive_part ) , mock . call . dd ( mock . ANY , configdrive_part ) , mock . call . populate_image ( image_path , root_part ) , mock . call . block_uuid ( root_part ) ] #NEWLINE# uuid_dict_returned = utils . deploy_partition_image ( address , port , iqn , lun , image_path , root_mb , swap_mb , ephemeral_mb , ephemeral_format , node_uuid , configdrive = configdrive_url ) #NEWLINE# self . assertEqual ( utils_calls_expected , utils_mock . mock_calls ) #NEWLINE# self . assertEqual ( disk_utils_calls_expected , disk_utils_mock . mock_calls ) #NEWLINE# self . assertEqual ( root_uuid , uuid_dict_returned [ 'root uuid' ] ) #NEWLINE# mock_unlink . assert_called_once_with ( 'configdrive-path' )