示例#1
0
class CITaskConfigManager(object):
    def __init__(self, mongo_host, mongo_port, db, collection):
        self.host = mongo_host
        self.port = mongo_port
        self.db = db
        self.collection = collection
        self.default_db = "doraemon"
        self.default_collection = "ci"
        self.mongo_helper = MongodbHelper(self.host, self.port)

    def save(self, value):
        return self.mongo_helper.save(self.db, self.collection, value)

    def remove(self, doc_id):
        result = self.mongo_helper.remove(self.db, self.collection, doc_id)
        if result == None:
            result = self.mongo_helper.remove(self.default_db,
                                              self.default_collection, doc_id)
        return result

    def get(self, doc_id):
        result = self.mongo_helper.get(self.db, self.collection, doc_id)
        if result == None:
            result = self.mongo_helper.get(self.default_db,
                                           self.default_collection, doc_id)
        return result
示例#2
0
 def get_replace_config(self, doc_id):
     mongo_helper = MongodbHelper(CIDeployServiceManager.host, CIDeployServiceManager.port)
     result = mongo_helper.get(CIDeployServiceManager.db, CIDeployServiceManager.collection, doc_id)
     if result == None:
         result = mongo_helper.get(CIDeployServiceManager.default_db, CIDeployServiceManager.default_collection,
                                   doc_id)
     return result
示例#3
0
 def get(db, collection, doc_id):
     HOST = MONGODB['default']['HOST']
     PORT = MONGODB['default']['PORT']
     mongo_helper = MongodbHelper(HOST, PORT)
     result = mongo_helper.get(db, collection, doc_id)
     if result == None:
         result = mongo_helper.get('doraemon', 'ci', doc_id)
     return result
示例#4
0
 def get(db, collection, doc_id):
     HOST = MONGODB['default']['HOST']
     PORT = MONGODB['default']['PORT']
     mongo_helper = MongodbHelper(HOST, PORT)
     result = mongo_helper.get(db, collection, doc_id)
     return result
示例#5
0
 def get_value(self, doc_id):
     mongo_helper = MongodbHelper(self.host, self.port)
     grid_out = mongo_helper.get(self.db, self.collection, doc_id)
     return grid_out