コード例 #1
0
ファイル: object.py プロジェクト: p0i0/openstack-glance
def _get(context, object_id, session):
    try:
        query = session.query(models.MetadefObject).filter_by(id=object_id)
        metadef_object = query.one()
    except sa_orm.exc.NoResultFound:
        msg = (_("Metadata definition object not found for id=%s") % object_id)
        LOG.warn(msg)
        raise exc.MetadefObjectNotFound(msg)

    return metadef_object
コード例 #2
0
def _get_by_name(context, namespace_name, name, session):
    namespace = namespace_api.get(context, namespace_name, session)
    try:
        query = session.query(models.MetadefObject)\
            .filter_by(name=name, namespace_id=namespace['id'])
        metadef_object = query.one()
    except sa_orm.exc.NoResultFound:
        msg = ("The metadata definition object with name=%(name)s"
               " was not found in namespace=%(namespace_name)s."
               % {'name': name, 'namespace_name': namespace_name})
        LOG.debug(msg)
        raise exc.MetadefObjectNotFound(object_name=name,
                                        namespace_name=namespace_name)

    return metadef_object