From 53065fd8242aadcf4963376cfd8c55a91341e19e Mon Sep 17 00:00:00 2001 From: Chad Roberts Date: Tue, 3 Nov 2015 15:24:55 -0500 Subject: [PATCH] Allowing shares to be edited on cluster update In order to allow the shares to be updated on a running cluster, the cluster update operation has been updated to allow the shares element. Change-Id: I33971eb495c5a318ba17a4b3f98534b9e8776deb Partial-Implements: bp sahara-add-shares-to-clusters --- sahara/service/validations/clusters_schema.py | 4 +++- .../unit/conductor/manager/test_clusters.py | 23 +++++++++++++++++++ .../test_cluster_update_validation.py | 6 +++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/sahara/service/validations/clusters_schema.py b/sahara/service/validations/clusters_schema.py index 46b333d3..fb0bffb4 100644 --- a/sahara/service/validations/clusters_schema.py +++ b/sahara/service/validations/clusters_schema.py @@ -16,6 +16,7 @@ import copy import sahara.service.validations.cluster_template_schema as ct_schema +from sahara.service.validations import shares def _build_node_groups_schema(): @@ -66,7 +67,8 @@ CLUSTER_UPDATE_SCHEMA = { }, "is_protected": { "type": ["boolean", "null"], - } + }, + "shares": copy.deepcopy(shares.SHARE_SCHEMA), }, "additionalProperties": False, "required": [] diff --git a/sahara/tests/unit/conductor/manager/test_clusters.py b/sahara/tests/unit/conductor/manager/test_clusters.py index 52ce06ae..5e685a5f 100644 --- a/sahara/tests/unit/conductor/manager/test_clusters.py +++ b/sahara/tests/unit/conductor/manager/test_clusters.py @@ -368,3 +368,26 @@ class ClusterTest(test_base.ConductorManagerTestCase): self.assertRaises(sa_exc.InvalidRequestError, self.api.cluster_get_all, ctx, **{'badfield': 'somevalue'}) + + def test_cluster_update_shares(self): + ctx = context.ctx() + cluster_db_obj = self.api.cluster_create(ctx, SAMPLE_CLUSTER) + _id = cluster_db_obj["id"] + + test_shares = [ + { + "id": "bd71d2d5-60a0-4ed9-a3d2-ad312c368880", + "path": "/mnt/manila", + "access_level": "rw" + } + ] + + updated_cl = self.api.cluster_update(ctx, _id, {"shares": test_shares}) + self.assertIsInstance(updated_cl, dict) + self.assertEqual(test_shares, updated_cl["shares"]) + + get_cl_obj = self.api.cluster_get(ctx, _id) + self.assertEqual(updated_cl, get_cl_obj) + + with testtools.ExpectedException(ex.NotFoundException): + self.api.cluster_update(ctx, "bad_id", {"shares": test_shares}) diff --git a/sahara/tests/unit/service/validation/test_cluster_update_validation.py b/sahara/tests/unit/service/validation/test_cluster_update_validation.py index 8f04107b..2ebfeb91 100644 --- a/sahara/tests/unit/service/validation/test_cluster_update_validation.py +++ b/sahara/tests/unit/service/validation/test_cluster_update_validation.py @@ -37,7 +37,8 @@ class TestClusterUpdateValidation(u.ValidationTestCase): 'name': 'cluster', 'description': 'very big cluster', 'is_public': False, - 'is_protected': False + 'is_protected': False, + 'shares': [] }) def test_cluster_update_nothing_required(self): @@ -51,7 +52,8 @@ class TestClusterUpdateValidation(u.ValidationTestCase): 'name': 'cluster', 'description': 'very big cluster', 'is_public': False, - 'is_protected': False + 'is_protected': False, + 'shares': [] } )