<s> """<STR_LIT>""" <EOL> import base64 <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . common . tools . datagen import rand_name <EOL> from cloudcafe . compute . common . types import NovaServerStatusTypes <EOL> from cloudroast . compute . fixtures import ComputeFixture <EOL> class CloudInitActionsTest ( ComputeFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( CloudInitActionsTest , cls ) . setUpClass ( ) <EOL> script = cls . config_drive_behaviors . read_cloud_init_for_config_drive ( <EOL> cls . cloud_init_config . user_data_script ) <EOL> cls . user_data_contents = script <EOL> user_data = base64 . b64encode ( cls . user_data_contents ) <EOL> cls . key = cls . keypairs_client . create_keypair ( rand_name ( "<STR_LIT:key>" ) ) . entity <EOL> cls . resources . add ( cls . key . name , <EOL> cls . keypairs_client . delete_keypair ) <EOL> active_server_response = cls . server_behaviors . create_active_server ( <EOL> config_drive = True , <EOL> user_data = user_data , <EOL> key_name = cls . key . name ) <EOL> cls . server = active_server_response . entity <EOL> cls . resources . add ( cls . server . id , <EOL> cls . servers_client . delete_server ) <EOL> cls . server_response = cls . servers_client . rebuild ( <EOL> cls . server . id , cls . image_ref_alt , config_drive = True , <EOL> key_name = cls . key . name , user_data = user_data ) <EOL> cls . server_after_rebuild = cls . server_response . entity <EOL> cls . server_behaviors . wait_for_server_status ( <EOL> cls . server . id , NovaServerStatusTypes . ACTIVE ) <EOL> cls . user_data_filepath = '<STR_LIT>' . format ( <EOL> cls . config_drive_config . base_path_to_mount ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT:yes>' ) <EOL> def test_user_data_input_format_on_rebuild ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <NUM_LIT> , self . server_response . status_code ) <EOL> self . config_drive_behaviors . mount_config_drive ( <EOL> server = self . server_after_rebuild , <EOL> servers_config = self . servers_config , <EOL> key = self . key . private_key , <EOL> source_path = self . config_drive_config . mount_source_path , <EOL> destination_path = self . config_drive_config . base_path_to_mount ) <EOL> remote_client = self . server_behaviors . get_remote_instance_client ( <EOL> self . server_after_rebuild , self . servers_config , <EOL> key = self . key . private_key ) <EOL> instance_user_data = remote_client . get_file_details ( <EOL> self . user_data_filepath ) <EOL> self . assertEqual ( instance_user_data . content , <EOL> self . user_data_contents , <EOL> msg = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' . format ( <EOL> self . user_data_contents , <EOL> instance_user_data . content ) ) <EOL> dir_script_present = remote_client . is_directory_present ( <EOL> directory_path = self . cloud_init_config . user_data_created_directory ) <EOL> self . assertTrue ( dir_script_present , <EOL> msg = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> file_script_present = remote_client . is_file_present ( <EOL> '<STR_LIT>' . format ( <EOL> self . cloud_init_config . user_data_created_directory ) ) <EOL> self . assertTrue ( file_script_present , <EOL> msg = "<STR_LIT>" <EOL> "<STR_LIT>" ) </s>
