summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Piwowarczyk <m.piwowarczy@samsung.com>2018-07-02 08:58:06 +0200
committerMarcin Piwowarczyk <m.piwowarczy@samsung.com>2018-08-07 08:25:39 +0200
commit9e737a2cf8cee4be79f0c8a0efd14ef4d3dbdad0 (patch)
tree098a09f958498f0f89f341e2b02730f219ab29c5
parent451d422e9eb8f59c8e069571f102e36fb8047f76 (diff)
downloadpython-troveclient-9e737a2cf8cee4be79f0c8a0efd14ef4d3dbdad0.tar.gz
Support configuration groups for clusters
Handles API part implemented in change: I7c0a22c6a0287128d0c37e100589c78173fd9c1a So far passing configuration group was possible only for single instance deployment. As the trove api now already supports configuration attach and detach for clusters, we are able to handle it in client. Configuration will be applied to each cluster instance. Partially implements: blueprint cluster-configuration-groups Change-Id: Ic0840c995cbc34203c76494d7ba522f3e17141a7 Signed-off-by: Marcin Piwowarczyk <m.piwowarczy@samsung.com>
-rw-r--r--releasenotes/notes/add-configuration-groups-for-clusters-6183b0b7b4fb8c9e.yaml6
-rw-r--r--troveclient/tests/test_clusters.py5
-rw-r--r--troveclient/tests/test_v1_shell.py22
-rw-r--r--troveclient/v1/clusters.py4
-rw-r--r--troveclient/v1/shell.py8
5 files changed, 42 insertions, 3 deletions
diff --git a/releasenotes/notes/add-configuration-groups-for-clusters-6183b0b7b4fb8c9e.yaml b/releasenotes/notes/add-configuration-groups-for-clusters-6183b0b7b4fb8c9e.yaml
new file mode 100644
index 0000000..0c559b3
--- /dev/null
+++ b/releasenotes/notes/add-configuration-groups-for-clusters-6183b0b7b4fb8c9e.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - |
+ A --configuration flag was added to the ``trove cluster-create``
+ command, in order to allow a user to attach specific configuration
+ for cluster.
diff --git a/troveclient/tests/test_clusters.py b/troveclient/tests/test_clusters.py
index 64e243e..2545083 100644
--- a/troveclient/tests/test_clusters.py
+++ b/troveclient/tests/test_clusters.py
@@ -79,10 +79,12 @@ class ClustersTest(testtools.TestCase):
'configsvr_volume_type': 'foo_type',
'mongos_volume_size': 12,
'mongos_volume_type': 'bar_type'}
+ configuration = 'test-config'
path, body, resp_key = clusters_test.create("test-name", "datastore",
"datastore-version",
instances, locality,
- extended_properties)
+ extended_properties,
+ configuration)
self.assertEqual("/clusters", path)
self.assertEqual("cluster", resp_key)
self.assertEqual("test-name", body["cluster"]["name"])
@@ -93,6 +95,7 @@ class ClustersTest(testtools.TestCase):
self.assertEqual(locality, body["cluster"]["locality"])
self.assertEqual(extended_properties,
body["cluster"]["extended_properties"])
+ self.assertEqual(configuration, body["cluster"]["configuration"])
def test_list(self):
page_mock = mock.Mock()
diff --git a/troveclient/tests/test_v1_shell.py b/troveclient/tests/test_v1_shell.py
index 03cb725..eb18e48 100644
--- a/troveclient/tests/test_v1_shell.py
+++ b/troveclient/tests/test_v1_shell.py
@@ -516,6 +516,28 @@ class ShellTest(utils.TestCase):
'name': 'test-clstr2',
'locality': 'affinity'}})
+ def test_cluster_create_with_configuration(self):
+ cmd = ('cluster-create test-clstr2 redis 3.0 '
+ '--configuration=config01 '
+ '--instance flavor=2,volume=1 '
+ '--instance flavor=02,volume=1 '
+ '--instance flavor=2,volume=1 ')
+ self.run_command(cmd)
+ self.assert_called_anytime(
+ 'POST', '/clusters',
+ {'cluster': {
+ 'instances': [
+ {'flavorRef': '2',
+ 'volume': {'size': '1'}},
+ {'flavorRef': '02',
+ 'volume': {'size': '1'}},
+ {'flavorRef': '2',
+ 'volume': {'size': '1'}},
+ ],
+ 'datastore': {'version': '3.0', 'type': 'redis'},
+ 'name': 'test-clstr2',
+ 'configuration': 'config01'}})
+
def test_cluster_create_with_extended_properties(self):
cmd = ('cluster-create test-clstr3 mongodb 4.0 '
'--instance flavor=2,volume=1 '
diff --git a/troveclient/v1/clusters.py b/troveclient/v1/clusters.py
index ae0380e..caa9d32 100644
--- a/troveclient/v1/clusters.py
+++ b/troveclient/v1/clusters.py
@@ -37,7 +37,7 @@ class Clusters(base.ManagerWithFind):
resource_class = Cluster
def create(self, name, datastore, datastore_version, instances=None,
- locality=None, extended_properties=None):
+ locality=None, extended_properties=None, configuration=None):
"""Create (boot) a new cluster."""
body = {"cluster": {
"name": name
@@ -53,6 +53,8 @@ class Clusters(base.ManagerWithFind):
body["cluster"]["locality"] = locality
if extended_properties:
body["cluster"]["extended_properties"] = extended_properties
+ if configuration:
+ body["cluster"]["configuration"] = configuration
return self._create("/clusters", body, "cluster")
diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py
index d5cc927..aef2529 100644
--- a/troveclient/v1/shell.py
+++ b/troveclient/v1/shell.py
@@ -894,6 +894,11 @@ def _parse_instance_options(cs, instance_options, for_grow=False):
metavar=EXT_PROPS_METAVAR,
default=None,
help=EXT_PROPS_HELP)
+@utils.arg('--configuration',
+ metavar='<configuration>',
+ type=str,
+ default=None,
+ help=_('ID of the configuration group to attach to the cluster.'))
@utils.service_type('database')
def do_cluster_create(cs, args):
"""Creates a new cluster."""
@@ -908,7 +913,8 @@ def do_cluster_create(cs, args):
args.datastore_version,
instances=instances,
locality=args.locality,
- extended_properties=extended_properties)
+ extended_properties=extended_properties,
+ configuration=args.configuration)
_print_cluster(cluster)