Merge "Limit cluster update properties"

This commit is contained in:
Zuul 2018-10-02 04:35:19 +00:00 committed by Gerrit Code Review
commit df257446ee
1 changed files with 6 additions and 0 deletions

View File

@ -35,6 +35,7 @@ CLUSTER_TEMPLATE_CREATE_ATTRS = cluster_templates.CREATION_ATTRIBUTES
CLUSTER_CREATE_ATTRS = clusters.CREATION_ATTRIBUTES
CERTIFICATE_CREATE_ATTRS = certificates.CREATION_ATTRIBUTES
QUOTA_CREATION_ATTRIBUTES = quotas.CREATION_ATTRIBUTES
CLUSTER_UPDATE_ALLOWED_PROPERTIES = set(['/node_count'])
def _cleanup_params(attrs, create, **params):
@ -138,6 +139,11 @@ def cluster_template_update(request, id, **kwargs):
old = magnumclient(request).cluster_templates.get(id).to_dict()
old = _cleanup_params(CLUSTER_TEMPLATE_CREATE_ATTRS, False, **old)
patch = _create_patches(old, new)
# NOTE(flwang): Now Magnum only support updating the node count for
# cluster upddate action. So let's simplify it by only passing the
# /node_count dict which can avoid many potential bugs.
patch = [d for d in patch if d['path']
in CLUSTER_UPDATE_ALLOWED_PROPERTIES]
return magnumclient(request).cluster_templates.update(id, patch)