<s> """<STR_LIT>""" <EOL> import base64 <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . compute . common . exceptions import FileNotFoundException <EOL> from cloudcafe . common . tools . datagen import rand_name <EOL> from cloudroast . compute . fixtures import ComputeFixture <EOL> class ConfigDriveDirectoryTest ( ComputeFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ConfigDriveDirectoryTest , cls ) . setUpClass ( ) <EOL> cls . metadata = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> cls . file_contents = '<STR_LIT>' <EOL> files = [ { '<STR_LIT:path>' : '<STR_LIT>' , '<STR_LIT>' : base64 . b64encode ( <EOL> cls . file_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> cls . server = cls . server_behaviors . create_active_server ( <EOL> config_drive = True , <EOL> key_name = cls . key . name , <EOL> personality = files , <EOL> metadata = cls . metadata ) . entity <EOL> cls . user_data_filepath = '<STR_LIT>' . format ( <EOL> cls . config_drive_config . base_path_to_mount ) <EOL> cls . resources . add ( cls . server . id , <EOL> cls . servers_client . delete_server ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT:yes>' ) <EOL> def test_create_server_config_drive_openstack_directory ( self ) : <EOL> """<STR_LIT>""" <EOL> remote_client = self . server_behaviors . get_remote_instance_client ( <EOL> self . server , self . servers_config , key = self . key . private_key ) <EOL> self . config_drive_behaviors . mount_config_drive ( <EOL> server = self . server , 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> dir_openstack_present = remote_client . is_directory_present ( <EOL> directory_path = '<STR_LIT>' . format ( <EOL> self . config_drive_config . base_path_to_mount ) ) <EOL> self . assertTrue ( dir_openstack_present , <EOL> msg = "<STR_LIT>" ) <EOL> dir_openstack_content_present = remote_client . is_directory_present ( <EOL> directory_path = '<STR_LIT>' . format ( <EOL> self . config_drive_config . base_path_to_mount ) ) <EOL> self . assertTrue ( dir_openstack_content_present , <EOL> msg = "<STR_LIT>" ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT:yes>' ) <EOL> def test_create_server_config_drive_ec2_directory ( self ) : <EOL> """<STR_LIT>""" <EOL> remote_client = self . server_behaviors . get_remote_instance_client ( <EOL> self . server , self . servers_config , key = self . key . private_key ) <EOL> self . config_drive_behaviors . mount_config_drive ( <EOL> server = self . server , 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> dir_openstack_present = remote_client . is_directory_present ( <EOL> directory_path = '<STR_LIT>' . format ( <EOL> self . config_drive_config . base_path_to_mount ) ) <EOL> self . assertTrue ( dir_openstack_present , <EOL> msg = "<STR_LIT>" ) <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT:yes>' ) <EOL> def test_create_server_config_drive_user_data_not_present ( self ) : <EOL> """<STR_LIT>""" <EOL> remote_client = self . server_behaviors . get_remote_instance_client ( <EOL> self . server , self . servers_config , key = self . key . private_key ) <EOL> self . config_drive_behaviors . mount_config_drive ( <EOL> server = self . server , 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> with self . assertRaises ( FileNotFoundException ) : <EOL> remote_client . get_file_details ( <EOL> file_path = self . user_data_filepath ) . content </s>
