Intial version of cluster_update API support

In this implementation, we don't allow the update to the size property
because it may cause confusion in the background engine. Instead, size
should be updated using the scale-out or scale-in operations.

We also allow updates to tags, timeout, name, and parent fields of a
cluster, in addition to the 'profile_id' field. The update to cluster
properties may be type checked (e.g. timeout should be an integer).

If the profile_id is included in the update request, it may invoke a
series of CLUSTER(NODE)_UPDATE actions in the engine. We will do some
preliminary checkings in the engine side before initiating such a series
of actions.
This commit is contained in:
tengqm 2015-03-03 16:27:45 +08:00
parent 306112996e
commit b260ccee05

View File

@ -157,13 +157,22 @@ class ClusterController(object):
raise exc.HTTPBadRequest(_("Malformed request data, missing "
"'cluster' key in request body."))
if consts.CLUSTER_PROFILE not in cluster_data:
raise exc.HTTPBadRequest(_("No cluster profile provided."))
profile = cluster_data[consts.CLUSTER_PROFILE]
size = cluster_data.get(consts.CLUSTER_SIZE)
if size is not None:
msg = _("Updating cluster size is not supported, please use "
"cluster scaling operations instead.")
raise exc.HTTPBadRequest(msg)
self.rpc_client.cluster_update(req.context,
cluster_id,
profile)
name = cluster_data.get(consts.CLUSTER_NAME)
profile_id = cluster_data.get(consts.CLUSTER_PROFILE)
parent = cluster_data.get(consts.CLUSTER_PARENT)
tags = cluster_data.get(consts.CLUSTER_TAGS)
timeout = cluster_data.get(consts.CLUSTER_TIMEOUT)
if timeout is not None:
timeout = utils.parse_int_param(consts.CLUSTER_TIMEOUT, timeout)
self.rpc_client.cluster_update(req.context, cluster_id, name,
profile_id, parent, tags, timeout)
raise exc.HTTPAccepted()