#NEWLINE# def test_deploy_partition_image_preserve_ephemeral( self ) : #NEWLINE# #INDENT# 'Check if 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 = 64 #NEWLINE# ephemeral_mb = 256 #NEWLINE# ephemeral_format = 'exttest' #NEWLINE# configdrive_mb = 0 #NEWLINE# node_uuid = '12345678-1234-1234-1234-1234567890abcxyz' #NEWLINE# dev = '/dev/fake' #NEWLINE# ephemeral_part = '/dev/fake-part1' #NEWLINE# swap_part = '/dev/fake-part2' #NEWLINE# root_part = '/dev/fake-part3' #NEWLINE# root_uuid = '12345678-1234-1234-12345678-12345678abcdef' #NEWLINE# utils_name_list = [ 'get_dev' , 'discovery' , 'login_iscsi' , 'delete_iscsi' , 'logout_iscsi' , 'notify' ] #NEWLINE# disk_utils_name_list = [ 'make_partitions' , 'get_image_mb' , 'is_block_device' , 'populate_image' , 'mkfs' , 'block_uuid' , 'get_dev_block_size' ] #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# 'swap' : swap_part , #NEWLINE# 'ephemeral' : ephemeral_part , #NEWLINE# 'root' : root_part , #NEWLINE# #UNINDENT# } #NEWLINE# disk_utils_mock . block_uuid . return_value = root_uuid #NEWLINE# utils_calls_expected = [ mock . call . get_dev ( address , port , 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 . make_partitions ( dev , root_mb , swap_mb , ephemeral_mb , configdrive_mb , node_uuid , commit = False , boot_option = 'netboot' , boot_mode = 'bios' , disk_label = None ) , mock . call . is_block_device ( lun ) , mock . call . is_block_device ( swap_part ) , mock . call . is_block_device ( ephemeral_part ) , mock . call . populate_image ( image_path , root_part ) , mock . call . mkfs ( dev = swap_part , fs = 'swap' , label = 'swap1' ) , 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 , preserve_ephemeral = True , boot_option = 'netboot' ) #NEWLINE# self . assertEqual ( utils_calls_expected , utils_mock . mock_calls ) #NEWLINE# self . assertEqual ( disk_utils_calls_expected , disk_utils_mock . mock_calls ) #NEWLINE# self . assertFalse ( disk_utils_mock . get_dev_block_size . called ) #NEWLINE# self . assertEqual ( root_uuid , uuid_dict_returned [ 'root uuid' ] )