Add 'update' command to OSC
This change adds database support to the python-openstackclient project for the 'update' command. The trove command update is now: openstack database instance update Change-Id: I426c892540f82bc19b7b28d7845a2f6699c3f526 Partially-Implements: blueprint trove-support-in-python-openstackclient Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
This commit is contained in:
parent
b7ebc503f4
commit
bf24669d60
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The command ``trove update`` is now available to use in the
|
||||||
|
python-openstackclient CLI as ``openstack database instance update``.
|
@ -65,6 +65,7 @@ openstack.database.v1 =
|
|||||||
database_instance_resize_volume = troveclient.osc.v1.database_instances:ResizeDatabaseInstanceVolume
|
database_instance_resize_volume = troveclient.osc.v1.database_instances:ResizeDatabaseInstanceVolume
|
||||||
database_instance_restart = troveclient.osc.v1.database_instances:RestartDatabaseInstance
|
database_instance_restart = troveclient.osc.v1.database_instances:RestartDatabaseInstance
|
||||||
database_instance_show = troveclient.osc.v1.database_instances:ShowDatabaseInstance
|
database_instance_show = troveclient.osc.v1.database_instances:ShowDatabaseInstance
|
||||||
|
database_instance_update = troveclient.osc.v1.database_instances:UpdateDatabaseInstance
|
||||||
database_instance_upgrade = troveclient.osc.v1.database_instances:UpgradeDatabaseInstance
|
database_instance_upgrade = troveclient.osc.v1.database_instances:UpgradeDatabaseInstance
|
||||||
database_limit_list = troveclient.osc.v1.database_limits:ListDatabaseLimits
|
database_limit_list = troveclient.osc.v1.database_limits:ListDatabaseLimits
|
||||||
database_quota_show = troveclient.osc.v1.database_quota:ShowDatabaseQuota
|
database_quota_show = troveclient.osc.v1.database_quota:ShowDatabaseQuota
|
||||||
|
@ -552,3 +552,59 @@ class RestartDatabaseInstance(command.Command):
|
|||||||
instance = osc_utils.find_resource(db_instances,
|
instance = osc_utils.find_resource(db_instances,
|
||||||
parsed_args.instance)
|
parsed_args.instance)
|
||||||
db_instances.restart(instance)
|
db_instances.restart(instance)
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDatabaseInstance(command.Command):
|
||||||
|
|
||||||
|
_description = _("Updates an instance: Edits name, "
|
||||||
|
"configuration, or replica source.")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(UpdateDatabaseInstance, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'instance',
|
||||||
|
metavar='<instance>',
|
||||||
|
type=str,
|
||||||
|
help=_('ID or name of the instance.'),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--name',
|
||||||
|
metavar='<name>',
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help=_('ID or name of the instance.'),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--configuration',
|
||||||
|
metavar='<configuration>',
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help=_('ID of the configuration reference to attach.'),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--detach_replica_source',
|
||||||
|
'--detach-replica-source',
|
||||||
|
dest='detach_replica_source',
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=_('Detach the replica instance from its replication source. '
|
||||||
|
'--detach-replica-source may be deprecated in the future '
|
||||||
|
'in favor of just --detach_replica_source'),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--remove_configuration',
|
||||||
|
dest='remove_configuration',
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=_('Drops the current configuration reference.'),
|
||||||
|
)
|
||||||
|
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.edit(instance, parsed_args.configuration,
|
||||||
|
parsed_args.name,
|
||||||
|
parsed_args.detach_replica_source,
|
||||||
|
parsed_args.remove_configuration)
|
||||||
|
@ -300,3 +300,25 @@ class TestDatabaseInstanceRestart(TestInstances):
|
|||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
self.instance_client.restart.assert_called_with('instance1')
|
self.instance_client.restart.assert_called_with('instance1')
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDatabaseInstanceUpdate(TestInstances):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestDatabaseInstanceUpdate, self).setUp()
|
||||||
|
self.cmd = database_instances.UpdateDatabaseInstance(self.app, None)
|
||||||
|
|
||||||
|
@mock.patch.object(utils, 'find_resource')
|
||||||
|
def test_instance_update(self, mock_find):
|
||||||
|
args = ['instance1',
|
||||||
|
'--name', 'new_instance_name',
|
||||||
|
'--detach_replica_source',
|
||||||
|
'--remove_configuration']
|
||||||
|
mock_find.return_value = args[0]
|
||||||
|
parsed_args = self.check_parser(self.cmd, args, [])
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
self.instance_client.edit.assert_called_with('instance1',
|
||||||
|
None,
|
||||||
|
'new_instance_name',
|
||||||
|
True, True)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
Loading…
Reference in New Issue
Block a user