Exemplo n.º 1
0
def delete_workspace(name):
    """
        Delete Kube service representing the workspace IDE
        Delete Kube pod associated with the service
        Delete Kube PVC representing the workspace (Trident will delete the associated PV and ONTAP clone)
        Delete Kube service representing the IDE
    """
    # TODO: Handle exceptions on db connection failure, and failure on each of the kube operations
    try:
        config = get_db_config()
        db = connect_db()
        workspace = Database.get_document_by_name(db, name)
        pvc = workspace['pvc']
        pod_name = workspace['pod']
        service = workspace['service']
        kube = KubernetesAPI()
        kube.delete_service(service)
        logging.info("Workspace service deleted")
        kube.delete_pod(pod_name)
        logging.info("Workspace POD deleted")
        kube.delete_pvc(pvc)
        logging.info("Workspace PVC deleted")
        db.delete(workspace)
    except Exception as e:
        logging.error("Unable to delete workspace %s: %s" %
                      (name, 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