Add resize-volume to OSC
This change adds database support to the python-openstackclient project for the resize-volume command The trove command resize-volume is now: openstack database instance resize volume Change-Id: If2413a605d294db0b0ee9c7aa49fbb1c929ebcd0 Partially-Implements: blueprint trove-support-in-python-openstackclient
This commit is contained in:
parent
e93d56de56
commit
f0f4aeeec6
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The command ``trove resize-volume`` is now available to use in
|
||||
the python-openstackclient CLI as ``openstack database instance resize volume``
|
@ -60,6 +60,7 @@ openstack.database.v1 =
|
||||
database_instance_list = troveclient.osc.v1.database_instances:ListDatabaseInstances
|
||||
database_instance_reset_status = troveclient.osc.v1.database_instances:ResetDatabaseInstanceStatus
|
||||
database_instance_resize_flavor = troveclient.osc.v1.database_instances:ResizeDatabaseInstanceFlavor
|
||||
database_instance_resize_volume = troveclient.osc.v1.database_instances:ResizeDatabaseInstanceVolume
|
||||
database_instance_show = troveclient.osc.v1.database_instances:ShowDatabaseInstance
|
||||
database_instance_upgrade = troveclient.osc.v1.database_instances:UpgradeDatabaseInstance
|
||||
database_limit_list = troveclient.osc.v1.database_limits:ListDatabaseLimits
|
||||
|
@ -445,3 +445,33 @@ class UpgradeDatabaseInstance(command.Command):
|
||||
instance = osc_utils.find_resource(db_instances,
|
||||
parsed_args.instance)
|
||||
db_instances.upgrade(instance, parsed_args.datastore_version)
|
||||
|
||||
|
||||
class ResizeDatabaseInstanceVolume(command.Command):
|
||||
|
||||
_description = _("Resizes the volume size of an instance.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ResizeDatabaseInstanceVolume, self).get_parser(
|
||||
prog_name
|
||||
)
|
||||
parser.add_argument(
|
||||
'instance',
|
||||
metavar='<instance>',
|
||||
type=str,
|
||||
help=_('ID or name of the instance.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'size',
|
||||
metavar='<size>',
|
||||
type=int,
|
||||
default=None,
|
||||
help=_('New size of the instance disk volume in GB.')
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
db_instances = self.app.client_manager.database.instances
|
||||
instance = osc_utils.find_resource(db_instances,
|
||||
parsed_args.instance)
|
||||
db_instances.resize_volume(instance, parsed_args.size)
|
||||
|
@ -218,3 +218,21 @@ class TestDatabaseInstanceUpgrade(TestInstances):
|
||||
self.instance_client.upgrade.assert_called_with('instance1',
|
||||
'datastore_version1')
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestDatabaseInstanceResizeVolume(TestInstances):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDatabaseInstanceResizeVolume, self).setUp()
|
||||
self.cmd = database_instances.ResizeDatabaseInstanceVolume(self.app,
|
||||
None)
|
||||
|
||||
@mock.patch.object(utils, 'find_resource')
|
||||
def test_instance_resize_volume(self, mock_find):
|
||||
args = ['instance1', '5']
|
||||
mock_find.side_effect = ['instance1']
|
||||
parsed_args = self.check_parser(self.cmd, args, [])
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.instance_client.resize_volume.assert_called_with('instance1',
|
||||
5)
|
||||
self.assertIsNone(result)
|
||||
|
Loading…
Reference in New Issue
Block a user