diff options
| author | wangyao <wangyao@cmss.chinamobile.com> | 2018-07-13 18:59:37 +0800 |
|---|---|---|
| committer | wangyao <wangyao@cmss.chinamobile.com> | 2018-07-17 16:03:41 +0800 |
| commit | 3f705bd0c828ef60dcae9d1621dcc7b95e9f21b9 (patch) | |
| tree | 4189bad0d79cc0315cca1595767f378bdadbf7ae /troveclient | |
| parent | 77f96476449e2418a64cbb508be68ccd77b38e79 (diff) | |
| download | python-troveclient-3f705bd0c828ef60dcae9d1621dcc7b95e9f21b9.tar.gz | |
Add promote-to-replica-source to OSC
This change adds database support to the python-openstackclient
project for the promote-to-replica-source command.
The trove command promote-to-replica-source is now:
openstack database instance promote to replica source
Change-Id: I0009b3e1074ddabaed6b02f5578f28cffc995b30
Partially-Implements: blueprint trove-support-in-python-openstackclient
Diffstat (limited to 'troveclient')
| -rw-r--r-- | troveclient/osc/v1/database_instances.py | 23 | ||||
| -rw-r--r-- | troveclient/tests/osc/v1/test_database_instances.py | 18 |
2 files changed, 41 insertions, 0 deletions
diff --git a/troveclient/osc/v1/database_instances.py b/troveclient/osc/v1/database_instances.py index 49fee39..8fae357 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 aeac22a..83e6d3e 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): |
