예제 #1
0
파일: api.py 프로젝트: mkscala/magnum
 def destroy_container(self, container_id):
     session = get_session()
     with session.begin():
         query = model_query(models.Container, session=session)
         query = add_identity_filter(query, container_id)
         count = query.delete()
         if count != 1:
             raise exception.ContainerNotFound(container_id)
예제 #2
0
파일: api.py 프로젝트: mkscala/magnum
 def get_container_by_uuid(self, context, container_uuid):
     query = model_query(models.Container)
     query = self._add_tenant_filters(context, query)
     query = query.filter_by(uuid=container_uuid)
     try:
         return query.one()
     except NoResultFound:
         raise exception.ContainerNotFound(container=container_uuid)
예제 #3
0
파일: api.py 프로젝트: mkscala/magnum
 def get_container_by_name(self, context, container_name):
     query = model_query(models.Container)
     query = self._add_tenant_filters(context, query)
     query = query.filter_by(name=container_name)
     try:
         return query.one()
     except NoResultFound:
         raise exception.ContainerNotFound(container=container_name)
     except MultipleResultsFound:
         raise exception.Conflict('Multiple containers exist with same '
                                  'name. Please use the container uuid '
                                  'instead.')
예제 #4
0
파일: api.py 프로젝트: mkscala/magnum
    def _do_update_container(self, container_id, values):
        session = get_session()
        with session.begin():
            query = model_query(models.Container, session=session)
            query = add_identity_filter(query, container_id)
            try:
                ref = query.with_lockmode('update').one()
            except NoResultFound:
                raise exception.ContainerNotFound(container=container_id)

            if 'provision_state' in values:
                values['provision_updated_at'] = timeutils.utcnow()

            ref.update(values)
        return ref
예제 #5
0
 def test_ContainerNotFound(self):
     self.assertRaises(exception.ContainerNotFound,
                       lambda: self.raise_(exception.ContainerNotFound()))