Exemplo n.º 1
0
def delete_project(name):
    '''
    Delete all elements associated with a given project/pipeline(ontap volume/jenkins job)
    '''
    try:
        config = get_db_config()
        db = connect_db()
        project = Database.get_document_by_name(db, name)
        volume = project['volume']
        ontap = OntapService(config['ontap_api'], config['ontap_apiuser'],
                             config['ontap_apipass'], config['ontap_svm_name'],
                             config['ontap_aggr_name'],
                             config['ontap_data_ip'])
        ontap.delete_volume(volume)
        db.delete(project)
        jenkins = connect_jenkins()
        jenkins.delete_job(name)

    except Exception as e:
        logging.error("Unable to delete project!: %s" % traceback.format_exc())
        raise
Exemplo n.º 2
0
def delete_workspace(name):
    '''

    '''
    try:
        config = get_db_config()
        db = connect_db()
        ontap = OntapService(config['ontap_api'], config['ontap_apiuser'],
                             config['ontap_apipass'], config['ontap_svm_name'],
                             config['ontap_aggr_name'],
                             config['ontap_data_ip'])
        ontap.delete_volume(name)
        workspace = Database.get_document_by_name(db, name)
        pod_name = workspace['pod_name']
        db.delete(workspace)
        kube = KubernetesAPI()
        kube.delete_pod(pod_name)

    except Exception as e:
        logging.error("Unable to delete workspace!: %s" %
                      traceback.format_exc())
        raise