def create_unit(self, struct, callback): ''' Create unit ''' try: unit = ClusterUnit(struct) unit.validate() except Exception, e: callback(None, e) return
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