def exa_db_system_cleanup(runner, config_file, config_profile, db_system_id_1): if SKIP_CLEAN_UP_RESOURCES: print("Skipping clean up of DB systems and dependent resources.") return success_terminating_db_systems = True try: # terminate db system 1 params = [ 'system', 'terminate', '--db-system-id', db_system_id_1, '--force' ] result = invoke(runner, config_file, config_profile, params) util.validate_response(result) # validate that it goes into terminating state params = ['system', 'get', '--db-system-id', db_system_id_1] result = invoke(runner, config_file, config_profile, params) util.validate_response(result) state = json.loads(result.output)['data']['lifecycle-state'] assert "TERMINAT" in state util.wait_until( ['db', 'system', 'get', '--db-system-id', db_system_id_1], 'TERMINATED', max_wait_seconds=DB_SYSTEM_PROVISIONING_TIME_SEC, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) success_terminating_db_systems = False assert success_terminating_db_systems
def temp_bucket(runner, config_file, config_profile): bucket_name = 'cli_temp_multipart_bucket_' + str(random.randint( 0, 1000000)) print("Bucket Name: ", bucket_name) # ns get result = invoke(runner, config_file, config_profile, ['ns', 'get']) validate_response(result) assert util.NAMESPACE in result.output # bucket create result = invoke(runner, config_file, config_profile, [ 'bucket', 'create', '-ns', util.NAMESPACE, '--compartment-id', util.COMPARTMENT_ID, '--name', bucket_name ]) validate_response(result) # create the SSE-C encryption key enc_key_str = generate_aes256_key_str() with open(GENERATED_ENC_KEY_FILE, 'w') as f: f.write(enc_key_str) yield bucket_name # clean up, delete bucket error_count = 0 try: result = invoke( runner, config_file, config_profile, ['object', 'list', '-ns', util.NAMESPACE, '-bn', bucket_name]) validate_response(result) response = json.loads(result.output) if 'data' in response: objects = response['data'] for obj in objects: invoke(runner, config_file, config_profile, [ 'object', 'delete', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', obj['name'], '--force' ]) validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 try: print("Deleting bucket") result = invoke(runner, config_file, config_profile, [ 'bucket', 'delete', '-ns', util.NAMESPACE, '--name', bucket_name, '--force' ]) validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 assert 0 == error_count # remove the SSE-C key file if os.path.exists(GENERATED_ENC_KEY_FILE): os.remove(GENERATED_ENC_KEY_FILE)
def temp_bucket(runner, config_file, config_profile, test_id): bucket_name = 'cli_temp_multipart_bucket_' + test_id # ns get result = invoke(runner, config_file, config_profile, ['ns', 'get']) validate_response(result) assert util.NAMESPACE in result.output # bucket create result = invoke(runner, config_file, config_profile, [ 'bucket', 'create', '-ns', util.NAMESPACE, '--compartment-id', util.COMPARTMENT_ID, '--name', bucket_name ]) validate_response(result) yield bucket_name # clean up, delete bucket error_count = 0 try: result = invoke( runner, config_file, config_profile, ['object', 'list', '-ns', util.NAMESPACE, '-bn', bucket_name]) validate_response(result) response = json.loads(result.output) if 'data' in response: objects = response['data'] for obj in objects: invoke(runner, config_file, config_profile, [ 'object', 'delete', '-ns', util.NAMESPACE, '-bn', bucket_name, '--name', obj['name'], '--force' ]) validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 try: print("Deleting bucket") result = invoke(runner, config_file, config_profile, [ 'bucket', 'delete', '-ns', util.NAMESPACE, '--name', bucket_name, '--force' ]) validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 assert 0 == error_count
def subtest_delete(self): error_count = 0 if len(self.instance_ocids) > 0: for ocid in self.instance_ocids: try: print("checking TERMINATED for " + ocid) util.wait_until(['compute', 'instance', 'get', '--instance-id', ocid], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: print("Deleting subnet") result = util.invoke_command(['network', 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'subnet', 'get', '--subnet-id', self.subnet_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: print("Deleting vcn") result = util.invoke_command(['network', 'vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'vcn', 'get', '--vcn-id', self.vcn_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)
def networking_cleanup(runner, config_file, config_profile, network_client, subnet_ocid_1, subnet_ocid_2, default_route_table_ocid, ig_ocid, vcn_ocid): if SKIP_CLEAN_UP_RESOURCES: print("Skipping clean up of DB systems and dependent resources.") return success_terminating_db_systems = True try: # delete VCN and subnets now that dependent DB systems are deleted subnet_params = ["subnet", "delete", "--force", "--subnet-id", subnet_ocid_1, "--wait-for-state", "TERMINATED"] invoke(runner, config_file, config_profile, subnet_params) try: runner.invoke(oci_cli.cli, ['--config-file', config_file, '--profile', config_profile, 'network'] + subnet_params) except oci.exceptions.ServiceError as error: if not hasattr(error, 'status') or error.status != 404: util.print_latest_exception(error) subnet_params = ["subnet", "delete", "--force", "--subnet-id", subnet_ocid_2, "--wait-for-state", "TERMINATED"] invoke(runner, config_file, config_profile, subnet_params) try: runner.invoke(oci_cli.cli, ['--config-file', config_file, '--profile', config_profile, 'network'] + subnet_params) except oci.exceptions.ServiceError as error: if not hasattr(error, 'status') or error.status != 404: util.print_latest_exception(error) route_table_params = ["route-table", "--force", "--rt-id", default_route_table_ocid, "--route-rules", "'[]'", ] runner.invoke(oci_cli.cli, ['--config-file', config_file, '--profile', config_profile, 'network'] + route_table_params) try: ig_params = ['internet-gateway', 'delete', '--force', '--ig-id', ig_ocid, '--wait-for-state', 'TERMINATED'] runner.invoke(oci_cli.cli, ['--config-file', config_file, '--profile', config_profile, 'network'] + ig_params) except oci.exceptions.ServiceError as error: if not hasattr(error, 'status') or error.status != 404: util.print_latest_exception(error) vcn_params = ['delete', '--vcn-id', vcn_ocid] runner.invoke(oci_cli.cli, ['--config-file', config_file, '--profile', config_profile, 'network'] + vcn_params) except Exception as error: util.print_latest_exception(error) success_terminating_db_systems = False assert success_terminating_db_systems
def clean_up_resources(self): print("clean_up_resources") error_count = 0 if hasattr(self, 'instance_ocid'): try: print("Deleting instance") result = self.invoke(['compute', 'instance', 'terminate', '--instance-id', self.instance_ocid, '--force']) util.validate_response(result) # This check was deferred from earlier b/c it takes a while to terminate an instance print("waiting for first instance to terminate " + self.previous_instance_ocid) util.wait_until(['compute', 'instance', 'get', '--instance-id', self.previous_instance_ocid], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) util.wait_until(['compute', 'instance', 'get', '--instance-id', self.instance_ocid], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: print("Deleting subnet") result = self.invoke(['network', 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'subnet', 'get', '--subnet-id', self.subnet_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: print("Deleting vcn") result = self.invoke(['network', 'vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'vcn', 'get', '--vcn-id', self.vcn_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)
def test_launch_exa_db_system(runner, config_file, config_profile, networking_test_launch_exa_db_system): DB_SYSTEM_SHAPE = 'Exadata.Quarter2.92' # provision DB systems params = [ 'system', 'launch', '--admin-password', ADMIN_PASSWORD, '--availability-domain', networking_test_launch_exa_db_system['availability_domain'], '--compartment-id', util.COMPARTMENT_ID, '--cpu-core-count', DB_SYSTEM_CPU_CORE_COUNT, '--database-edition', DB_SYSTEM_DB_EXTREME_EDITION, '--time-zone', 'US/Pacific', '--db-name', 'clidbexa', '--db-version', DB_VERSION, '--display-name', 'CliDbSysExa', '--hostname', 'cliexa', '--shape', DB_SYSTEM_SHAPE, '--ssh-authorized-keys-file', util.SSH_AUTHORIZED_KEYS_FILE, '--subnet-id', networking_test_launch_exa_db_system['subnet_ocid_1'], '--backup-subnet-id', networking_test_launch_exa_db_system['subnet_ocid_2'], '--sparse-diskgroup', 'true' ] result = invoke(runner, config_file, config_profile, params) util.validate_response(result) print(str(result.output)) json_result = json.loads(result.output) db_system_id_1 = json_result['data']['id'] print("Wating for DB System to launch...") # launch db system util.wait_until(['db', 'system', 'get', '--db-system-id', db_system_id_1], 'PROVISIONING', max_wait_seconds=DB_SYSTEM_PROVISIONING_TIME_SEC) print("DB System launched successfully!") if SKIP_CLEAN_UP_RESOURCES: print("Skipping clean up of DB systems and dependent resources.") return success_terminating_db_systems = True try: # terminate db system params = [ 'system', 'terminate', '--db-system-id', db_system_id_1, '--force' ] result = invoke(runner, config_file, config_profile, params) util.validate_response(result) # validate that it goes into terminating state params = ['system', 'get', '--db-system-id', db_system_id_1] result = invoke(runner, config_file, config_profile, params) util.validate_response(result) state = json.loads(result.output)['data']['lifecycle-state'] assert "TERMINAT" in state # TODO: Re-enable this after this is re-recorded using CLI tenancy. util.wait_until( ['db', 'system', 'get', '--db-system-id', db_system_id_1], 'TERMINATED', max_wait_seconds=DB_SYSTEM_PROVISIONING_TIME_SEC, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) success_terminating_db_systems = False assert success_terminating_db_systems
def subtest_delete(self): error_count = 0 if hasattr(self, 'image_ocid'): try: print("Deleting image") result = self.invoke([ 'compute', 'image', 'delete', '--image-id', self.image_ocid, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'ch_ocid'): try: print("Deleting console history") result = self.invoke([ 'compute', 'console-history', 'delete', '--instance-console-history-id', self.ch_ocid, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'instance_ocid'): try: print("Checking instance terminated " + self.instance_ocid) util.wait_until([ 'compute', 'instance', 'get', '--instance-id', self.instance_ocid ], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'instance_ocid_2'): try: print("Checking instance 2 terminated " + self.instance_ocid_2) util.wait_until([ 'compute', 'instance', 'get', '--instance-id', self.instance_ocid_2 ], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'windows_instance_ocid'): try: print("Checking windows instance terminated " + self.windows_instance_ocid) util.wait_until([ 'compute', 'instance', 'get', '--instance-id', self.windows_instance_ocid ], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_ocid'): try: print("Deleting volume") result = self.invoke([ 'bv', 'volume', 'delete', '--volume-id', self.volume_ocid, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: print("Deleting subnet") result = self.invoke([ 'network', 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'subnet', 'get', '--subnet-id', self.subnet_ocid ], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: print("Deleting vcn") result = self.invoke([ 'network', 'vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force' ]) util.validate_response(result) util.wait_until( ['network', 'vcn', 'get', '--vcn-id', self.vcn_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)
def vcn_and_subnets(network_client): from tests import util with test_config_container.create_vcr().use_cassette( '_conftest_fixture_vcn_and_subnets.yml'): # create VCN vcn_name = util.random_name('cli_lb_test_vcn') cidr_block = "10.0.0.0/16" vcn_dns_label = util.random_name('vcn', insert_underscore=False) create_vcn_details = oci.core.models.CreateVcnDetails() create_vcn_details.cidr_block = cidr_block create_vcn_details.display_name = vcn_name create_vcn_details.compartment_id = os.environ[ 'OCI_CLI_COMPARTMENT_ID'] create_vcn_details.dns_label = vcn_dns_label result = network_client.create_vcn(create_vcn_details) vcn_ocid = result.data.id assert result.status == 200 oci.wait_until(network_client, network_client.get_vcn(vcn_ocid), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300, max_interval_seconds=WAIT_INTERVAL_SECONDS) # create subnet in first AD subnet_name = util.random_name('cli_lb_test_subnet') cidr_block = "10.0.1.0/24" subnet_dns_label = util.random_name('subnet', insert_underscore=False) create_subnet_details = oci.core.models.CreateSubnetDetails() create_subnet_details.compartment_id = os.environ[ 'OCI_CLI_COMPARTMENT_ID'] create_subnet_details.availability_domain = util.availability_domain() create_subnet_details.display_name = subnet_name create_subnet_details.vcn_id = vcn_ocid create_subnet_details.cidr_block = cidr_block create_subnet_details.dns_label = subnet_dns_label result = network_client.create_subnet(create_subnet_details) subnet_ocid_1 = result.data.id assert result.status == 200 oci.wait_until(network_client, network_client.get_subnet(subnet_ocid_1), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300, max_interval_seconds=WAIT_INTERVAL_SECONDS) # create subnet in second AD subnet_name = util.random_name('cli_lb_test_subnet') cidr_block = "10.0.0.0/24" subnet_dns_label = util.random_name('subnet2', insert_underscore=False) create_subnet_details = oci.core.models.CreateSubnetDetails() create_subnet_details.compartment_id = os.environ[ 'OCI_CLI_COMPARTMENT_ID'] create_subnet_details.availability_domain = util.second_availability_domain( ) create_subnet_details.display_name = subnet_name create_subnet_details.vcn_id = vcn_ocid create_subnet_details.cidr_block = cidr_block create_subnet_details.dns_label = subnet_dns_label result = network_client.create_subnet(create_subnet_details) subnet_ocid_2 = result.data.id assert result.status == 200 oci.wait_until(network_client, network_client.get_subnet(subnet_ocid_2), 'lifecycle_state', 'AVAILABLE', max_wait_seconds=300, max_interval_seconds=WAIT_INTERVAL_SECONDS) yield [vcn_ocid, subnet_ocid_1, subnet_ocid_2] # For some reason VCR doesn't like that the post-yield stuff here is all in one cassette. Splitting into different cassettes seems to work with test_config_container.create_vcr().use_cassette( '_conftest_fixture_vcn_and_subnets_delete.yml'): # delete VCN and subnets network_client.delete_subnet(subnet_ocid_1) try: oci.wait_until(network_client, network_client.get_subnet(subnet_ocid_1), 'lifecycle_state', 'TERMINATED', max_wait_seconds=600, max_interval_seconds=WAIT_INTERVAL_SECONDS) except oci.exceptions.ServiceError as error: if not hasattr(error, 'status') or error.status != 404: util.print_latest_exception(error) network_client.delete_subnet(subnet_ocid_2) try: oci.wait_until(network_client, network_client.get_subnet(subnet_ocid_2), 'lifecycle_state', 'TERMINATED', max_wait_seconds=600, max_interval_seconds=WAIT_INTERVAL_SECONDS) except oci.exceptions.ServiceError as error: if not hasattr(error, 'status') or error.status != 404: util.print_latest_exception(error) network_client.delete_vcn(vcn_ocid)
def clean_up_resources(self): error_count = 0 if hasattr(self, 'first_instance_id'): try: print("Deleting instance " + self.first_instance_id) result = self.invoke([ 'compute', 'instance', 'terminate', '--instance-id', self.first_instance_id, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'second_instance_id'): try: print("Deleting instance " + self.second_instance_id) result = self.invoke([ 'compute', 'instance', 'terminate', '--instance-id', self.second_instance_id, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'first_instance_id'): try: print("Checking instance terminated " + self.first_instance_id) util.wait_until([ 'compute', 'instance', 'get', '--instance-id', self.first_instance_id ], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'second_instance_id'): try: print("Checking instance terminated " + self.second_instance_id) util.wait_until([ 'compute', 'instance', 'get', '--instance-id', self.second_instance_id ], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: print("Deleting subnet") result = self.invoke([ 'network', 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'subnet', 'get', '--subnet-id', self.subnet_ocid ], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vlan_ocid'): try: print("Deleting vlan") result = self.invoke([ 'network', 'vlan', 'delete', '--vlan-id', self.vlan_ocid, '--force' ]) util.validate_response(result) util.wait_until( ['network', 'vlan', 'get', '--vlan-id', self.vlan_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: print("Deleting vcn") result = self.invoke([ 'network', 'vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force' ]) util.validate_response(result) util.wait_until( ['network', 'vcn', 'get', '--vcn-id', self.vcn_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)
def subtest_delete(self): error_count = 0 if hasattr(self, 'backup_id'): try: result = self.invoke([ 'backup', 'delete', '--volume-backup-id', self.backup_id, '--force' ]) util.validate_response(result) util.wait_until([ 'bv', 'backup', 'get', '--volume-backup-id', self.backup_id ], 'TERMINATED', max_interval_seconds=180) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_group_backup_id'): try: result = self.invoke([ 'volume-group-backup', 'delete', '--volume-group-backup-id', self.volume_group_backup_id, '--force' ]) util.validate_response(result) util.wait_until([ 'bv', 'volume-group-backup', 'get', '--volume-group-backup-id', self.volume_group_backup_id ], 'TERMINATED', max_interval_seconds=180) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_id'): try: result = self.invoke([ 'volume', 'delete', '--volume-id', self.volume_id, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_id_two'): try: result = self.invoke([ 'volume', 'delete', '--volume-id', self.volume_id_two, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_group'): try: result = self.invoke([ 'volume-group', 'delete', '--volume-group-id', self.volume_group, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_group_clone'): try: result = self.invoke([ 'volume-group', 'delete', '--volume-group-id', self.volume_group_clone, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_group_restored'): try: result = self.invoke([ 'volume-group', 'delete', '--volume-group-id', self.volume_group_restored, '--force' ]) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volumes'): for volume in self.volumes: try: result = self.invoke( ['volume', 'delete', '--volume-id', volume, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'volume_clones'): for volume in self.volume_clones: try: result = self.invoke( ['volume', 'delete', '--volume-id', volume, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'restored_volumes'): for volume in self.restored_volumes: try: result = self.invoke( ['volume', 'delete', '--volume-id', volume, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)
def clean_up_resources(self): error_count = 0 if hasattr(self, 'instance_id'): try: print("Deleting instance " + self.instance_id) result = self.invoke(['compute', 'instance', 'terminate', '--instance-id', self.instance_id, '--force']) util.validate_response(result) util.wait_until(['compute', 'instance', 'get', '--instance-id', self.instance_id], 'TERMINATED', max_wait_seconds=1200, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: print("Deleting subnet") result = self.invoke(['network', 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'subnet', 'get', '--subnet-id', self.subnet_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: print("Deleting vcn") result = self.invoke(['network', 'vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force']) util.validate_response(result) util.wait_until(['network', 'vcn', 'get', '--vcn-id', self.vcn_ocid], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'custom_image_id'): try: print("Deleting custom base image") result = self.invoke( ['compute', 'image', 'delete', '--image-id', self.custom_image_id, '--force']) util.validate_response(result) util.wait_until(['compute', 'image', 'get', '--image-id', self.custom_image_id], 'DELETED', max_wait_seconds=3600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'imported_image_from_tuple_id'): try: print("Deleting imported image") result = self.invoke( ['compute', 'image', 'delete', '--image-id', self.imported_image_from_tuple_id, '--force']) util.validate_response(result) util.wait_until(['compute', 'image', 'get', '--image-id', self.imported_image_from_tuple_id], 'DELETED', max_wait_seconds=3600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'imported_image_from_uri_id'): try: print("Deleting imported image") result = self.invoke( ['compute', 'image', 'delete', '--image-id', self.imported_image_from_uri_id, '--force']) util.validate_response(result) util.wait_until(['compute', 'image', 'get', '--image-id', self.imported_image_from_uri_id], 'DELETED', max_wait_seconds=3600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'imported_image_from_par_id'): try: print("Deleting imported image") result = self.invoke( ['compute', 'image', 'delete', '--image-id', self.imported_image_from_par_id, '--force']) util.validate_response(result) util.wait_until(['compute', 'image', 'get', '--image-id', self.imported_image_from_par_id], 'DELETED', max_wait_seconds=3600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'export_via_tuple_object_name')): try: print("Deleting exported image via tuple") result = self.invoke( ['os', 'object', 'delete', '--namespace', self.object_storage_namespace, '--bucket-name', self.bucket_name, '--name', self.export_via_tuple_object_name, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'export_via_uri_object_name')): try: print("Deleting exported image via uri") result = self.invoke( ['os', 'object', 'delete', '--namespace', self.object_storage_namespace, '--bucket-name', self.bucket_name, '--name', self.export_via_uri_object_name, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'export_via_par_object_name')): try: print("Deleting exported image via preauthenticated request") result = self.invoke( ['os', 'object', 'delete', '--namespace', self.object_storage_namespace, '--bucket-name', self.bucket_name, '--name', self.export_via_par_object_name, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'bucket_par_id')): try: print("Deleting bucket par") result = self.invoke( ['os', 'preauth-request', 'delete', '--namespace', self.object_storage_namespace, '--bucket-name', self.bucket_name, '--par-id', self.bucket_par_id, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'object_par_id')): try: print("Deleting object par") result = self.invoke( ['os', 'preauth-request', 'delete', '--namespace', self.object_storage_namespace, '--bucket-name', self.bucket_name, '--par-id', self.object_par_id, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if (hasattr(self, 'bucket_name')): try: print("Deleting bucket") result = self.invoke( ['os', 'bucket', 'delete', '--namespace', self.object_storage_namespace, '--name', self.bucket_name, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 assert error_count == 0
def subtest_delete(self): error_count = 0 if hasattr(self, 'rt_ocid'): max_retry = 3 retry = 0 try: while retry < max_retry: try: util.vcr_mode_aware_sleep(2) result = self.invoke([ 'route-table', 'delete', '--rt-id', self.rt_ocid, '--force' ]) util.validate_response(result) break except Exception as error: # if the route-table no longer exists then don't try to delete it again if '"status": 404' in result.output: break else: retry += 1 print("Retrying route-table delete.") util.wait_until( ['network', 'route-table', 'get', '--rt-id', self.rt_ocid], 'TERMINATED', succeed_if_not_found=True, max_wait_seconds=300) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'ipsc_ocid'): try: result = self.invoke([ 'ip-sec-connection', 'delete', '--ipsc-id', self.ipsc_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'ip-sec-connection', 'get', '--ipsc-id', self.ipsc_ocid ], 'TERMINATED', succeed_if_not_found=True, max_wait_seconds=300) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'drg_attachment_ocid'): try: result = self.invoke([ 'drg-attachment', 'delete', '--drg-attachment-id', self.drg_attachment_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'drg-attachment', 'get', '--drg-attachment-id', self.drg_attachment_ocid ], 'DETACHED', succeed_if_not_found=True, max_wait_seconds=600) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'drg_ocid'): try: result = self.invoke( ['drg', 'delete', '--drg-id', self.drg_ocid, '--force']) util.validate_response(result) util.wait_until( ['network', 'drg', 'get', '--drg-id', self.drg_ocid], 'TERMINATED', succeed_if_not_found=True, max_wait_seconds=600) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'dhcp_options_ocid'): try: result = self.invoke([ 'dhcp-options', 'delete', '--dhcp-id', self.dhcp_options_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'dhcp-options', 'get', '--dhcp-id', self.dhcp_options_ocid ], 'TERMINATED', succeed_if_not_found=True, max_wait_seconds=600) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'cpe_ocid'): try: result = self.invoke( ['cpe', 'delete', '--cpe-id', self.cpe_ocid, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'ig_ocid'): try: result = self.invoke([ 'internet-gateway', 'delete', '--ig-id', self.ig_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'internet-gateway', 'get', '--ig-id', self.ig_ocid ], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'subnet_ocid'): try: result = self.invoke([ 'subnet', 'delete', '--subnet-id', self.subnet_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'subnet', 'get', '--subnet-id', self.subnet_ocid ], 'TERMINATED', max_wait_seconds=600, succeed_if_not_found=True) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'sl_ocid'): try: result = self.invoke([ 'security-list', 'delete', '--security-list-id', self.sl_ocid, '--force' ]) util.validate_response(result) util.wait_until([ 'network', 'security-list', 'get', '--security-list-id', self.sl_ocid ], 'TERMINATED', succeed_if_not_found=True, max_wait_seconds=300) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 if hasattr(self, 'vcn_ocid'): try: result = self.invoke( ['vcn', 'delete', '--vcn-id', self.vcn_ocid, '--force']) util.validate_response(result) except Exception as error: util.print_latest_exception(error) error_count = error_count + 1 self.assertEquals(0, error_count)