示例#1
0
def delete_application(name):
    try:
        x = del_application(name)
        if not x:
            raise NotExistError("application %s not exist" % name, "")
        x = x[0]
        fields = json.loads(x.fields)
        app = Application(name=x.name, fields=fields, buckets=x.s3_buckets)
        S3Ins.del_s3_buckets(x.s3_buckets.split(","))
        logger.info("delete application %s", name)
        return app
    except Exception as e:
        logger.error(e)
        return e
示例#2
0
def delete_application(name, force=False):
    try:
        if not force:
            if not entities_list(name, 100, 0):
                raise RequestError(
                    "Prevent to delete application with entity not deleted",
                    "")
        app = MongoIns.search_by_name(APPLICATION_COLLECTION_NAME, name)
        if not app:
            raise NotExistError(f"application {name} not exist", "")
        app = app[0]
        delete_milvus_collections_by_fields(app)
        S3Ins.del_s3_buckets(app['bucket'])
        MongoIns.delete_mongo_collection(f"{name}_entity")
        MongoIns.delete_by_name(APPLICATION_COLLECTION_NAME, name)
        logger.info("delete application %s", name)
        application = Application(app["name"], app["fields"], app["bucket"])
        application.metadata = app["metadata"]
        return application
    except Exception as e:
        logger.error(e)
        raise e
示例#3
0
def delete_application(name):
    try:
        if len(entities_list(name, 100, 0)):
            raise RequestError(
                "Prevent to delete application with entity not deleted", "")
        # TODO rewrite clean all resource before change metadata
        x = del_application(name)
        if not x:
            raise NotExistError(f"application {name} not exist", "")
        x = x[0]
        fields = search_fields(json.loads(x.fields))
        app = Application(name=x.name,
                          fields=fields2dict(fields),
                          buckets=x.s3_buckets)
        delete_milvus_collections_by_fields(app)
        delete_fields(json.loads(x.fields))
        S3Ins.del_s3_buckets(x.s3_buckets.split(","))
        MongoIns.delete_mongo_collection(f"{name}_entity")
        logger.info("delete application %s", name)
        return app
    except Exception as e:
        logger.error(e)
        raise e