diff options
| author | Zhao Chao <zhaochao1984@gmail.com> | 2018-01-18 18:04:55 +0800 |
|---|---|---|
| committer | Zhao Chao <zhaochao1984@gmail.com> | 2018-01-20 17:20:32 +0800 |
| commit | e89cadc0ed75b5fd42ff5b1ea123bb47d075b116 (patch) | |
| tree | 0d76a3663a437756dd00ce166b5219bce4ce39ac /troveclient/osc | |
| parent | f0f4aeeec65ef776071905ac51d4133aef748768 (diff) | |
| download | python-troveclient-e89cadc0ed75b5fd42ff5b1ea123bb47d075b116.tar.gz | |
Add force-delete to OSC
This change adds database support for the python-openstackclient
project for the force-delete and cluster-force-delete commands.
The trove command force-delete is now:
openstack database instance force delete
The trove command cluster-force-delete is now:
openstack database cluster force delete
Change-Id: I919678ca6b06d3b5762eac1990cc1fbf0e149d7c
Partially-Implements: blueprint trove-support-in-python-openstackclient
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
Diffstat (limited to 'troveclient/osc')
| -rw-r--r-- | troveclient/osc/v1/database_clusters.py | 26 | ||||
| -rw-r--r-- | troveclient/osc/v1/database_instances.py | 27 |
2 files changed, 53 insertions, 0 deletions
diff --git a/troveclient/osc/v1/database_clusters.py b/troveclient/osc/v1/database_clusters.py index 997d79c..b9e1918 100644 --- a/troveclient/osc/v1/database_clusters.py +++ b/troveclient/osc/v1/database_clusters.py @@ -258,3 +258,29 @@ class UpgradeDatabaseCluster(command.Command): cluster = utils.find_resource(database_clusters, parsed_args.cluster) database_clusters.upgrade(cluster, parsed_args.datastore_version) + + +class ForceDeleteDatabaseCluster(command.Command): + + _description = _("Force delete a cluster.") + + def get_parser(self, prog_name): + parser = super(ForceDeleteDatabaseCluster, self).get_parser(prog_name) + parser.add_argument( + 'cluster', + metavar='<cluster>', + help=_('ID or name of the cluster.'), + ) + return parser + + def take_action(self, parsed_args): + database_clusters = self.app.client_manager.database.clusters + cluster = utils.find_resource(database_clusters, + parsed_args.cluster) + database_clusters.reset_status(cluster) + try: + database_clusters.delete(cluster) + except Exception as e: + msg = (_("Failed to delete cluster %(cluster)s: %(e)s") + % {'cluster': parsed_args.cluster, 'e': e}) + raise exceptions.CommandError(msg) diff --git a/troveclient/osc/v1/database_instances.py b/troveclient/osc/v1/database_instances.py index 60b5e98..0af4f36 100644 --- a/troveclient/osc/v1/database_instances.py +++ b/troveclient/osc/v1/database_instances.py @@ -475,3 +475,30 @@ class ResizeDatabaseInstanceVolume(command.Command): instance = osc_utils.find_resource(db_instances, parsed_args.instance) db_instances.resize_volume(instance, parsed_args.size) + + +class ForceDeleteDatabaseInstance(command.Command): + + _description = _("Force delete an instance.") + + def get_parser(self, prog_name): + parser = (super(ForceDeleteDatabaseInstance, self) + .get_parser(prog_name)) + parser.add_argument( + 'instance', + metavar='<instance>', + 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.reset_status(instance) + try: + db_instances.delete(instance) + except Exception as e: + msg = (_("Failed to delete instance %(instance)s: %(e)s") + % {'instance': parsed_args.instance, 'e': e}) + raise exceptions.CommandError(msg) |
