Merge "Support configuration groups for clusters"
This commit is contained in:
@@ -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.
|
||||||
@@ -79,10 +79,12 @@ class ClustersTest(testtools.TestCase):
|
|||||||
'configsvr_volume_type': 'foo_type',
|
'configsvr_volume_type': 'foo_type',
|
||||||
'mongos_volume_size': 12,
|
'mongos_volume_size': 12,
|
||||||
'mongos_volume_type': 'bar_type'}
|
'mongos_volume_type': 'bar_type'}
|
||||||
|
configuration = 'test-config'
|
||||||
path, body, resp_key = clusters_test.create("test-name", "datastore",
|
path, body, resp_key = clusters_test.create("test-name", "datastore",
|
||||||
"datastore-version",
|
"datastore-version",
|
||||||
instances, locality,
|
instances, locality,
|
||||||
extended_properties)
|
extended_properties,
|
||||||
|
configuration)
|
||||||
self.assertEqual("/clusters", path)
|
self.assertEqual("/clusters", path)
|
||||||
self.assertEqual("cluster", resp_key)
|
self.assertEqual("cluster", resp_key)
|
||||||
self.assertEqual("test-name", body["cluster"]["name"])
|
self.assertEqual("test-name", body["cluster"]["name"])
|
||||||
@@ -93,6 +95,7 @@ class ClustersTest(testtools.TestCase):
|
|||||||
self.assertEqual(locality, body["cluster"]["locality"])
|
self.assertEqual(locality, body["cluster"]["locality"])
|
||||||
self.assertEqual(extended_properties,
|
self.assertEqual(extended_properties,
|
||||||
body["cluster"]["extended_properties"])
|
body["cluster"]["extended_properties"])
|
||||||
|
self.assertEqual(configuration, body["cluster"]["configuration"])
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
page_mock = mock.Mock()
|
page_mock = mock.Mock()
|
||||||
|
|||||||
@@ -516,6 +516,28 @@ class ShellTest(utils.TestCase):
|
|||||||
'name': 'test-clstr2',
|
'name': 'test-clstr2',
|
||||||
'locality': 'affinity'}})
|
'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):
|
def test_cluster_create_with_extended_properties(self):
|
||||||
cmd = ('cluster-create test-clstr3 mongodb 4.0 '
|
cmd = ('cluster-create test-clstr3 mongodb 4.0 '
|
||||||
'--instance flavor=2,volume=1 '
|
'--instance flavor=2,volume=1 '
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Clusters(base.ManagerWithFind):
|
|||||||
resource_class = Cluster
|
resource_class = Cluster
|
||||||
|
|
||||||
def create(self, name, datastore, datastore_version, instances=None,
|
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."""
|
"""Create (boot) a new cluster."""
|
||||||
body = {"cluster": {
|
body = {"cluster": {
|
||||||
"name": name
|
"name": name
|
||||||
@@ -53,6 +53,8 @@ class Clusters(base.ManagerWithFind):
|
|||||||
body["cluster"]["locality"] = locality
|
body["cluster"]["locality"] = locality
|
||||||
if extended_properties:
|
if extended_properties:
|
||||||
body["cluster"]["extended_properties"] = extended_properties
|
body["cluster"]["extended_properties"] = extended_properties
|
||||||
|
if configuration:
|
||||||
|
body["cluster"]["configuration"] = configuration
|
||||||
|
|
||||||
return self._create("/clusters", body, "cluster")
|
return self._create("/clusters", body, "cluster")
|
||||||
|
|
||||||
|
|||||||
@@ -894,6 +894,11 @@ def _parse_instance_options(cs, instance_options, for_grow=False):
|
|||||||
metavar=EXT_PROPS_METAVAR,
|
metavar=EXT_PROPS_METAVAR,
|
||||||
default=None,
|
default=None,
|
||||||
help=EXT_PROPS_HELP)
|
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')
|
@utils.service_type('database')
|
||||||
def do_cluster_create(cs, args):
|
def do_cluster_create(cs, args):
|
||||||
"""Creates a new cluster."""
|
"""Creates a new cluster."""
|
||||||
@@ -908,7 +913,8 @@ def do_cluster_create(cs, args):
|
|||||||
args.datastore_version,
|
args.datastore_version,
|
||||||
instances=instances,
|
instances=instances,
|
||||||
locality=args.locality,
|
locality=args.locality,
|
||||||
extended_properties=extended_properties)
|
extended_properties=extended_properties,
|
||||||
|
configuration=args.configuration)
|
||||||
_print_cluster(cluster)
|
_print_cluster(cluster)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user