def _try_to_delete_nodes(tf_folder):
    log.info('Start running terraform delete')
    utils.run_command_with_output(f'cd {tf_folder} && '
                                  'terraform destroy '
                                  '-auto-approve '
                                  '-input=false '
                                  '-state=terraform.tfstate '
                                  '-state-out=terraform.tfstate '
                                  '-var-file=terraform.tfvars.json')
示例#2
0
def delete_nodes(tfvars):
    try:
        print("Start running terraform delete")
        cmd = "cd build/terraform/  && terraform destroy -auto-approve " \
              "-input=false -state=terraform.tfstate -state-out=terraform.tfstate -var-file=terraform.tfvars.json"
        utils.run_command_with_output(cmd)
    except:
        print("Failed to run terraform delete")
    finally:
        virsh_cleanup.clean_virsh_resources(virsh_cleanup.DEFAULT_SKIP_LIST, [
            tfvars.get("cluster_name", consts.TEST_INFRA),
            tfvars.get("libvirt_network_name", consts.TEST_INFRA)
        ])
def delete_nodes(tfvars):
    try:
        log.info("Start running terraform delete")
        cmd = "cd %s  && terraform destroy -auto-approve " \
              "-input=false -state=terraform.tfstate -state-out=terraform.tfstate " \
              "-var-file=terraform.tfvars.json" % consts.TF_FOLDER
        utils.run_command_with_output(cmd)
    except:
        log.exception("Failed to run terraform delete, deleting %s",
                      consts.TF_FOLDER)
        shutil.rmtree(consts.TF_FOLDER)
    finally:
        virsh_cleanup.clean_virsh_resources(virsh_cleanup.DEFAULT_SKIP_LIST, [
            tfvars.get("cluster_name", consts.TEST_INFRA),
            tfvars.get("libvirt_network_name", consts.TEST_INFRA)
        ])