summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-05-27 11:28:00 +0000
committerGerrit Code Review <review@openstack.org>2014-05-27 11:28:01 +0000
commit21646a49dcf38a2a039fbe287d1ae6069ce8977e (patch)
tree983c72574bd671a0145957ff4cc1fe5c8e183fd0
parent89859556cfb1d1067879a044506c168a6dbbc0ea (diff)
parent84de6ee1a0eff940aa770bcbf0c802424da21e85 (diff)
downloadpython-troveclient-21646a49dcf38a2a039fbe287d1ae6069ce8977e.tar.gz
Merge "Allow users the ability to update the instance name"
-rw-r--r--troveclient/tests/test_instances.py11
-rw-r--r--troveclient/v1/instances.py14
-rw-r--r--troveclient/v1/shell.py20
3 files changed, 45 insertions, 0 deletions
diff --git a/troveclient/tests/test_instances.py b/troveclient/tests/test_instances.py
index cdd29e4..9c5a44f 100644
--- a/troveclient/tests/test_instances.py
+++ b/troveclient/tests/test_instances.py
@@ -177,6 +177,17 @@ class InstancesTest(testtools.TestCase):
resp.status_code = 500
self.assertRaises(Exception, self.instances.modify, 'instance1')
+ def test_edit(self):
+ resp = mock.Mock()
+ resp.status_code = 204
+ body = None
+ self.instances.api.client.patch = mock.Mock(return_value=(resp, body))
+ self.instances.edit(123)
+ self.instances.edit(123, 321)
+ self.instances.edit(123, 321, 'name-1234')
+ resp.status_code = 500
+ self.assertRaises(Exception, self.instances.edit, 'instance1')
+
def test_configuration(self):
def side_effect_func(path, inst):
return path, inst
diff --git a/troveclient/v1/instances.py b/troveclient/v1/instances.py
index 2bf922e..ea0fae5 100644
--- a/troveclient/v1/instances.py
+++ b/troveclient/v1/instances.py
@@ -86,6 +86,20 @@ class Instances(base.ManagerWithFind):
resp, body = self.api.client.put(url, body=body)
common.check_for_exceptions(resp, body, url)
+ def edit(self, instance_id, configuration=None, name=None):
+ body = {
+ "instance": {
+ }
+ }
+ if configuration is not None:
+ body["instance"]["configuration"] = configuration
+ if name is not None:
+ body["instance"]["name"] = name
+
+ url = "/instances/%s" % instance_id
+ resp, body = self.api.client.patch(url, body=body)
+ common.check_for_exceptions(resp, body, url)
+
def list(self, limit=None, marker=None):
"""Get a list of all instances.
diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py
index 6c1b69d..5d23006 100644
--- a/troveclient/v1/shell.py
+++ b/troveclient/v1/shell.py
@@ -148,6 +148,26 @@ def do_delete(cs, args):
cs.instances.delete(args.instance)
+@utils.arg('instance',
+ metavar='<instance>',
+ type=str,
+ help='UUID of the instance.')
+@utils.arg('--name',
+ metavar='<name>',
+ type=str,
+ default=None,
+ help='Name of the instance.')
+@utils.arg('--configuration',
+ metavar='<configuration>',
+ type=str,
+ default=None,
+ help='ID of the configuration reference to attach.')
+@utils.service_type('database')
+def do_update(cs, args):
+ """Updates an instance name or configuration."""
+ cs.instances.edit(args.instance, args.configuration, args.name)
+
+
@utils.arg('name',
metavar='<name>',
type=str,