summaryrefslogtreecommitdiff
path: root/openstackclient/network/v2
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-03-14 14:03:04 +0800
committerTang Chen <chen.tang@easystack.cn>2016-04-14 13:54:14 +0800
commit56f9227063cb86594600ccc80c661101f0f0c2c8 (patch)
treec682b181aaf6cb831a33cfb383a310ec2f05af48 /openstackclient/network/v2
parentbe6027e09b806496d20b833a5f9ed6fcf44156b6 (diff)
downloadpython-openstackclient-56f9227063cb86594600ccc80c661101f0f0c2c8.tar.gz
Enhance exception handling for "network delete" command
This patch rework "network delete" command following the rules in doc/source/command-errors.rst. In "network delete" command, there are multiple REST API calls, and we should make as many of them as possible. And log error for each one, give a better error message. Also return a non-zero exit code. Change-Id: I39ae087dd7bd08d049d513abfa6c5cab2bd13b2b Partial-Bug: #1556719
Diffstat (limited to 'openstackclient/network/v2')
-rw-r--r--openstackclient/network/v2/network.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py
index 20d943ed..fcbe77c7 100644
--- a/openstackclient/network/v2/network.py
+++ b/openstackclient/network/v2/network.py
@@ -224,9 +224,13 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
return (columns, data)
-class DeleteNetwork(common.NetworkAndComputeCommand):
+class DeleteNetwork(common.NetworkAndComputeDelete):
"""Delete network(s)"""
+ # Used by base class to find resources in parsed_args.
+ resource = 'network'
+ r = None
+
def update_parser_common(self, parser):
parser.add_argument(
'network',
@@ -234,20 +238,16 @@ class DeleteNetwork(common.NetworkAndComputeCommand):
nargs="+",
help=("Network(s) to delete (name or ID)")
)
+
return parser
def take_action_network(self, client, parsed_args):
- for network in parsed_args.network:
- obj = client.find_network(network)
- client.delete_network(obj)
+ obj = client.find_network(self.r, ignore_missing=False)
+ client.delete_network(obj)
def take_action_compute(self, client, parsed_args):
- for network in parsed_args.network:
- network = utils.find_resource(
- client.networks,
- network,
- )
- client.networks.delete(network.id)
+ network = utils.find_resource(client.networks, self.r)
+ client.networks.delete(network.id)
class ListNetwork(common.NetworkAndComputeLister):