diff options
author | Zuul <zuul@review.openstack.org> | 2018-07-18 06:21:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-07-18 06:21:52 +0000 |
commit | 3adf5fe392102c088b72c4dac6f10eaf1f0e7983 (patch) | |
tree | 6585b675b0b24b020be00c2c90cf875de104f3e5 | |
parent | 048dd502fa8273e138cf76b752e39a912b16d534 (diff) | |
parent | 3f705bd0c828ef60dcae9d1621dcc7b95e9f21b9 (diff) | |
download | python-troveclient-3adf5fe392102c088b72c4dac6f10eaf1f0e7983.tar.gz |
-rw-r--r-- | releasenotes/notes/add-promote-to-replica-source-to-osc-6eca8c5507344205.yaml | 5 | ||||
-rw-r--r-- | setup.cfg | 1 | ||||
-rw-r--r-- | troveclient/osc/v1/database_instances.py | 23 | ||||
-rw-r--r-- | troveclient/tests/osc/v1/test_database_instances.py | 18 |
4 files changed, 47 insertions, 0 deletions
diff --git a/releasenotes/notes/add-promote-to-replica-source-to-osc-6eca8c5507344205.yaml b/releasenotes/notes/add-promote-to-replica-source-to-osc-6eca8c5507344205.yaml new file mode 100644 index 0000000..2eb1b5a --- /dev/null +++ b/releasenotes/notes/add-promote-to-replica-source-to-osc-6eca8c5507344205.yaml @@ -0,0 +1,5 @@ +--- +features: + - The command ``trove promote-to-replica-source`` is now available to + use in the python-openstackclient CLI as + ``openstack database instance promote to replica source`` @@ -68,6 +68,7 @@ openstack.database.v1 = database_instance_eject_replica_source = troveclient.osc.v1.database_instances:EjectDatabaseInstanceReplicaSource database_instance_force_delete = troveclient.osc.v1.database_instances:ForceDeleteDatabaseInstance database_instance_list = troveclient.osc.v1.database_instances:ListDatabaseInstances + database_instance_promote_to_replica_source = troveclient.osc.v1.database_instances:PromoteDatabaseInstanceToReplicaSource 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 diff --git a/troveclient/osc/v1/database_instances.py b/troveclient/osc/v1/database_instances.py index 96ec7c7..3bb6a74 100644 --- a/troveclient/osc/v1/database_instances.py +++ b/troveclient/osc/v1/database_instances.py @@ -533,6 +533,29 @@ class ForceDeleteDatabaseInstance(command.Command): raise exceptions.CommandError(msg) +class PromoteDatabaseInstanceToReplicaSource(command.Command): + + _description = _( + "Promotes a replica to be the new replica source of its set.") + + def get_parser(self, prog_name): + parser = super(PromoteDatabaseInstanceToReplicaSource, + self).get_parser(prog_name) + parser.add_argument( + 'instance', + metavar='<instance>', + type=str, + help=_('ID or name of the instance.'), + ) + 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.promote_to_replica_source(instance) + + class RestartDatabaseInstance(command.Command): _description = _("Restarts an instance.") diff --git a/troveclient/tests/osc/v1/test_database_instances.py b/troveclient/tests/osc/v1/test_database_instances.py index 524e30c..488a835 100644 --- a/troveclient/tests/osc/v1/test_database_instances.py +++ b/troveclient/tests/osc/v1/test_database_instances.py @@ -284,6 +284,24 @@ class TestDatabaseInstanceEnableLog(TestInstances): 'log_name') +class TestDatabaseInstancePromoteToReplicaSource(TestInstances): + + def setUp(self): + super(TestDatabaseInstancePromoteToReplicaSource, self).setUp() + self.cmd = database_instances.PromoteDatabaseInstanceToReplicaSource( + self.app, None) + + @mock.patch.object(utils, 'find_resource') + def test_instance_promote_to_replica_source(self, mock_find): + args = ['instance'] + mock_find.return_value = args[0] + parsed_args = self.check_parser(self.cmd, args, []) + result = self.cmd.take_action(parsed_args) + self.instance_client.promote_to_replica_source.assert_called_with( + 'instance') + self.assertIsNone(result) + + class TestDatabaseInstanceRestart(TestInstances): def setUp(self): |