diff --git a/troveclient/utils.py b/troveclient/utils.py index e39ada33..a6ea4bdd 100644 --- a/troveclient/utils.py +++ b/troveclient/utils.py @@ -327,3 +327,10 @@ def decode_data(data): # py27 & py34 seem to understand bytearray the same return bytearray([item for item in base64.b64decode(data)]) + + +def do_action_with_msg(action, success_msg): + """Helper to run an action with return message.""" + + action + print(success_msg) diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py index 09349c1c..11eff3f3 100644 --- a/troveclient/v1/shell.py +++ b/troveclient/v1/shell.py @@ -408,7 +408,9 @@ def do_cluster_shrink(cs, args): def do_delete(cs, args): """Deletes an instance.""" instance = _find_instance(cs, args.instance) - cs.instances.delete(instance) + msg = _("Request to delete instance %s " + "has been accepted.") % instance.id + utils.do_action_with_msg(cs.instances.delete(instance), msg) @utils.arg('instance', metavar='', @@ -417,8 +419,10 @@ def do_delete(cs, args): def do_force_delete(cs, args): """Force delete an instance.""" instance = _find_instance(cs, args.instance) + msg = _("Request to force delete instance %s " + "has been accepted.") % instance.id cs.instances.reset_status(instance) - cs.instances.delete(instance) + utils.do_action_with_msg(cs.instances.delete(instance), msg) @utils.arg('instance', metavar='', @@ -439,7 +443,9 @@ def do_reset_status(cs, args): def do_cluster_delete(cs, args): """Deletes a cluster.""" cluster = _find_cluster(cs, args.cluster) - cs.clusters.delete(cluster) + msg = _("Request to delete cluster %s " + "has been accepted.") % cluster.id + utils.do_action_with_msg(cs.clusters.delete(cluster), msg) @utils.arg('cluster', metavar='', @@ -448,8 +454,10 @@ def do_cluster_delete(cs, args): def do_cluster_force_delete(cs, args): """Force delete a cluster""" cluster = _find_cluster(cs, args.cluster) + msg = _("Request to force delete cluster %s " + "has been accepted.") % cluster.id cs.clusters.reset_status(cluster) - cs.clusters.delete(cluster) + utils.do_action_with_msg(cs.clusters.delete(cluster), msg) @utils.arg('cluster', metavar='',