Exemplo n.º 1
0
    def post(self, rc):
        """Create a new ReplicationController.

        :param rc: a ReplicationController within the request body.
        """
        rc.parse_manifest()
        rc_dict = rc.as_dict()
        context = pecan.request.context
        rc_dict['project_id'] = context.project_id
        rc_dict['user_id'] = context.user_id
        rc_obj = objects.ReplicationController(context, **rc_dict)
        new_rc = pecan.request.rpcapi.rc_create(rc_obj)
        if not new_rc:
            raise exception.InvalidState()

        # Set the HTTP Location Header
        pecan.response.location = link.build_url('rcs', new_rc.uuid)
        return ReplicationController.convert_with_links(new_rc)
Exemplo n.º 2
0
    def post(self, service):
        """Create a new service.

        :param service: a service within the request body.
        """
        service.parse_manifest()
        service_dict = service.as_dict()
        context = pecan.request.context
        service_dict['project_id'] = context.project_id
        service_dict['user_id'] = context.user_id
        service_obj = objects.Service(context, **service_dict)
        new_service = pecan.request.rpcapi.service_create(service_obj)
        if new_service is None:
            raise exception.InvalidState()

        # Set the HTTP Location Header
        pecan.response.location = link.build_url('services', new_service.uuid)
        return Service.convert_with_links(new_service)
Exemplo n.º 3
0
 def test_InvalidState(self):
     self.assertRaises(exception.InvalidState,
                       lambda: self.raise_(exception.InvalidState()))