예제 #1
0
def deletedb(serviceid, dbid):
    namespace = "default"
    tenantid = "servicedesigns"
    labelstring = 'dbjob=' + 'dbjob' + dbid
    db_path = tenantid + "/" + serviceid + "/data/" + dbid
    db_outputfile = db_path + "/output.json"
    db_logfile = db_path + "/log.json"
    deployment_status, deployment_status_message = delete_deployment(
        dbid, namespace)
    service_status, service_status_message = delete_service(dbid, namespace)
    job_status, job_status_message = delete_job(dbid, namespace)
    pod_status, pod_status_message = delete_pod(namespace, labelstring)
    if deployment_status == "success":
        if service_status == "success":
            if job_status == "success":
                if pod_status == "success":
                    delete_op_status, delete_op_status_message, delete_op_response = datafile.delete_s3_file(
                        db_outputfile)
                    dellog_status, dellog_statusmessage, delresponse = datafile.delete_s3_file(
                        db_logfile)
                    if delete_op_status == "success" and dellog_status == "success":
                        status_message = {
                            "status": 200,
                            "status_message": "db_deleted_successfully"
                        }
                    else:
                        status_message = {
                            "status": 400,
                            "status_message": delete_op_status_message,
                            "error_message": delete_op_response
                        }
                else:
                    status_message = {
                        "status": 400,
                        "status_message": "dbpod_deletion_failed",
                        "error_message": pod_status_message
                    }
            else:
                status_message = {
                    "status": 400,
                    "status_message": "dbjob_deletion_failed",
                    "error_message": job_status_message
                }
        else:
            status_message = {
                "status": 400,
                "status_message": "dbservice_deletion_failed",
                "error_message": service_status_message
            }
    else:
        status_message = {
            "status": 400,
            "status_message": "dbdeployment_deletion_failed",
            "error_message": deployment_status
        }
    return (status_message)
예제 #2
0
def deletemethod(productid, serviceid, apiid, versionid, resourceid, methodid):
    resourcepath = "servicedesigns/" + serviceid + "/api/" + versionid + "/resources/" + resourceid + "/config.json"
    status, statusmessage, resource = datafile.load_s3_file(resourcepath)
    if status == "success":
        methodids = []
        for method in resource["methods"]:
            methodids.append(method["Ref"])
        if methodid in methodids:
            for method in resource["methods"]:
                if method["Ref"] == methodid:
                    resource["methods"].remove(method)
                    resstatus, resstatusmessage, res = datafile.write_s3_file(
                        resourcepath, resource)
            methodprefix = "servicedesigns/" + serviceid + "/api/" + versionid + "/resources/" + resourceid + "/methods/" + methodid
            methodpath = methodprefix + ".json"
            status, statusmessage, delmeth = datafile.delete_s3_file(
                methodpath)
            delstatus, delstatusmessage = datafile.delete_folders(methodprefix)
            if status == "success" and delstatus == "success":
                message = {"statusCode": 200, "message": "method deleted"}
            else:
                message = {"statusCode": 400, "message": delstatusmessage}
        else:
            message = {"statusCode": 400, "message": "methodid does not exist"}
    else:
        message = {"errorMessage": statusmessage, "Error": resource}
    return (message)
예제 #3
0
def deletetestcases(productid, serviceid, apiid, versionid, resourceid,
                    methodid, testcaseid):
    testcasepath = "servicedesigns/" + serviceid + "/api/" + versionid + "/resources/" + resourceid + "/testcases/" + methodid + "/" + testcaseid + ".json"
    deletestatus, deletestatusmessage, deleteresponse = datafile.delete_s3_file(
        testcasepath)
    if deletestatus == "success":
        message = {"statusCode": 200, "body": "testcase successfully deleted"}
    else:
        message = {"statusCode": 400, "errorMessage": deleteresponse}
    return (message)
예제 #4
0
def deletetablejob(serviceid, dbid, tableid):
    namespace = "default"
    labelstring = 'tablejob=' + 'tablejob' + tableid
    tenantid = "servicedesigns"
    table_path = tenantid + "/" + serviceid + "/data/" + dbid + "/tables/" + tableid
    table_outputfile = table_path + "/output.json"
    table_logfile = table_path + "/log.json"
    jobstatus, jobstatus_message = delete_job(tableid, namespace)
    podstatus, podstatus_message = delete_pod(namespace, labelstring)
    if jobstatus == "success":
        if podstatus == "success":
            delete_op_status, delete_op_status_message, delete_op_response = datafile.delete_s3_file(
                table_outputfile)
            delete_logs_status, delete_logs_status_message, delete_logs_response = datafile.delete_s3_file(
                table_logfile)
            if delete_op_status == "success" and delete_logs_status == "success":
                status_message = {
                    "status": 200,
                    "status_message": "tablejob_and_pod_deleted_successfully"
                }
            else:
                status_message = {
                    "status": 400,
                    "status_message": delete_op_status_message,
                    "error_message": delete_op_response
                }
        else:
            status_message = {
                "status": 400,
                "status_message": "tablepod_deletion_failed",
                "error_message": podstatus_message
            }
    else:
        status_message = {
            "status": 400,
            "status_message": "tablejob_deletion_failed",
            "error_message": jobstatus_message
        }
    return (status_message)
