示例#1
0
    def update(self, request, system_id):
        """@description-title Update a region controller
        @description Updates a region controller with the given system_id.

        @param (string) "{system_id}" [required=true] The region controller's
        system_id.

        @param (string) "description" [required=false] The new description for
        this given region controller.

        @param (string) "power_type" [required=false] The new power type for
        this region controller. If you use the default value, power_parameters
        will be set to the empty string.  Available to admin users.  See the
        `Power types`_ section for a list of the available power types.

        @param (string) "power_parameters_{param1}" [required=true] The new
        value for the 'param1' power parameter. Note that this is dynamic as
        the available parameters depend on the selected value of the region
        controller's power_type.  Available to admin users. See the `Power
        types`_ section for a list of the available power parameters for each
        power type.

        @param (boolean) "power_parameters_skip_check" [required=false] Whether
        or not the new power parameters for this region controller should be
        checked against the expected power parameters for the region
        controller's power type ('true' or 'false').  The default is 'false'.

        @param (string) "zone" [required=false] Name of a valid physical zone
        in which to place this region controller.

        @success (http-status-code) "200" 200
        @success (json) "success-json" A JSON object containing the updated
        region controller object.
        @success-example (json) "success-json" [exkey=update] placeholder text

        @error (http-status-code) "404" 404
        @error (content) "not-found" The requested region controller system_id
        is not found.
        @error-example "not-found"
            Not Found

        @error (http-status-code) "403" 403
        @error (content) "no-perms" The user does not have permission to
        update the region controller.
        @error-example "no-perms"
            This method is reserved for admin users.
        """
        region = self.model.objects.get_node_or_404(system_id=system_id,
                                                    user=request.user,
                                                    perm=NodePermission.admin)
        form = ControllerForm(data=request.data, instance=region)

        if form.is_valid():
            return form.save()
        else:
            raise MAASAPIValidationError(form.errors)
示例#2
0
    def update(self, request, system_id):
        """@description-title Update a rack controller
        @description Updates a rack controller with the given system_id.

        @param (string) "description" [required=false] The new description for
        this given rack controller.

        @param (string) "power_type" [required=false] The new power type for
        the given rack controller. If you use the default value,
        power_parameters will be set to an empty string. See the
        `Power types`_ section for a list of available power types. Note that
        only admin users can set this parameter.

        @param (string) "power_parameters_{param}" [required=true] The new
        value for the 'param' power parameter. This is a dynamic parameter
        that depends on the rack controller's power_type. See the
        `Power types`_ section for a list of available parameters based on
        power type. Note that only admin users can set these parameters.

        @param (boolean) "power_parameters_skip_check" [required=false] If
        true, the new power parameters for the given rack controller will be
        checked against the expected parameters for the rack controller's power
        type. Default is false.

        @param (string) "zone" [required=false] The name of a valid zone in
        which to place the given rack controller.

        @param (string) "domain" [required=false] The domain for this
        controller. If not given the default domain is used.

        @success (http-status-code) "200" 200
        @success (content) "success-json" A JSON object containing the updated
        rack-controller object.
        @success-example "success-json" [exkey=update] placeholder

        @error (http-status-code) "404" 404
        @error (content) "not-found" The requested rack controller system_id
        is not found.
        @error-example "not-found"
            Not Found

        @error (http-status-code) "403" 403
        @error (content) "no-perms" This method is reserved for admin users.
        """
        rack = self.model.objects.get_node_or_404(system_id=system_id,
                                                  user=request.user,
                                                  perm=NodePermission.admin)
        form = ControllerForm(data=request.data, instance=rack)

        if form.is_valid():
            return form.save()
        else:
            raise MAASAPIValidationError(form.errors)
示例#3
0
    def update(self, request, system_id):
        """Update a specific Region controller.

        :param power_type: The new power type for this region controller. If
            you use the default value, power_parameters will be set to the
            empty string.
            Available to admin users.
            See the `Power types`_ section for a list of the available power
            types.
        :type power_type: unicode

        :param power_parameters_{param1}: The new value for the 'param1'
            power parameter.  Note that this is dynamic as the available
            parameters depend on the selected value of the region controller's
            power_type.  Available to admin users. See the `Power types`_
            section for a list of the available power parameters for each
            power type.
        :type power_parameters_{param1}: unicode

        :param power_parameters_skip_check: Whether or not the new power
            parameters for this region controller should be checked against the
            expected power parameters for the region controller's power type
            ('true' or 'false').
            The default is 'false'.
        :type power_parameters_skip_check: unicode

        :param zone: Name of a valid physical zone in which to place this
            region controller.
        :type zone: unicode

        Returns 404 if the region controller is not found.
        Returns 403 if the user does not have permission to update the region
        controller.
        """
        region = self.model.objects.get_node_or_404(system_id=system_id,
                                                    user=request.user,
                                                    perm=NODE_PERMISSION.EDIT)
        form = ControllerForm(data=request.data, instance=region)

        if form.is_valid():
            return form.save()
        else:
            raise MAASAPIValidationError(form.errors)