From b260ccee050d098033d98ac0536a2d72d94db995 Mon Sep 17 00:00:00 2001 From: tengqm Date: Tue, 3 Mar 2015 16:27:45 +0800 Subject: [PATCH] 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. --- senlin/api/openstack/v1/clusters.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/senlin/api/openstack/v1/clusters.py b/senlin/api/openstack/v1/clusters.py index c7728475d..5d0cb8e22 100644 --- a/senlin/api/openstack/v1/clusters.py +++ b/senlin/api/openstack/v1/clusters.py @@ -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()