Exemplo n.º 1
0
    def create_unit(self, struct, callback):
        '''
            Create unit
        '''

        try:
            unit = ClusterUnit(struct)
            unit.validate()
        except Exception, e:
            callback(None, e)
            return
Exemplo n.º 2
0
    def read_unit(self, unit_uuid, callback):
        '''
            Read unit data
        '''

        try:
            unit = yield motor.Op(
                self.db.units.find_one, {
                    'uuid':unit_uuid
                }, {'_id':0}
            )
            if unit:
                unit = ClusterUnit(unit)
                unit.validate()
        except Exception, e:
            callback(None, e)
            return