Beispiel #1
0
 def _get_resource_provider_by_uuid(self, context, provider_uuid):
     query = model_query(models.ResourceProvider)
     query = query.filter_by(uuid=provider_uuid)
     try:
         return query.one()
     except NoResultFound:
         raise exception.ResourceProviderNotFound(
             resource_provider=provider_uuid)
Beispiel #2
0
 def destroy_resource_provider(self, context, provider_id):
     session = get_session()
     with session.begin():
         query = model_query(models.ResourceProvider, session=session)
         query = add_identity_filter(query, provider_id)
         count = query.delete()
         if count != 1:
             raise exception.ResourceProviderNotFound(
                 resource_provider=provider_id)
Beispiel #3
0
 def _get_resource_provider_by_name(self, context, provider_name):
     query = model_query(models.ResourceProvider)
     query = query.filter_by(name=provider_name)
     try:
         return query.one()
     except NoResultFound:
         raise exception.ResourceProviderNotFound(
             resource_provider=provider_name)
     except MultipleResultsFound:
         raise exception.Conflict('Multiple resource providers exist with '
                                  'same name. Please use the uuid instead.')
Beispiel #4
0
    def _do_update_resource_provider(self, provider_id, values):
        session = get_session()
        with session.begin():
            query = model_query(models.ResourceProvider, session=session)
            query = add_identity_filter(query, provider_id)
            try:
                ref = query.with_lockmode('update').one()
            except NoResultFound:
                raise exception.ResourceProviderNotFound(
                    resource_provider=provider_id)

            ref.update(values)
        return ref