def service_get(service_id, session=None): result = model_query(service_models.Service, session=session). \ filter_by(id=service_id). \ first() if not result: raise exception.ServiceNotFound(service_id=service_id) return result
def count_insert_or_update(name, url): print name, url session = get_session() result = model_query(APICount, session=session). \ filter_by(name=name). \ filter_by(url=url). \ first() if not result: with session.begin(): result = APICount() result.update({'name': name, 'url': url, 'count': 1}) result.save() else: result.count += 1 result.save(session=session) return result
def service_get_by_args(host, binary): return model_query(service_models.Service). \ filter_by(host=host). \ filter_by(binary=binary). \ first()
def count_list(): return model_query(APICount).all()
def service_list(): return model_query(service_models.Service).all()
def P_machine_get_undelete(deleted=False, session=None): return model_query(PhysicalMachine, session=session). \ filter_by(deleted=deleted). \ all()
def P_machine_get_by_id(id, deleted=False, session=None): return model_query(PhysicalMachine, session=session). \ filter_by(id=id). \ filter_by(deleted=deleted). \ first()
def P_machine_list(): return model_query(PhysicalMachine).all()
def P_machine_get_by_userid_(user_id, cb_sysname, deleted=False, session=None): return model_query(PhysicalMachine, session=session). \ filter_by(user_id=user_id). \ filter_by(cobbler_sysname=cb_sysname). \ filter_by(deleted=deleted). \ first()
def P_machine_get_by_user_id(user_id, deleted=False, session=None): return model_query(PhysicalMachine, session=session). \ filter_by(user_id=user_id). \ filter_by(deleted=deleted). \ all()