From 64e4050ed1acb41d41d468ad1a8b714e762ab244 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 15 Apr 2018 08:55:53 +0300 Subject: [PATCH] TVD: fix project plugin OSC to display errors The project plugin mapping used by the TVD plugin uses the openstack client for configration by the admin user. This patch catches the plugin exceptions to make sure the user sees the error. Change-Id: I8dce5e1daf2d0c4796c53e831b81462b27e8bc9c --- vmware_nsx/osc/v2/project_plugin_map.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/osc/v2/project_plugin_map.py b/vmware_nsx/osc/v2/project_plugin_map.py index 4335796806..515acfc7b1 100644 --- a/vmware_nsx/osc/v2/project_plugin_map.py +++ b/vmware_nsx/osc/v2/project_plugin_map.py @@ -13,10 +13,14 @@ """Project Plugin mapping action implementations""" +import six + +from openstack import exceptions as os_exceptions from openstack.network import network_service from openstack import resource from openstackclient.i18n import _ from osc_lib.command import command +from osc_lib import exceptions as osc_exceptions from osc_lib import utils project_plugin_maps_path = "/project-plugin-maps" @@ -82,7 +86,13 @@ class CreateProjectPluginMap(command.ShowOne): def take_action(self, parsed_args): client = self.app.client_manager.network attrs = _get_attrs(parsed_args) - obj = client._create(ProjectPluginMap, **attrs) + try: + obj = client._create(ProjectPluginMap, **attrs) + except os_exceptions.HttpException as exc: + msg = _("Error while executing command: %s") % exc.message + if exc.details: + msg += ", " + six.text_type(exc.details) + raise osc_exceptions.CommandError(msg) display_columns, columns = _get_columns(obj) data = utils.get_item_properties(obj, columns, formatters={}) return (display_columns, data)