<s> """<STR_LIT>""" <EOL> import base64 <EOL> from cloudcafe . common . tools . datagen import rand_name <EOL> from cloudroast . compute . fixtures import ComputeFixture <EOL> from cloudcafe . compute . common . types import NovaServerStatusTypes <EOL> from cloudcafe . compute . common . types import InstanceAuthStrategies <EOL> class ConfigDriveRescueTests ( ComputeFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ConfigDriveRescueTests , 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 . user_data_contents = "<STR_LIT>" <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 ( <EOL> cls . key . name , cls . keypairs_client . delete_keypair ) <EOL> server_response = cls . server_behaviors . create_active_server ( <EOL> config_drive = True , personality = files , user_data = user_data , <EOL> flavor_ref = cls . flavor_ref , metadata = cls . metadata , <EOL> key_name = cls . key . name ) <EOL> server_to_rescue = server_response . entity <EOL> cls . resources . add ( server_to_rescue . id , <EOL> cls . servers_client . delete_server ) <EOL> cls . server_behaviors . wait_for_server_status ( <EOL> server_to_rescue . id , NovaServerStatusTypes . ACTIVE ) <EOL> cls . server = server_response . entity <EOL> cls . user_data_filepath = '<STR_LIT>' . format ( <EOL> cls . config_drive_config . base_path_to_mount ) <EOL> remote_client = cls . server_behaviors . get_remote_instance_client ( <EOL> cls . server , cls . servers_config , key = cls . key . private_key ) <EOL> cls . config_drive_behaviors . mount_config_drive ( <EOL> server = cls . server , servers_config = cls . servers_config , <EOL> key = cls . key . private_key , <EOL> source_path = cls . config_drive_config . mount_source_path , <EOL> destination_path = cls . config_drive_config . base_path_to_mount ) <EOL> test_values = cls . config_drive_behaviors . get_config_drive_details ( <EOL> cls . user_data_filepath , cls . config_drive_config . base_path_to_mount , <EOL> cls . server , cls . servers_config , cls . key . private_key , <EOL> cls . config_drive_config . openstack_meta_filepath ) <EOL> cls . user_data_before_rescue = test_values [ <NUM_LIT:0> ] <EOL> cls . kb_size_before_rescue = test_values [ <NUM_LIT:1> ] <EOL> cls . openstack_meta_before_rescue = test_values [ <NUM_LIT:2> ] <EOL> rescue_response = cls . rescue_client . rescue ( cls . server . id ) <EOL> changed_password = rescue_response . entity . admin_pass <EOL> rescue_server_response = cls . server_behaviors . wait_for_server_status ( <EOL> cls . server . id , '<STR_LIT>' ) <EOL> rescue_server = rescue_server_response . entity <EOL> rescue_server . admin_pass = changed_password <EOL> cls . unrescue_response = cls . rescue_client . unrescue ( cls . server . id ) <EOL> cls . server_behaviors . wait_for_server_status ( cls . server . id , '<STR_LIT>' ) <EOL> remote_client = cls . server_behaviors . get_remote_instance_client ( <EOL> cls . server , cls . servers_config , <EOL> auth_strategy = InstanceAuthStrategies . PASSWORD ) <EOL> cls . user_data_filepath = '<STR_LIT>' . format ( <EOL> cls . config_drive_config . base_path_to_mount ) <EOL> cls . config_drive_behaviors . mount_config_drive ( <EOL> server = cls . server , servers_config = cls . servers_config , <EOL> key = cls . key . private_key , <EOL> source_path = cls . config_drive_config . mount_source_path , <EOL> destination_path = cls . config_drive_config . base_path_to_mount ) <EOL> cls . dir_openstack_content_present = remote_client . is_directory_present ( <EOL> directory_path = '<STR_LIT>' . format ( <EOL> cls . config_drive_config . base_path_to_mount ) ) <EOL> test_values = cls . config_drive_behaviors . get_config_drive_details ( <EOL> cls . user_data_filepath , cls . config_drive_config . base_path_to_mount , <EOL> cls . server , cls . servers_config , cls . key . private_key , <EOL> cls . config_drive_config . openstack_meta_filepath ) <EOL> cls . user_data_after_rescue = test_values [ <NUM_LIT:0> ] <EOL> cls . kb_size_after_rescue = test_values [ <NUM_LIT:1> ] <EOL> cls . openstack_meta_after_rescue = test_values [ <NUM_LIT:2> ] <EOL> def test_unresecue_response ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . unrescue_response . status_code , <NUM_LIT> ) <EOL> def test_directory_present_after_rescue ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( self . dir_openstack_content_present , <EOL> msg = "<STR_LIT>" ) <EOL> def test_openstack_metadata ( self ) : <EOL> message = "<STR_LIT>" <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . openstack_meta_after_rescue , <EOL> self . openstack_meta_before_rescue , <EOL> msg = "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> self . openstack_meta_before_rescue . admin_pass , <EOL> self . openstack_meta_after_rescue . admin_pass , <EOL> msg = message . format ( <EOL> '<STR_LIT>' , <EOL> self . openstack_meta_before_rescue . admin_pass , <EOL> self . openstack_meta_after_rescue . admin_pass ) ) <EOL> self . assertIsNotNone ( <EOL> self . openstack_meta_after_rescue . availability_zone , <EOL> msg = "<STR_LIT>" ) <EOL> self . assertIsNotNone ( <EOL> self . openstack_meta_after_rescue . hostname , <EOL> msg = "<STR_LIT>" ) <EOL> self . assertIsNotNone ( <EOL> self . openstack_meta_after_rescue . launch_index , <EOL> msg = "<STR_LIT>" ) <EOL> self . assertEqual ( <EOL> self . openstack_meta_before_rescue . name , <EOL> self . openstack_meta_after_rescue . name , <EOL> msg = message . format ( <EOL> '<STR_LIT>' , <EOL> self . openstack_meta_before_rescue . name , <EOL> self . openstack_meta_after_rescue . name ) ) <EOL> self . assertEqual ( self . openstack_meta_after_rescue . meta . get ( <EOL> '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( self . openstack_meta_after_rescue . meta . get ( <EOL> '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> getattr ( <EOL> self . openstack_meta_before_rescue . public_keys , <EOL> self . key . name ) , <EOL> getattr ( <EOL> self . openstack_meta_after_rescue . public_keys , <EOL> self . key . name ) , <EOL> msg = message . format ( '<STR_LIT>' , <EOL> self . openstack_meta_before_rescue . public_keys , <EOL> self . openstack_meta_after_rescue . public_keys ) ) <EOL> self . assertEqual ( <EOL> self . openstack_meta_before_rescue . uuid , <EOL> self . openstack_meta_after_rescue . uuid , <EOL> msg = message . format ( '<STR_LIT>' , <EOL> self . openstack_meta_before_rescue . uuid , <EOL> self . openstack_meta_after_rescue . uuid ) ) </s>
