(self, cluster_template_ident, patch)
return ClusterTemplate.convert_with_links(cluster_template)
Update an existing ClusterTemplate.

        :param cluster_template_ident: UUID or logic name of a
        ClusterTemplate.
        :param patch: a json PATCH document to apply to this
        ClusterTemplate.
Update an existing ClusterTemplate.
Update an existing ClusterTemplate .
def patch(self, cluster_template_ident, patch):   # noqa
        """Update an existing ClusterTemplate.

        :param cluster_template_ident: UUID or logic name of a
        ClusterTemplate.
        :param patch: a json PATCH document to apply to this
        ClusterTemplate.
        """
        context = pecan.request.context
        if context.is_admin:
            policy.enforce(context, 'clustertemplate:update_all_projects',
                           action='clustertemplate:update_all_projects')
            context.all_tenants = True
        cluster_template = api_utils.get_resource('ClusterTemplate',
                                                  cluster_template_ident)
        policy.enforce(context, 'clustertemplate:update',
                       cluster_template.as_dict(),
                       action='clustertemplate:update')
        try:
            cluster_template_dict = cluster_template.as_dict()
            new_cluster_template = ClusterTemplate(**api_utils.apply_jsonpatch(
                cluster_template_dict,
                patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        new_cluster_template_dict = new_cluster_template.as_dict()
        attr_validator.validate_os_resources(context,
                                             new_cluster_template_dict)
        # check permissions when updating ClusterTemplate public or hidden flag
        if (cluster_template.public != new_cluster_template.public or
                cluster_template.hidden != new_cluster_template.hidden):
            if not policy.enforce(context, "clustertemplate:publish", None,
                                  do_raise=False):
                raise exception.ClusterTemplatePublishDenied()

        # Update only the fields that have changed
        for field in objects.ClusterTemplate.fields:
            try:
                patch_val = getattr(new_cluster_template, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if cluster_template[field] != patch_val:
                cluster_template[field] = patch_val

        if (cluster_template.docker_storage_driver in ('devicemapper',
                                                       'overlay')):
            warnings.warn(self._devicemapper_overlay_deprecation_note,
                          DeprecationWarning)
            LOG.warning(self._devicemapper_overlay_deprecation_note)

        cluster_template.save()
        return ClusterTemplate.convert_with_links(cluster_template)
def patch ( self , cluster_template_ident , patch ) : # noqa context = pecan . request . context if context . is_admin : policy . enforce ( context , 'clustertemplate:update_all_projects' , action = 'clustertemplate:update_all_projects' ) context . all_tenants = True cluster_template = api_utils . get_resource ( 'ClusterTemplate' , cluster_template_ident ) policy . enforce ( context , 'clustertemplate:update' , cluster_template . as_dict ( ) , action = 'clustertemplate:update' ) try : cluster_template_dict = cluster_template . as_dict ( ) new_cluster_template = ClusterTemplate ( * * api_utils . apply_jsonpatch ( cluster_template_dict , patch ) ) except api_utils . JSONPATCH_EXCEPTIONS as e : raise exception . PatchError ( patch = patch , reason = e ) new_cluster_template_dict = new_cluster_template . as_dict ( ) attr_validator . validate_os_resources ( context , new_cluster_template_dict ) # check permissions when updating ClusterTemplate public or hidden flag if ( cluster_template . public != new_cluster_template . public or cluster_template . hidden != new_cluster_template . hidden ) : if not policy . enforce ( context , "clustertemplate:publish" , None , do_raise = False ) : raise exception . ClusterTemplatePublishDenied ( ) # Update only the fields that have changed for field in objects . ClusterTemplate . fields : try : patch_val = getattr ( new_cluster_template , field ) except AttributeError : # Ignore fields that aren't exposed in the API continue if patch_val == wtypes . Unset : patch_val = None if cluster_template [ field ] != patch_val : cluster_template [ field ] = patch_val if ( cluster_template . docker_storage_driver in ( 'devicemapper' , 'overlay' ) ) : warnings . warn ( self . _devicemapper_overlay_deprecation_note , DeprecationWarning ) LOG . warning ( self . _devicemapper_overlay_deprecation_note ) cluster_template . save ( ) return ClusterTemplate . convert_with_links ( cluster_template )