From b928ec680a26fc97cac67fdec9deeb5be3e0bc4c Mon Sep 17 00:00:00 2001 From: Peter Stachowski Date: Fri, 6 May 2016 01:37:42 -0400 Subject: [PATCH] Add support for modules in cluster create/grow When the module support was added, passing the modules to the actual create was not done on the server side. This has been added. Partial Bug: #1578917 Change-Id: I80c8e230f8bff550851f5cad146aa5976f45e5c4 --- ...-support-for-clusters-87b41dd7648275bf.yaml | 6 ++++++ trove/cluster/models.py | 2 ++ trove/cluster/service.py | 6 +++++- trove/common/apischema.py | 1 + .../cluster/experimental/cassandra/api.py | 3 ++- .../cluster/experimental/galera_common/api.py | 3 ++- .../cluster/experimental/mongodb/api.py | 3 ++- .../cluster/experimental/redis/api.py | 3 ++- .../cluster/experimental/vertica/api.py | 18 +++++++----------- .../cluster/test_cluster_controller.py | 1 + .../cluster/test_cluster_pxc_controller.py | 1 + .../cluster/test_cluster_redis_controller.py | 3 +++ .../cluster/test_cluster_vertica_controller.py | 1 + 13 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 releasenotes/notes/module-support-for-clusters-87b41dd7648275bf.yaml diff --git a/releasenotes/notes/module-support-for-clusters-87b41dd7648275bf.yaml b/releasenotes/notes/module-support-for-clusters-87b41dd7648275bf.yaml new file mode 100644 index 0000000000..632a4a1fca --- /dev/null +++ b/releasenotes/notes/module-support-for-clusters-87b41dd7648275bf.yaml @@ -0,0 +1,6 @@ +--- +features: + - Support was added for applying modules to + cluster instances through cluster-create + and cluster-grow. Bug 1578917 + diff --git a/trove/cluster/models.py b/trove/cluster/models.py index 88fbf8d5b2..1d2b52dc97 100644 --- a/trove/cluster/models.py +++ b/trove/cluster/models.py @@ -278,6 +278,8 @@ class Cluster(object): instance['name'] = node['name'] if 'volume' in node: instance['volume_size'] = int(node['volume']['size']) + if 'modules' in node: + instance['modules'] = node['modules'] instances.append(instance) return self.grow(instances) elif action == 'shrink': diff --git a/trove/cluster/service.py b/trove/cluster/service.py index 0cb7afc010..8c167d61ad 100644 --- a/trove/cluster/service.py +++ b/trove/cluster/service.py @@ -158,6 +158,7 @@ class ClusterController(wsgi.Controller): for node in nodes: flavor_id = utils.get_id_from_href(node['flavorRef']) volume_size = volume_type = nics = availability_zone = None + modules = None if 'volume' in node: volume_size = int(node['volume']['size']) volume_type = node['volume'].get('volume_type') @@ -165,12 +166,15 @@ class ClusterController(wsgi.Controller): nics = node['nics'] if 'availability_zone' in node: availability_zone = node['availability_zone'] + if 'modules' in node: + modules = node['modules'] instances.append({"flavor_id": flavor_id, "volume_size": volume_size, "volume_type": volume_type, "nics": nics, - "availability_zone": availability_zone}) + "availability_zone": availability_zone, + "modules": modules}) locality = body['cluster'].get('locality') if locality: diff --git a/trove/common/apischema.py b/trove/common/apischema.py index 5752c0ae10..2afd80635d 100644 --- a/trove/common/apischema.py +++ b/trove/common/apischema.py @@ -288,6 +288,7 @@ cluster = { "volume": volume, "nics": nics, "availability_zone": non_empty_string, + "modules": module_list, "related_to": non_empty_string, "type": non_empty_string } diff --git a/trove/common/strategies/cluster/experimental/cassandra/api.py b/trove/common/strategies/cluster/experimental/cassandra/api.py index b9b910905a..25b8fabc1b 100644 --- a/trove/common/strategies/cluster/experimental/cassandra/api.py +++ b/trove/common/strategies/cluster/experimental/cassandra/api.py @@ -155,7 +155,8 @@ class CassandraCluster(models.Cluster): availability_zone=instance_az, configuration_id=None, cluster_config=member_config, - locality=locality) + locality=locality, + modules=instance.get('modules')) new_instances.append(new_instance) diff --git a/trove/common/strategies/cluster/experimental/galera_common/api.py b/trove/common/strategies/cluster/experimental/galera_common/api.py index 50f8281782..007627770f 100644 --- a/trove/common/strategies/cluster/experimental/galera_common/api.py +++ b/trove/common/strategies/cluster/experimental/galera_common/api.py @@ -139,7 +139,8 @@ class GaleraCommonCluster(cluster_models.Cluster): nics=instance.get('nics', None), configuration_id=None, cluster_config=member_config, - locality=locality + locality=locality, + modules=instance.get('modules') ) for instance in instances] diff --git a/trove/common/strategies/cluster/experimental/mongodb/api.py b/trove/common/strategies/cluster/experimental/mongodb/api.py index 9bf6d67131..c9969bc632 100644 --- a/trove/common/strategies/cluster/experimental/mongodb/api.py +++ b/trove/common/strategies/cluster/experimental/mongodb/api.py @@ -146,7 +146,8 @@ class MongoDbCluster(models.Cluster): nics=nics[i], configuration_id=None, cluster_config=member_config, - locality=locality) + locality=locality, + modules=instances[i].get('modules')) for i in range(1, num_configsvr + 1): instance_name = "%s-%s-%s" % (name, "configsvr", str(i)) diff --git a/trove/common/strategies/cluster/experimental/redis/api.py b/trove/common/strategies/cluster/experimental/redis/api.py index d9c729354b..47865c2606 100644 --- a/trove/common/strategies/cluster/experimental/redis/api.py +++ b/trove/common/strategies/cluster/experimental/redis/api.py @@ -105,7 +105,8 @@ class RedisCluster(models.Cluster): cluster_config={ "id": db_info.id, "instance_type": "member"}, - locality=locality + locality=locality, + modules=instance.get('modules') ) for instance in instances] diff --git a/trove/common/strategies/cluster/experimental/vertica/api.py b/trove/common/strategies/cluster/experimental/vertica/api.py index c3762a312f..67fe1fe11e 100644 --- a/trove/common/strategies/cluster/experimental/vertica/api.py +++ b/trove/common/strategies/cluster/experimental/vertica/api.py @@ -133,17 +133,13 @@ class VerticaCluster(models.Cluster): instance_name = "%s-member-%s" % (db_info.name, str(i + num_existing + 1)) minstances.append( - inst_models.Instance.create(context, instance_name, - flavor_id, - datastore_version.image_id, - [], [], datastore, - datastore_version, - volume_size, None, - nics=nics[i], - availability_zone=azs[i], - configuration_id=None, - cluster_config=member_config, - locality=locality) + inst_models.Instance.create( + context, instance_name, flavor_id, + datastore_version.image_id, [], [], datastore, + datastore_version, volume_size, None, + nics=nics[i], availability_zone=azs[i], + configuration_id=None, cluster_config=member_config, + locality=locality, modules=instances[i].get('modules')) ) return minstances diff --git a/trove/tests/unittests/cluster/test_cluster_controller.py b/trove/tests/unittests/cluster/test_cluster_controller.py index f76eba396d..192d5f97f7 100644 --- a/trove/tests/unittests/cluster/test_cluster_controller.py +++ b/trove/tests/unittests/cluster/test_cluster_controller.py @@ -176,6 +176,7 @@ class TestClusterController(TestCase): 'volume_type': None, 'flavor_id': '1234', 'availability_zone': 'az', + 'modules': None, 'nics': [ {'net-id': 'e89aa5fd-6b0a-436d-a75c-1545d34d5331'} ] diff --git a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py index b95993752f..e19eff46c9 100644 --- a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py +++ b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py @@ -141,6 +141,7 @@ class TestClusterController(trove_testtools.TestCase): 'volume_type': None, 'flavor_id': '1234', 'availability_zone': 'az', + 'modules': None, 'nics': [ {'net-id': 'e89aa5fd-6b0a-436d-a75c-1545d34d5331'} ] diff --git a/trove/tests/unittests/cluster/test_cluster_redis_controller.py b/trove/tests/unittests/cluster/test_cluster_redis_controller.py index 1732be0342..283159e88f 100644 --- a/trove/tests/unittests/cluster/test_cluster_redis_controller.py +++ b/trove/tests/unittests/cluster/test_cluster_redis_controller.py @@ -156,6 +156,7 @@ class TestClusterController(trove_testtools.TestCase): 'volume_type': None, "flavor_id": "1234", "availability_zone": "az", + 'modules': None, "nics": [ {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"} ] @@ -165,6 +166,7 @@ class TestClusterController(trove_testtools.TestCase): 'volume_type': None, "flavor_id": "1234", "availability_zone": "az", + 'modules': None, "nics": [ {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"} ] @@ -174,6 +176,7 @@ class TestClusterController(trove_testtools.TestCase): 'volume_type': None, "flavor_id": "1234", "availability_zone": "az", + 'modules': None, "nics": [ {"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"} ] diff --git a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py index bbfc729f8a..c9251a8514 100644 --- a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py +++ b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py @@ -141,6 +141,7 @@ class TestClusterController(trove_testtools.TestCase): 'volume_type': None, 'flavor_id': '1234', 'availability_zone': 'az', + 'modules': None, 'nics': [ {'net-id': 'e89aa5fd-6b0a-436d-a75c-1545d34d5331'} ]