Пример #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 save(db, collection, value):
     HOST = MONGODB['default']['HOST']
     PORT = MONGODB['default']['PORT']
     mongo_helper = MongodbHelper(HOST, PORT)
     return mongo_helper.save(db, collection, value)
Пример #3
0
 def save_replace_config(self, value):
     mongo_helper = MongodbHelper(CIDeployServiceManager.host,
                                  CIDeployServiceManager.port)
     return mongo_helper.save(CIDeployServiceManager.db,
                              CIDeployServiceManager.collection, value)
Пример #4
0
 def save_value(self, value):
     mongo_helper = MongodbHelper(self.host, self.port)
     doc_id = mongo_helper.save(self.db, self.collection, value)
     return doc_id