예제 #1
0
    def update(self, req, id, body):
        """Update a security service."""
        context = req.environ['manila.context']

        if not body or 'security_service' not in body:
            raise exc.HTTPUnprocessableEntity()

        security_service_data = body['security_service']
        valid_update_keys = ('description', 'name')

        try:
            security_service = db.security_service_get(context, id)
            policy.check_policy(context, RESOURCE_NAME, 'show',
                                security_service)
        except exception.NotFound:
            raise exc.HTTPNotFound()

        if security_service['status'].lower() in ['new', 'inactive']:
            update_dict = security_service_data
        else:
            update_dict = dict([(key, security_service_data[key])
                                for key in valid_update_keys
                                if key in security_service_data])

        policy.check_policy(context, RESOURCE_NAME, 'update', security_service)
        security_service = db.security_service_update(context, id, update_dict)
        return self._view_builder.detail(req, security_service)
예제 #2
0
    def update(self, req, id, body):
        """Update a security service."""
        context = req.environ['manila.context']

        if not body or 'security_service' not in body:
            raise exc.HTTPUnprocessableEntity()

        security_service_data = body['security_service']
        valid_update_keys = ('description', 'name')

        try:
            security_service = db.security_service_get(context, id)
            policy.check_policy(context, RESOURCE_NAME, 'update',
                                security_service)
        except exception.NotFound:
            raise exc.HTTPNotFound()

        if self._share_servers_dependent_on_sn_exist(context, id):
            for item in security_service_data:
                if item not in valid_update_keys:
                    msg = _("Cannot update security service %s. It is "
                            "attached to share network with share server "
                            "associated. Only 'name' and 'description' "
                            "fields are available for update.") % id
                    raise exc.HTTPForbidden(explanation=msg)

        policy.check_policy(context, RESOURCE_NAME, 'update', security_service)
        security_service = db.security_service_update(context, id,
                                                      security_service_data)
        return self._view_builder.detail(req, security_service)
예제 #3
0
    def update(self, req, id, body):
        """Update a security service."""
        context = req.environ['manila.context']

        if not body or 'security_service' not in body:
            raise exc.HTTPUnprocessableEntity()

        security_service_data = body['security_service']
        valid_update_keys = (
            'description',
            'name'
        )

        try:
            security_service = db.security_service_get(context, id)
            policy.check_policy(context, RESOURCE_NAME, 'update',
                                security_service)
        except exception.NotFound:
            raise exc.HTTPNotFound()

        if self._share_servers_dependent_on_sn_exist(context, id):
            for item in security_service_data:
                if item not in valid_update_keys:
                    msg = _("Cannot update security service %s. It is "
                            "attached to share network with share server "
                            "associated. Only 'name' and 'description' "
                            "fields are available for update.") % id
                    raise exc.HTTPForbidden(explanation=msg)

        policy.check_policy(context, RESOURCE_NAME, 'update', security_service)
        security_service = db.security_service_update(
            context, id, security_service_data)
        return self._view_builder.detail(req, security_service)
예제 #4
0
    def update(self, req, id, body):
        """Update a security service."""
        context = req.environ['manila.context']

        if not body or 'security_service' not in body:
            raise exc.HTTPUnprocessableEntity()

        security_service_data = body['security_service']
        valid_update_keys = (
            'description',
            'name'
        )

        try:
            security_service = db.security_service_get(context, id)
            policy.check_policy(context, RESOURCE_NAME, 'show',
                                security_service)
        except exception.NotFound:
            raise exc.HTTPNotFound()

        if security_service['status'].lower() in ['new', 'inactive']:
            update_dict = security_service_data
        else:
            update_dict = dict([(key, security_service_data[key])
                                for key in valid_update_keys
                                if key in security_service_data])

        policy.check_policy(context, RESOURCE_NAME, 'update', security_service)
        security_service = db.security_service_update(context, id, update_dict)
        return self._view_builder.detail(req, security_service)