def destroy_port(self, uuid): session = get_session() with session.begin(): query = model_query(models.Port, session=session) query = add_identity_filter(query, uuid) count = query.delete() if count == 0: raise exception.PortNotFound(uuid=uuid)
def get_port_by_name(self, port_name): query = model_query(models.Port).filter_by(name=port_name) try: return query.one() except NoResultFound: raise exception.PortNotFound(name=port_name)
def get_port_by_uuid(self, port_uuid): query = model_query(models.Port).filter_by(uuid=port_uuid) try: return query.one() except NoResultFound: raise exception.PortNotFound(uuid=port_uuid)