summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-05 04:36:25 +0000
committerGerrit Code Review <review@openstack.org>2016-06-05 04:36:26 +0000
commit93db7f58edf8e1157eacfc22f2b880c4edd91764 (patch)
tree08c810c79bf4da07d293a0abc2c6d72c1c0a23ec /openstackclient/compute
parent1c097b777c9e89a9e4e5eda80c583b0edc5c0784 (diff)
parent909bab1e07ec564055dd7dab578af9970a8e648e (diff)
downloadpython-openstackclient-93db7f58edf8e1157eacfc22f2b880c4edd91764.tar.gz
Merge "Support multiple argument for compute agent delete command"
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/agent.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/openstackclient/compute/v2/agent.py b/openstackclient/compute/v2/agent.py
index e358399d..064fe5a6 100644
--- a/openstackclient/compute/v2/agent.py
+++ b/openstackclient/compute/v2/agent.py
@@ -18,6 +18,7 @@
import six
from openstackclient.common import command
+from openstackclient.common import exceptions
from openstackclient.common import utils
from openstackclient.i18n import _
@@ -75,20 +76,35 @@ class CreateAgent(command.ShowOne):
class DeleteAgent(command.Command):
- """Delete compute agent command"""
+ """Delete compute agent(s)"""
def get_parser(self, prog_name):
parser = super(DeleteAgent, self).get_parser(prog_name)
parser.add_argument(
"id",
metavar="<id>",
- help=_("ID of agent to delete")
+ nargs='+',
+ help=_("ID of agent(s) to delete")
)
return parser
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
- compute_client.agents.delete(parsed_args.id)
+ result = 0
+ for id in parsed_args.id:
+ try:
+ compute_client.agents.delete(id)
+ except Exception as e:
+ result += 1
+ self.app.log.error(_("Failed to delete agent with "
+ "ID '%(id)s': %(e)s")
+ % {'id': id, 'e': e})
+
+ if result > 0:
+ total = len(parsed_args.id)
+ msg = (_("%(result)s of %(total)s agents failed "
+ "to delete.") % {'result': result, 'total': total})
+ raise exceptions.CommandError(msg)
class ListAgent(command.Lister):