summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-10 15:55:42 +0000
committerGerrit Code Review <review@openstack.org>2016-12-10 15:55:42 +0000
commit20eb0a4bd180d3137c7986cfb8065412746eed80 (patch)
treef4797807aab2369e438f25635a9c85a5b32fd963
parent156b36e8523525dac177b0a9bcee4aa60049d086 (diff)
parent9d3098ebaf4718838edc714f2c1d3b02a992c398 (diff)
Merge "Cluster Upgrade"2.7.0
-rw-r--r--releasenotes/notes/cluster-upgrade-d58d1fc4b8da0a03.yaml3
-rw-r--r--troveclient/tests/test_clusters.py10
-rw-r--r--troveclient/tests/test_v1_shell.py5
-rw-r--r--troveclient/v1/clusters.py9
-rw-r--r--troveclient/v1/shell.py12
5 files changed, 39 insertions, 0 deletions
diff --git a/releasenotes/notes/cluster-upgrade-d58d1fc4b8da0a03.yaml b/releasenotes/notes/cluster-upgrade-d58d1fc4b8da0a03.yaml
new file mode 100644
index 0000000..9d672cd
--- /dev/null
+++ b/releasenotes/notes/cluster-upgrade-d58d1fc4b8da0a03.yaml
@@ -0,0 +1,3 @@
1features:
2 - Added cluster-upgrade command to upgrade all instances
3 in a cluster to a new datastore version.
diff --git a/troveclient/tests/test_clusters.py b/troveclient/tests/test_clusters.py
index 0ccda05..710b3c1 100644
--- a/troveclient/tests/test_clusters.py
+++ b/troveclient/tests/test_clusters.py
@@ -102,6 +102,16 @@ class ClustersTest(testtools.TestCase):
102 self.assertEqual(('/clusters/cluster1', 'cluster'), 102 self.assertEqual(('/clusters/cluster1', 'cluster'),
103 clusters_test.get(1)) 103 clusters_test.get(1))
104 104
105 def test_upgrade(self):
106 resp = mock.Mock()
107 resp.status_code = 200
108 body = None
109 clusters_test = self.get_clusters()
110 clusters_test.api.client.post = mock.Mock(return_value=(resp, body))
111 clusters_test.upgrade('cluster1', '5.6')
112 resp.status_code = 500
113 self.assertRaises(Exception, clusters_test.upgrade, 'cluster1', '5.6')
114
105 def test_delete(self): 115 def test_delete(self):
106 resp = mock.Mock() 116 resp = mock.Mock()
107 resp.status_code = 200 117 resp.status_code = 200
diff --git a/troveclient/tests/test_v1_shell.py b/troveclient/tests/test_v1_shell.py
index 58c9d4c..0e55947 100644
--- a/troveclient/tests/test_v1_shell.py
+++ b/troveclient/tests/test_v1_shell.py
@@ -474,6 +474,11 @@ class ShellTest(utils.TestCase):
474 self.run_command(cmd) 474 self.run_command(cmd)
475 self.assert_called('POST', '/clusters/cls-1234') 475 self.assert_called('POST', '/clusters/cls-1234')
476 476
477 def test_cluster_upgrade(self):
478 cmd = ('cluster-upgrade cls-1234 1234')
479 self.run_command(cmd)
480 self.assert_called('POST', '/clusters/cls-1234')
481
477 def test_cluster_create_with_locality(self): 482 def test_cluster_create_with_locality(self):
478 cmd = ('cluster-create test-clstr2 redis 3.0 --locality=affinity ' 483 cmd = ('cluster-create test-clstr2 redis 3.0 --locality=affinity '
479 '--instance flavor=2,volume=1 ' 484 '--instance flavor=2,volume=1 '
diff --git a/troveclient/v1/clusters.py b/troveclient/v1/clusters.py
index 451bfe8..b7e5ddd 100644
--- a/troveclient/v1/clusters.py
+++ b/troveclient/v1/clusters.py
@@ -126,6 +126,15 @@ class Clusters(base.ManagerWithFind):
126 body = {"shrink": instances} 126 body = {"shrink": instances}
127 return self._action(cluster, body) 127 return self._action(cluster, body)
128 128
129 def upgrade(self, cluster, datastore_version):
130 """Upgrades a cluster to a new datastore version.
131
132 :param cluster: The cluster to upgrade
133 :param datastore_version: Datastore version to which to upgrade
134 """
135 body = {"upgrade": {'datastore_version': datastore_version}}
136 return self._action(cluster, body)
137
129 138
130class ClusterStatus(object): 139class ClusterStatus(object):
131 140
diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py
index 86eae0e..a0058f6 100644
--- a/troveclient/v1/shell.py
+++ b/troveclient/v1/shell.py
@@ -414,6 +414,18 @@ def do_cluster_reset_status(cs, args):
414 cs.clusters.reset_status(cluster) 414 cs.clusters.reset_status(cluster)
415 415
416 416
417@utils.arg('cluster', metavar='<cluster>',
418 help=_('ID or name of the cluster.'))
419@utils.arg('datastore_version',
420 metavar='<datastore_version>',
421 help=_('A datastore version name or ID.'))
422@utils.service_type('database')
423def do_cluster_upgrade(cs, args):
424 """Upgrades a cluster to a new datastore version."""
425 cluster = _find_cluster(cs, args.cluster)
426 cs.clusters.upgrade(cluster, args.datastore_version)
427
428
417@utils.arg('instance', 429@utils.arg('instance',
418 metavar='<instance>', 430 metavar='<instance>',
419 type=str, 431 type=str,