Implement Instance Upgrade

This change includes a new "trove upgrade" CLI command and
a new "Instances.upgrade" python API method to implement
the new Instance Upgrade feature.

Change-Id: I6ec2ebb78019c014f87ba5d8cbfd284686c64f30
Implements: blueprint image-upgrade
This commit is contained in:
Morgan Jones
2016-06-06 13:38:24 -04:00
committed by Doug Shelley
parent b18d4ebf46
commit 4f3ab58687
5 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
features:
- Add a new trove upgrade CLI command and a new
Instances.upgrade python API method to implement
the new Instance Upgrade feature.

View File

@@ -238,6 +238,16 @@ class InstancesTest(testtools.TestCase):
resp.status_code = 500
self.assertRaises(Exception, self.instances.edit, 'instance1')
def test_upgrade(self):
resp = mock.Mock()
resp.status_code = 200
body = None
self.instances.api.client.patch = mock.Mock(return_value=(resp, body))
self.instances.upgrade(self.instance_with_id, "5.6")
resp.status_code = 500
self.assertRaises(Exception, self.instances.upgrade,
'instance1')
def test_configuration(self):
def side_effect_func(path, inst):
return path, inst

View File

@@ -608,6 +608,10 @@ class ShellTest(utils.TestCase):
self.run_command('configuration-detach 1234')
self.assert_called('PUT', '/instances/1234')
def test_upgrade(self):
self.run_command('upgrade 1234 c-123')
self.assert_called('PATCH', '/instances/1234')
def test_metadata_edit(self):
self.run_command('metadata-edit 1234 key-123 value-123')
self.assert_called('PATCH', '/instances/1234/metadata/key-123')

View File

@@ -167,6 +167,18 @@ class Instances(base.ManagerWithFind):
resp, body = self.api.client.patch(url, body=body)
common.check_for_exceptions(resp, body, url)
def upgrade(self, instance, datastore_version):
"""Upgrades an instance with a new datastore version."""
body = {
"instance": {
"datastore_version": datastore_version
}
}
url = "/instances/%s" % base.getid(instance)
resp, body = self.api.client.patch(url, body=body)
common.check_for_exceptions(resp, body, url)
def list(self, limit=None, marker=None, include_clustered=False):
"""Get a list of all instances.

View File

@@ -759,6 +759,20 @@ def do_resize_instance(cs, args):
cs.instances.resize_instance(instance, flavor_id)
@utils.arg('instance',
metavar='<instance>',
type=str,
help='ID or name of the instance.')
@utils.arg('datastore_version',
metavar='<datastore_version>',
help='A datastore version name or ID.')
@utils.service_type('database')
def do_upgrade(cs, args):
"""Upgrades an instance to a new datastore version."""
instance = _find_instance(cs, args.instance)
cs.instances.upgrade(instance, args.datastore_version)
@utils.arg('instance',
metavar='<instance>',
type=str,