예제 #5
0
def deleteconf():
    try:
        coderepoconfigpath = "repoconfig/config.json"
        secretpath = os.getenv("NETRC")
        netrcpath = "/home/app/.netrc"
        status, statusmessage, delgitconf = datafile.delete_s3_file(
            coderepoconfigpath)
        if status == "error":
            message = {"statusCode": 400, "errorMessage": statusmessage}
            return (message)
        if os.path.exists(secretpath):
            os.remove(secretpath)
        if os.path.exists(netrcpath):
            os.remove(netrcpath)
        message = {"statusCode": 200, "message": "gitconfig deleted"}
        return (message)
    except Exception as e:
        message = {"statusCode": 400, "errormessage": str(e)}
        return (message)
예제 #6
0
def deletedata(serviceid, versionid, resourceid, dbid):
    resourcepath = "servicedesigns/" + serviceid + "/api/" + versionid + "/resources/" + resourceid + "/config.json"
    status, statusmessage, resource = datafile.load_s3_file(resourcepath)
    if status == "success":
        for data in resource["data"]:
            if data["db"] != []:
                dbids = []
                for db in data["db"]:
                    dbids.append(db["Ref"])
                if dbid in dbids:
                    for db in data["db"]:
                        if db["Ref"] == dbid:
                            data["db"].remove(db)
                            status, statusmessage, response = datafile.write_s3_file(
                                resourcepath, resource)
                    datapath = "servicedesigns/" + serviceid + "/data/" + dbid + "/config.json"
                    delstatus, delstatusmessage, delres = datafile.delete_s3_file(
                        datapath)
                    datapathprefix = "servicedesigns/" + serviceid + "/data/" + dbid
                    delstatus, delstatusmessage = datafile.delete_folders(
                        datapathprefix)
                    message = {
                        "statusCode": 200,
                        "message": "database deleted"
                    }
                else:
                    message = {
                        "statusCode": 400,
                        "errorMessage": "dbid does not exist"
                    }
            else:
                message = {
                    "statusCode": 400,
                    "errorMessage": "no database present"
                }
    else:
        message = {"errorMessage": statusmessage, "Error": resource}
    return (message)
예제 #7
0
def deleteresource(serviceid, resourceid, versionid):
    namespace = "default"
    labelstring = 'resourcejob=' + 'resourcejob' + resourceid
    resource_path = "servicedesigns/" + serviceid + "/api/" + versionid + "/resources/" + resourceid
    resource_outputfile = resource_path + "/output.json"
    deployment_status, deployment_status_message = delete_deployment(
        resourceid, namespace)
    service_status, service_status_message = delete_service(
        resourceid, namespace)
    job_status, job_status_message = delete_job(resourceid, namespace)
    pod_status, pod_status_message = delete_pod(namespace, labelstring)
    ingress_status, ingress_status_message = delete_ingress(
        resourceid, namespace)
    if deployment_status == "success":
        if service_status == "success":
            if job_status == "success":
                if pod_status == "success":
                    if ingress_status == "success":
                        delete_op_status, delete_op_status_message, delete_op_response = datafile.delete_s3_file(
                            resource_outputfile)
                        if delete_op_status == "success":
                            status_message = {
                                "status": 200,
                                "status_message":
                                "resource_deleted_successfully"
                            }
                        else:
                            status_message = {
                                "status": 400,
                                "status_message": delete_op_status_message,
                                "error_message": delete_op_response
                            }
                    else:
                        status_message = {
                            "status": 400,
                            "status_message": "ingress_deletion_failed",
                            "error_message": ingress_status_message
                        }
                else:
                    status_message = {
                        "status": 400,
                        "status_message": "resource_pod_deletion_failed",
                        "error_message": pod_status_message
                    }
            else:
                status_message = {
                    "status": 400,
                    "status_message": "resource_job_deletion_failed",
                    "error_message": job_status_message
                }
        else:
            status_message = {
                "status": 400,
                "status_message": "resource_service_deletion_failed",
                "error_message": service_status_message
            }
    else:
        status_message = {
            "status": 400,
            "status_message": "resource_deployment_deletion_failed",
            "error_message": deployment_status
        }
    return (status_message)