summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Motoki <amotoki@gmail.com>2017-04-11 10:24:01 +0000
committerAkihiro Motoki <amotoki@gmail.com>2017-04-11 10:24:01 +0000
commitced987815d6a091fbcedbd4c319395038cb3f976 (patch)
treecbf937b36497d6fd3637cf415b5e6fa2fddecab8
parentc88d5c1de396d32550550f9790aa570989b1576a (diff)
Ensure log messages are not translated
Previously translated messages are included in log messages and it was determined what language is chosen by users. It makes difficult for operators to understand log messgaes. This commit tries to use English messages for all log messages. The following policies are applied based on the past discussions in the bug 1406333 and related reviews. - English messages are used for log messages. - log messages include exception messages if possible to help operators identify what happens. - Use ID rather than name for log messages as ID is much more unique compared to name. - LOG.debug() in success code path are deleted. We don't log success messages in most places and API calls to back-end services can be logged from python bindings. Change-Id: Ie554463908327435d886d0d0f1671fd327c0cd00 Closes-Bug: #1406333
Notes
Notes (review): Code-Review+1: Julie Gravel <julie.gravel@suse.com> Code-Review+1: Debo Zhang <zhangdebo@inspur.com> Code-Review+2: Rob Cresswell <robert.cresswell@outlook.com> Code-Review+2: David Lyle <dklyle0@gmail.com> Workflow+1: David Lyle <dklyle0@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 27 Apr 2017 22:39:12 +0000 Reviewed-on: https://review.openstack.org/455635 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--horizon/notifications.py22
-rw-r--r--horizon/tables/base.py7
-rw-r--r--openstack_dashboard/api/microversions.py4
-rw-r--r--openstack_dashboard/api/neutron.py28
-rw-r--r--openstack_dashboard/api/nova.py4
-rw-r--r--openstack_dashboard/dashboards/admin/networks/agents/tables.py2
-rw-r--r--openstack_dashboard/dashboards/admin/networks/forms.py8
-rw-r--r--openstack_dashboard/dashboards/admin/networks/ports/forms.py18
-rw-r--r--openstack_dashboard/dashboards/admin/networks/subnets/tables.py5
-rw-r--r--openstack_dashboard/dashboards/admin/networks/subnets/workflows.py5
-rw-r--r--openstack_dashboard/dashboards/admin/networks/tables.py5
-rw-r--r--openstack_dashboard/dashboards/identity/identity_providers/protocols/forms.py2
-rw-r--r--openstack_dashboard/dashboards/project/firewalls/forms.py157
-rw-r--r--openstack_dashboard/dashboards/project/firewalls/tables.py5
-rw-r--r--openstack_dashboard/dashboards/project/networks/forms.py6
-rw-r--r--openstack_dashboard/dashboards/project/networks/ports/forms.py16
-rw-r--r--openstack_dashboard/dashboards/project/networks/ports/tables.py7
-rw-r--r--openstack_dashboard/dashboards/project/networks/subnets/tables.py5
-rw-r--r--openstack_dashboard/dashboards/project/networks/tables.py5
-rw-r--r--openstack_dashboard/dashboards/project/networks/workflows.py10
-rw-r--r--openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py10
-rw-r--r--openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tabs.py6
-rw-r--r--openstack_dashboard/dashboards/project/routers/forms.py12
-rw-r--r--openstack_dashboard/dashboards/project/routers/ports/forms.py24
-rw-r--r--openstack_dashboard/dashboards/project/routers/ports/tables.py5
-rw-r--r--openstack_dashboard/dashboards/project/routers/tables.py18
-rw-r--r--openstack_dashboard/dashboards/project/vpn/forms.py16
27 files changed, 223 insertions, 189 deletions
diff --git a/horizon/notifications.py b/horizon/notifications.py
index 31f2b5a..bde4812 100644
--- a/horizon/notifications.py
+++ b/horizon/notifications.py
@@ -66,13 +66,14 @@ class JSONMessage(object):
66 except ValueError as exc: 66 except ValueError as exc:
67 self.failed = True 67 self.failed = True
68 68
69 msg = _("Message json file '%(path)s' is malformed." 69 params = {'path': self._path, 'exception': exc}
70 " %(exception)s")
71 msg = msg % {'path': self._path, 'exception': str(exc)}
72 if self.fail_silently: 70 if self.fail_silently:
73 LOG.warning(msg) 71 LOG.warning("Message json file '%(path)s' is malformed. "
72 "%(exception)s", params)
74 else: 73 else:
75 raise exceptions.MessageFailure(msg) 74 raise exceptions.MessageFailure(
75 _("Message json file '%(path)s' is malformed. "
76 "%(exception)s") % params)
76 else: 77 else:
77 level_name = attrs.get('level', 'info') 78 level_name = attrs.get('level', 'info')
78 if level_name in self.MESSAGE_LEVELS: 79 if level_name in self.MESSAGE_LEVELS:
@@ -89,13 +90,14 @@ class JSONMessage(object):
89 except Exception as exc: 90 except Exception as exc:
90 self.failed = True 91 self.failed = True
91 92
92 msg = _("Error processing message json file '%(path)s': " 93 params = {'path': self._path, 'exception': exc}
93 "%(exception)s")
94 msg = msg % {'path': self._path, 'exception': str(exc)}
95 if self.fail_silently: 94 if self.fail_silently:
96 LOG.warning(msg) 95 LOG.warning("Error processing message json file '%(path)s': "
96 "%(exception)s", params)
97 else: 97 else:
98 raise exceptions.MessageFailure(msg) 98 raise exceptions.MessageFailure(
99 _("Error processing message json file '%(path)s': "
100 "%(exception)s") % params)
99 101
100 def send_message(self, request): 102 def send_message(self, request):
101 if self.failed: 103 if self.failed:
diff --git a/horizon/tables/base.py b/horizon/tables/base.py
index b8c9914..8c7138a 100644
--- a/horizon/tables/base.py
+++ b/horizon/tables/base.py
@@ -391,10 +391,9 @@ class Column(html.HTMLElement):
391 # Basic object lookups 391 # Basic object lookups
392 data = getattr(datum, self.transform, None) 392 data = getattr(datum, self.transform, None)
393 if not hasattr(datum, self.transform): 393 if not hasattr(datum, self.transform):
394 msg = _("The attribute %(attr)s doesn't exist on " 394 msg = "The attribute %(attr)s doesn't exist on %(obj)s."
395 "%(obj)s.") % {'attr': self.transform, 'obj': datum} 395 LOG.debug(termcolors.colorize(msg, **PALETTE['ERROR']),
396 msg = termcolors.colorize(msg, **PALETTE['ERROR']) 396 {'attr': self.transform, 'obj': datum})
397 LOG.debug(msg)
398 return data 397 return data
399 398
400 def get_data(self, datum): 399 def get_data(self, datum):
diff --git a/openstack_dashboard/api/microversions.py b/openstack_dashboard/api/microversions.py
index 03f0173..64a53c4 100644
--- a/openstack_dashboard/api/microversions.py
+++ b/openstack_dashboard/api/microversions.py
@@ -45,8 +45,8 @@ def get_microversion_for_feature(service, feature, wrapper_class,
45 try: 45 try:
46 service_features = MICROVERSION_FEATURES[service] 46 service_features = MICROVERSION_FEATURES[service]
47 except KeyError: 47 except KeyError:
48 LOG.debug("'%s' could not be found in the MICROVERSION_FEATURES " 48 LOG.debug("'%s' could not be found in the MICROVERSION_FEATURES dict",
49 "dict" % service) 49 service)
50 return None 50 return None
51 feature_versions = service_features[feature] 51 feature_versions = service_features[feature]
52 for version in reversed(feature_versions): 52 for version in reversed(feature_versions):
diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py
index 5c44d23..ed61a96 100644
--- a/openstack_dashboard/api/neutron.py
+++ b/openstack_dashboard/api/neutron.py
@@ -1123,9 +1123,9 @@ def servers_update_addresses(request, servers, all_tenants=False):
1123 networks = list_resources_with_long_filters( 1123 networks = list_resources_with_long_filters(
1124 network_list, 'id', set([port.network_id for port in ports]), 1124 network_list, 'id', set([port.network_id for port in ports]),
1125 request=request) 1125 request=request)
1126 except Exception: 1126 except Exception as e:
1127 LOG.error('Unable to connect to Neutron: %s', e)
1127 error_message = _('Unable to connect to Neutron.') 1128 error_message = _('Unable to connect to Neutron.')
1128 LOG.error(error_message)
1129 messages.error(request, error_message) 1129 messages.error(request, error_message)
1130 return 1130 return
1131 1131
@@ -1160,9 +1160,10 @@ def _server_get_addresses(request, server, ports, floating_ips, network_names):
1160 def _format_address(mac, ip, type): 1160 def _format_address(mac, ip, type):
1161 try: 1161 try:
1162 version = netaddr.IPAddress(ip).version 1162 version = netaddr.IPAddress(ip).version
1163 except Exception: 1163 except Exception as e:
1164 LOG.error('Unable to parse IP address %(ip)s: %(exc)s',
1165 {'ip': ip, 'exc': e})
1164 error_message = _('Unable to parse IP address %s.') % ip 1166 error_message = _('Unable to parse IP address %s.') % ip
1165 LOG.error(error_message)
1166 messages.error(request, error_message) 1167 messages.error(request, error_message)
1167 raise 1168 raise
1168 return {u'OS-EXT-IPS-MAC:mac_addr': mac, 1169 return {u'OS-EXT-IPS-MAC:mac_addr': mac,
@@ -1283,10 +1284,9 @@ def get_feature_permission(request, feature, operation=None):
1283 network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {}) 1284 network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
1284 feature_info = FEATURE_MAP.get(feature) 1285 feature_info = FEATURE_MAP.get(feature)
1285 if not feature_info: 1286 if not feature_info:
1286 # Translators: Only used inside Horizon code and invisible to users 1287 raise ValueError("The requested feature '%(feature)s' is unknown. "
1287 raise ValueError(_("The requested feature '%(feature)s' is unknown. " 1288 "Please make sure to specify a feature defined "
1288 "Please make sure to specify a feature defined " 1289 "in FEATURE_MAP.")
1289 "in FEATURE_MAP."))
1290 1290
1291 # Check dashboard settings 1291 # Check dashboard settings
1292 feature_config = feature_info.get('config') 1292 feature_config = feature_info.get('config')
@@ -1300,10 +1300,9 @@ def get_feature_permission(request, feature, operation=None):
1300 if feature_policies: 1300 if feature_policies:
1301 policy_name = feature_policies.get(operation) 1301 policy_name = feature_policies.get(operation)
1302 if not policy_name: 1302 if not policy_name:
1303 # Translators: Only used inside Horizon code and invisible to users 1303 raise ValueError("The 'operation' parameter for "
1304 raise ValueError(_("The 'operation' parameter for " 1304 "get_feature_permission '%(feature)s' "
1305 "get_feature_permission '%(feature)s' " 1305 "is invalid. It should be one of %(allowed)s"
1306 "is invalid. It should be one of %(allowed)s")
1307 % {'feature': feature, 1306 % {'feature': feature,
1308 'allowed': ' '.join(feature_policies.keys())}) 1307 'allowed': ' '.join(feature_policies.keys())})
1309 role = (('network', policy_name),) 1308 role = (('network', policy_name),)
@@ -1316,9 +1315,8 @@ def get_feature_permission(request, feature, operation=None):
1316 try: 1315 try:
1317 return is_extension_supported(request, feature_extension) 1316 return is_extension_supported(request, feature_extension)
1318 except Exception: 1317 except Exception:
1319 msg = (_("Failed to check Neutron '%s' extension is not supported") 1318 LOG.info("Failed to check Neutron '%s' extension is not supported",
1320 % feature_extension) 1319 feature_extension)
1321 LOG.info(msg)
1322 return False 1320 return False
1323 1321
1324 # If all checks are passed, now a given feature is allowed. 1322 # If all checks are passed, now a given feature is allowed.
diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py
index 3fddf6d..1854b7a 100644
--- a/openstack_dashboard/api/nova.py
+++ b/openstack_dashboard/api/nova.py
@@ -349,8 +349,8 @@ class SecurityGroupManager(network_base.SecurityGroupManager):
349 self.client.servers.remove_security_group(instance_id, group) 349 self.client.servers.remove_security_group(instance_id, group)
350 num_groups_to_modify -= 1 350 num_groups_to_modify -= 1
351 except nova_exceptions.ClientException as err: 351 except nova_exceptions.ClientException as err:
352 LOG.error(_("Failed to modify %(num_groups_to_modify)d instance " 352 LOG.error("Failed to modify %(num_groups_to_modify)d instance "
353 "security groups: %(err)s"), 353 "security groups: %(err)s",
354 {'num_groups_to_modify': num_groups_to_modify, 354 {'num_groups_to_modify': num_groups_to_modify,
355 'err': err}) 355 'err': err})
356 # reraise novaclient.exceptions.ClientException, but with 356 # reraise novaclient.exceptions.ClientException, but with
diff --git a/openstack_dashboard/dashboards/admin/networks/agents/tables.py b/openstack_dashboard/dashboards/admin/networks/agents/tables.py
index 3edd563..4797fee 100644
--- a/openstack_dashboard/dashboards/admin/networks/agents/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/agents/tables.py
@@ -54,8 +54,8 @@ class DeleteDHCPAgent(tables.DeleteAction):
54 api.neutron.remove_network_from_dhcp_agent(request, obj_id, 54 api.neutron.remove_network_from_dhcp_agent(request, obj_id,
55 network_id) 55 network_id)
56 except Exception as e: 56 except Exception as e:
57 LOG.info('Failed to delete agent: %s', e)
57 msg = _('Failed to delete agent: %s') % e 58 msg = _('Failed to delete agent: %s') % e
58 LOG.info(msg)
59 redirect = reverse('horizon:admin:networks:detail', 59 redirect = reverse('horizon:admin:networks:detail',
60 args=[network_id]) 60 args=[network_id])
61 exceptions.handle(request, msg, redirect=redirect) 61 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py
index 3eec873..6146343 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -263,7 +263,7 @@ class CreateNetwork(forms.SelfHandlingForm):
263 params['provider:segmentation_id'] = ( 263 params['provider:segmentation_id'] = (
264 data['segmentation_id']) 264 data['segmentation_id'])
265 network = api.neutron.network_create(request, **params) 265 network = api.neutron.network_create(request, **params)
266 LOG.debug(_('Network %s was successfully created.'), data['name']) 266 LOG.debug('Network %s was successfully created.', data['name'])
267 return network 267 return network
268 except Exception: 268 except Exception:
269 redirect = reverse('horizon:admin:networks:index') 269 redirect = reverse('horizon:admin:networks:index')
@@ -329,11 +329,11 @@ class UpdateNetwork(forms.SelfHandlingForm):
329 self.initial['network_id'], 329 self.initial['network_id'],
330 **params) 330 **params)
331 msg = _('Network %s was successfully updated.') % data['name'] 331 msg = _('Network %s was successfully updated.') % data['name']
332 LOG.debug(msg)
333 messages.success(request, msg) 332 messages.success(request, msg)
334 return network 333 return network
335 except Exception: 334 except Exception as e:
335 LOG.info('Failed to update network %(id)s: %(exc)s',
336 {'id': self.initial['network_id'], 'exc': e})
336 msg = _('Failed to update network %s') % data['name'] 337 msg = _('Failed to update network %s') % data['name']
337 LOG.info(msg)
338 redirect = reverse(self.failure_url) 338 redirect = reverse(self.failure_url)
339 exceptions.handle(request, msg, redirect=redirect) 339 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/admin/networks/ports/forms.py b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
index 5db8f45..8494f89 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
@@ -124,15 +124,15 @@ class CreatePort(project_forms.CreatePort):
124 124
125 port = api.neutron.port_create(request, **params) 125 port = api.neutron.port_create(request, **params)
126 msg = _('Port %s was successfully created.') % port['id'] 126 msg = _('Port %s was successfully created.') % port['id']
127 LOG.debug(msg)
128 messages.success(request, msg) 127 messages.success(request, msg)
129 return port 128 return port
130 except Exception: 129 except Exception as e:
131 msg = _('Failed to create a port for network %s') \ 130 net_id = data['network_id']
132 % data['network_id'] 131 LOG.info('Failed to create a port for network %(id)s: %(exc)s',
133 LOG.info(msg) 132 {'id': net_id, 'exc': e})
133 msg = _('Failed to create a port for network %s') % net_id
134 redirect = reverse(self.failure_url, 134 redirect = reverse(self.failure_url,
135 args=(data['network_id'],)) 135 args=(net_id,))
136 exceptions.handle(request, msg, redirect=redirect) 136 exceptions.handle(request, msg, redirect=redirect)
137 137
138 138
@@ -185,12 +185,12 @@ class UpdatePort(project_forms.UpdatePort):
185 mac_address=data['mac_address'], 185 mac_address=data['mac_address'],
186 **extension_kwargs) 186 **extension_kwargs)
187 msg = _('Port %s was successfully updated.') % data['port_id'] 187 msg = _('Port %s was successfully updated.') % data['port_id']
188 LOG.debug(msg)
189 messages.success(request, msg) 188 messages.success(request, msg)
190 return port 189 return port
191 except Exception: 190 except Exception as e:
191 LOG.info('Failed to update port %(id)s: %(exc)s',
192 {'id': data['port_id'], 'exc': e})
192 msg = _('Failed to update port %s') % data['port_id'] 193 msg = _('Failed to update port %s') % data['port_id']
193 LOG.info(msg)
194 redirect = reverse(self.failure_url, 194 redirect = reverse(self.failure_url,
195 args=[data['network_id']]) 195 args=[data['network_id']])
196 exceptions.handle(request, msg, redirect=redirect) 196 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py
index 66572ed..d3cb202 100644
--- a/openstack_dashboard/dashboards/admin/networks/subnets/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/subnets/tables.py
@@ -54,9 +54,10 @@ class DeleteSubnet(proj_tables.SubnetPolicyTargetMixin, tables.DeleteAction):
54 def delete(self, request, obj_id): 54 def delete(self, request, obj_id):
55 try: 55 try:
56 api.neutron.subnet_delete(request, obj_id) 56 api.neutron.subnet_delete(request, obj_id)
57 except Exception: 57 except Exception as e:
58 LOG.info('Failed to delete subnet %(id)s: %(exc)s',
59 {'id': obj_id, 'exc': e})
58 msg = _('Failed to delete subnet %s') % obj_id 60 msg = _('Failed to delete subnet %s') % obj_id
59 LOG.info(msg)
60 network_id = self.table.kwargs['network_id'] 61 network_id = self.table.kwargs['network_id']
61 redirect = reverse('horizon:admin:networks:detail', 62 redirect = reverse('horizon:admin:networks:detail',
62 args=[network_id]) 63 args=[network_id])
diff --git a/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py b/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py
index 4ca2c6a..871b379 100644
--- a/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py
+++ b/openstack_dashboard/dashboards/admin/networks/subnets/workflows.py
@@ -64,10 +64,11 @@ class CreateSubnet(project_workflows.CreateSubnet):
64 # created for if admin user does not belong to the tenant. 64 # created for if admin user does not belong to the tenant.
65 network = api.neutron.network_get(request, 65 network = api.neutron.network_get(request,
66 self.context['network_id']) 66 self.context['network_id'])
67 except Exception: 67 except Exception as e:
68 LOG.info('Failed to retrieve network %(id)s for a subnet: %(exc)s',
69 {'id': data['network_id'], 'exc': e})
68 msg = (_('Failed to retrieve network %s for a subnet') % 70 msg = (_('Failed to retrieve network %s for a subnet') %
69 data['network_id']) 71 data['network_id'])
70 LOG.info(msg)
71 redirect = self.get_failure_url() 72 redirect = self.get_failure_url()
72 exceptions.handle(request, msg, redirect=redirect) 73 exceptions.handle(request, msg, redirect=redirect)
73 subnet = self._create_subnet(request, data, 74 subnet = self._create_subnet(request, data,
diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py
index 5ff9517..47ed5fe 100644
--- a/openstack_dashboard/dashboards/admin/networks/tables.py
+++ b/openstack_dashboard/dashboards/admin/networks/tables.py
@@ -53,9 +53,10 @@ class DeleteNetwork(policy.PolicyTargetMixin, tables.DeleteAction):
53 def delete(self, request, obj_id): 53 def delete(self, request, obj_id):
54 try: 54 try:
55 api.neutron.network_delete(request, obj_id) 55 api.neutron.network_delete(request, obj_id)
56 except Exception: 56 except Exception as e:
57 LOG.info('Failed to delete network %(id)s: %(exc)s',
58 {'id': obj_id, 'exc': e})
57 msg = _('Failed to delete network %s') % obj_id 59 msg = _('Failed to delete network %s') % obj_id
58 LOG.info(msg)
59 redirect = reverse('horizon:admin:networks:index') 60 redirect = reverse('horizon:admin:networks:index')
60 exceptions.handle(request, msg, redirect=redirect) 61 exceptions.handle(request, msg, redirect=redirect)
61 62
diff --git a/openstack_dashboard/dashboards/identity/identity_providers/protocols/forms.py b/openstack_dashboard/dashboards/identity/identity_providers/protocols/forms.py
index 2b931e4..29a8d57 100644
--- a/openstack_dashboard/dashboards/identity/identity_providers/protocols/forms.py
+++ b/openstack_dashboard/dashboards/identity/identity_providers/protocols/forms.py
@@ -40,8 +40,8 @@ class AddProtocolForm(forms.SelfHandlingForm):
40 try: 40 try:
41 mappings = api.keystone.mapping_list(request) 41 mappings = api.keystone.mapping_list(request)
42 except Exception as e: 42 except Exception as e:
43 LOG.info('Failed to get mapping list %s', e)
43 msg = _('Failed to get mapping list %s') % e 44 msg = _('Failed to get mapping list %s') % e
44 LOG.info(msg)
45 messages.error(request, msg) 45 messages.error(request, msg)
46 46
47 choices = [(m.id, m.id) for m in mappings] 47 choices = [(m.id, m.id) for m in mappings]
diff --git a/openstack_dashboard/dashboards/project/firewalls/forms.py b/openstack_dashboard/dashboards/project/firewalls/forms.py
index 701ab8a..b454066 100644
--- a/openstack_dashboard/dashboards/project/firewalls/forms.py
+++ b/openstack_dashboard/dashboards/project/firewalls/forms.py
@@ -12,7 +12,6 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15import abc
16import logging 15import logging
17 16
18from django.core.urlresolvers import reverse 17from django.core.urlresolvers import reverse
@@ -89,13 +88,13 @@ class UpdateRule(forms.SelfHandlingForm):
89 try: 88 try:
90 rule = api.fwaas.rule_update(request, rule_id, **context) 89 rule = api.fwaas.rule_update(request, rule_id, **context)
91 msg = _('Rule %s was successfully updated.') % name_or_id 90 msg = _('Rule %s was successfully updated.') % name_or_id
92 LOG.debug(msg)
93 messages.success(request, msg) 91 messages.success(request, msg)
94 return rule 92 return rule
95 except Exception as e: 93 except Exception as e:
94 LOG.error('Failed to update rule %(id)s: %(reason)s',
95 {'id': rule_id, 'reason': e})
96 msg = (_('Failed to update rule %(name)s: %(reason)s') % 96 msg = (_('Failed to update rule %(name)s: %(reason)s') %
97 {'name': name_or_id, 'reason': e}) 97 {'name': name_or_id, 'reason': e})
98 LOG.error(msg)
99 redirect = reverse(self.failure_url) 98 redirect = reverse(self.failure_url)
100 exceptions.handle(request, msg, redirect=redirect) 99 exceptions.handle(request, msg, redirect=redirect)
101 100
@@ -115,13 +114,13 @@ class UpdatePolicy(forms.SelfHandlingForm):
115 try: 114 try:
116 policy = api.fwaas.policy_update(request, policy_id, **context) 115 policy = api.fwaas.policy_update(request, policy_id, **context)
117 msg = _('Policy %s was successfully updated.') % name_or_id 116 msg = _('Policy %s was successfully updated.') % name_or_id
118 LOG.debug(msg)
119 messages.success(request, msg) 117 messages.success(request, msg)
120 return policy 118 return policy
121 except Exception as e: 119 except Exception as e:
122 msg = _('Failed to update policy %(name)s: %(reason)s') % { 120 LOG.error('Failed to update policy %(id)s: %(reason)s',
123 'name': name_or_id, 'reason': e} 121 {'id': policy_id, 'reason': e})
124 LOG.error(msg) 122 msg = (_('Failed to update policy %(name)s: %(reason)s') %
123 {'name': name_or_id, 'reason': e})
125 redirect = reverse(self.failure_url) 124 redirect = reverse(self.failure_url)
126 exceptions.handle(request, msg, redirect=redirect) 125 exceptions.handle(request, msg, redirect=redirect)
127 126
@@ -170,13 +169,13 @@ class UpdateFirewall(forms.SelfHandlingForm):
170 firewall = api.fwaas.firewall_update(request, firewall_id, 169 firewall = api.fwaas.firewall_update(request, firewall_id,
171 **context) 170 **context)
172 msg = _('Firewall %s was successfully updated.') % name_or_id 171 msg = _('Firewall %s was successfully updated.') % name_or_id
173 LOG.debug(msg)
174 messages.success(request, msg) 172 messages.success(request, msg)
175 return firewall 173 return firewall
176 except Exception as e: 174 except Exception as e:
177 msg = _('Failed to update firewall %(name)s: %(reason)s') % { 175 LOG.error('Failed to update firewall %(id)s: %(reason)s',
178 'name': name_or_id, 'reason': e} 176 {'id': firewall_id, 'reason': e})
179 LOG.error(msg) 177 msg = (_('Failed to update firewall %(name)s: %(reason)s') %
178 {'name': name_or_id, 'reason': e})
180 redirect = reverse(self.failure_url) 179 redirect = reverse(self.failure_url)
181 exceptions.handle(request, msg, redirect=redirect) 180 exceptions.handle(request, msg, redirect=redirect)
182 181
@@ -210,8 +209,8 @@ class InsertRuleToPolicy(forms.SelfHandlingForm):
210 current_choices = [(r.id, r.name_or_id) for r in current_rules] 209 current_choices = [(r.id, r.name_or_id) for r in current_rules]
211 210
212 except Exception as e: 211 except Exception as e:
212 LOG.error('Failed to retrieve available rules: %s', e)
213 msg = _('Failed to retrieve available rules: %s') % e 213 msg = _('Failed to retrieve available rules: %s') % e
214 LOG.error(msg)
215 redirect = reverse(self.failure_url) 214 redirect = reverse(self.failure_url)
216 exceptions.handle(request, msg, redirect=redirect) 215 exceptions.handle(request, msg, redirect=redirect)
217 216
@@ -233,13 +232,13 @@ class InsertRuleToPolicy(forms.SelfHandlingForm):
233 '%(policy)s.') % { 232 '%(policy)s.') % {
234 'rule': insert_rule.name or insert_rule.id, 233 'rule': insert_rule.name or insert_rule.id,
235 'policy': policy_name_or_id} 234 'policy': policy_name_or_id}
236 LOG.debug(msg)
237 messages.success(request, msg) 235 messages.success(request, msg)
238 return policy 236 return policy
239 except Exception as e: 237 except Exception as e:
240 msg = _('Failed to insert rule to policy %(name)s: %(reason)s') % { 238 LOG.error('Failed to insert rule to policy %(id)s: %(reason)s',
241 'name': policy_id, 'reason': e} 239 {'id': policy_id, 'reason': e})
242 LOG.error(msg) 240 msg = (_('Failed to insert rule to policy %(name)s: %(reason)s') %
241 {'name': policy_id, 'reason': e})
243 redirect = reverse(self.failure_url) 242 redirect = reverse(self.failure_url)
244 exceptions.handle(request, msg, redirect=redirect) 243 exceptions.handle(request, msg, redirect=redirect)
245 244
@@ -263,9 +262,12 @@ class RemoveRuleFromPolicy(forms.SelfHandlingForm):
263 262
264 current_choices = [(r.id, r.name_or_id) for r in current_rules] 263 current_choices = [(r.id, r.name_or_id) for r in current_rules]
265 except Exception as e: 264 except Exception as e:
266 msg = _('Failed to retrieve current rules in policy %(name)s: ' 265 LOG.error('Failed to retrieve current rules in policy %(id)s: '
267 '%(reason)s') % {'name': self.initial['name'], 'reason': e} 266 '%(reason)s',
268 LOG.error(msg) 267 {'id': self.initial['policy_id'], 'reason': e})
268 msg = (_('Failed to retrieve current rules in policy %(name)s: '
269 '%(reason)s') %
270 {'name': self.initial['name'], 'reason': e})
269 redirect = reverse(self.failure_url) 271 redirect = reverse(self.failure_url)
270 exceptions.handle(request, msg, redirect=redirect) 272 exceptions.handle(request, msg, redirect=redirect)
271 273
@@ -283,39 +285,47 @@ class RemoveRuleFromPolicy(forms.SelfHandlingForm):
283 '%(policy)s.') % { 285 '%(policy)s.') % {
284 'rule': remove_rule.name or remove_rule.id, 286 'rule': remove_rule.name or remove_rule.id,
285 'policy': policy_name_or_id} 287 'policy': policy_name_or_id}
286 LOG.debug(msg)
287 messages.success(request, msg) 288 messages.success(request, msg)
288 return policy 289 return policy
289 except Exception as e: 290 except Exception as e:
290 msg = _('Failed to remove rule from policy %(name)s: ' 291 LOG.error('Failed to remove rule from policy %(id)s: %(reason)s',
291 '%(reason)s') % {'name': self.initial['name'], 292 {'id': policy_id, 'reason': e})
292 'reason': e} 293 msg = (_('Failed to remove rule from policy %(name)s: %(reason)s')
293 LOG.error(msg) 294 % {'name': self.initial['name'], 'reason': e})
294 redirect = reverse(self.failure_url) 295 redirect = reverse(self.failure_url)
295 exceptions.handle(request, msg, redirect=redirect) 296 exceptions.handle(request, msg, redirect=redirect)
296 297
297 298
298class RouterInsertionFormBase(forms.SelfHandlingForm): 299class AddRouterToFirewall(forms.SelfHandlingForm):
300 router_ids = forms.MultipleChoiceField(
301 label=_("Add Routers"),
302 required=False,
303 widget=forms.ThemableCheckboxSelectMultiple(),
304 help_text=_("Add selected router(s) to the firewall."))
305
306 failure_url = 'horizon:project:firewalls:index'
299 307
300 def __init__(self, request, *args, **kwargs): 308 def __init__(self, request, *args, **kwargs):
301 super(RouterInsertionFormBase, self).__init__(request, *args, **kwargs) 309 super(AddRouterToFirewall, self).__init__(request, *args, **kwargs)
302 try: 310 try:
303 router_choices = self.get_router_choices(request, kwargs) 311 router_choices = self.get_router_choices(request, kwargs)
304 self.fields['router_ids'].choices = router_choices 312 self.fields['router_ids'].choices = router_choices
305 except Exception as e: 313 except Exception as e:
306 msg = self.init_failure_msg % {'name': self.initial['name'], 314 LOG.error('Failed to retrieve available routers: %s', e)
307 'reason': e} 315 msg = _('Failed to retrieve available routers: %s') % e
308 LOG.error(msg)
309 redirect = reverse(self.failure_url) 316 redirect = reverse(self.failure_url)
310 exceptions.handle(request, msg, redirect=redirect) 317 exceptions.handle(request, msg, redirect=redirect)
311 318
312 @abc.abstractmethod
313 def get_router_choices(self, request, kwargs): 319 def get_router_choices(self, request, kwargs):
314 """Return a list of selectable routers.""" 320 tenant_id = self.request.user.tenant_id
321 routers_list = api.fwaas.firewall_unassociated_routers_list(
322 request, tenant_id)
323 return [(r.id, r.name_or_id) for r in routers_list]
315 324
316 @abc.abstractmethod
317 def get_new_router_ids(self, context): 325 def get_new_router_ids(self, context):
318 """Return a new list of router IDs associated with the firewall.""" 326 existing_router_ids = self.initial['router_ids']
327 add_router_ids = context['router_ids']
328 return add_router_ids + existing_router_ids
319 329
320 def handle(self, request, context): 330 def handle(self, request, context):
321 firewall_id = self.initial['firewall_id'] 331 firewall_id = self.initial['firewall_id']
@@ -323,43 +333,22 @@ class RouterInsertionFormBase(forms.SelfHandlingForm):
323 try: 333 try:
324 body = {'router_ids': self.get_new_router_ids(context)} 334 body = {'router_ids': self.get_new_router_ids(context)}
325 firewall = api.fwaas.firewall_update(request, firewall_id, **body) 335 firewall = api.fwaas.firewall_update(request, firewall_id, **body)
326 msg = self.success_msg % {'firewall': firewall_name_or_id} 336 msg = (_('Router(s) was/were successfully added to firewall '
327 LOG.debug(msg) 337 '%(firewall)s.') %
338 {'firewall': firewall_name_or_id})
328 messages.success(request, msg) 339 messages.success(request, msg)
329 return firewall 340 return firewall
330 except Exception as e: 341 except Exception as e:
331 msg = self.failure_msg % {'name': firewall_name_or_id, 'reason': e} 342 LOG.error('Failed to add router(s) to firewall %(id)s: %(reason)s',
332 LOG.error(msg) 343 {'id': firewall_id, 'reason': e})
344 msg = (_('Failed to add router(s) to firewall %(name)s: '
345 '%(reason)s') %
346 {'name': firewall_name_or_id, 'reason': e})
333 redirect = reverse(self.failure_url) 347 redirect = reverse(self.failure_url)
334 exceptions.handle(request, msg, redirect=redirect) 348 exceptions.handle(request, msg, redirect=redirect)
335 349
336 350
337class AddRouterToFirewall(RouterInsertionFormBase): 351class RemoveRouterFromFirewall(forms.SelfHandlingForm):
338 router_ids = forms.MultipleChoiceField(
339 label=_("Add Routers"),
340 required=False,
341 widget=forms.ThemableCheckboxSelectMultiple(),
342 help_text=_("Add selected router(s) to the firewall."))
343
344 failure_url = 'horizon:project:firewalls:index'
345 success_msg = _('Router(s) was/were successfully added to firewall '
346 '%(firewall)s.')
347 failure_msg = _('Failed to add router(s) to firewall %(name)s: %(reason)s')
348 init_failure_msg = _('Failed to retrieve available routers: %(reason)s')
349
350 def get_router_choices(self, request, kwargs):
351 tenant_id = self.request.user.tenant_id
352 routers_list = api.fwaas.firewall_unassociated_routers_list(
353 request, tenant_id)
354 return [(r.id, r.name_or_id) for r in routers_list]
355
356 def get_new_router_ids(self, context):
357 existing_router_ids = self.initial['router_ids']
358 add_router_ids = context['router_ids']
359 return add_router_ids + existing_router_ids
360
361
362class RemoveRouterFromFirewall(RouterInsertionFormBase):
363 router_ids = forms.MultipleChoiceField( 352 router_ids = forms.MultipleChoiceField(
364 label=_("Associated Routers"), 353 label=_("Associated Routers"),
365 required=False, 354 required=False,
@@ -367,12 +356,22 @@ class RemoveRouterFromFirewall(RouterInsertionFormBase):
367 help_text=_("Unselect the router(s) to be removed from firewall.")) 356 help_text=_("Unselect the router(s) to be removed from firewall."))
368 357
369 failure_url = 'horizon:project:firewalls:index' 358 failure_url = 'horizon:project:firewalls:index'
370 success_msg = _('Router(s) was successfully removed from firewall ' 359
371 '%(firewall)s.') 360 def __init__(self, request, *args, **kwargs):
372 failure_msg = _('Failed to remove router(s) from firewall %(name)s: ' 361 super(RemoveRouterFromFirewall, self).__init__(request,
373 '%(reason)s') 362 *args, **kwargs)
374 init_failure_msg = _('Failed to retrieve current routers in firewall ' 363 try:
375 '%(name)s: %(reason)s') 364 router_choices = self.get_router_choices(request, kwargs)
365 self.fields['router_ids'].choices = router_choices
366 except Exception as e:
367 LOG.error('Failed to retrieve current routers in firewall %(id)s: '
368 '%(reason)s',
369 {'id': self.initial['firewall_id'], 'reason': e})
370 msg = (_('Failed to retrieve current routers in firewall '
371 '%(name)s: %(reason)s') %
372 {'name': self.initial['name'], 'reason': e})
373 redirect = reverse(self.failure_url)
374 exceptions.handle(request, msg, redirect=redirect)
376 375
377 def get_router_choices(self, request, kwargs): 376 def get_router_choices(self, request, kwargs):
378 tenant_id = self.request.user.tenant_id 377 tenant_id = self.request.user.tenant_id
@@ -384,3 +383,23 @@ class RemoveRouterFromFirewall(RouterInsertionFormBase):
384 def get_new_router_ids(self, context): 383 def get_new_router_ids(self, context):
385 # context[router_ids] is router IDs to be kept. 384 # context[router_ids] is router IDs to be kept.
386 return context['router_ids'] 385 return context['router_ids']
386
387 def handle(self, request, context):
388 firewall_id = self.initial['firewall_id']
389 firewall_name_or_id = self.initial['name'] or firewall_id
390 try:
391 body = {'router_ids': self.get_new_router_ids(context)}
392 firewall = api.fwaas.firewall_update(request, firewall_id, **body)
393 msg = (_('Router(s) was successfully removed from firewall '
394 '%(firewall)s.') %
395 {'firewall': firewall_name_or_id})
396 messages.success(request, msg)
397 return firewall
398 except Exception as e:
399 LOG.error('Failed to remove router(s) from firewall %(id)s: '
400 '%(reason)s', {'id': firewall_id, 'reason': e})
401 msg = (_('Failed to remove router(s) from firewall %(name)s: '
402 '%(reason)s') %
403 {'name': firewall_name_or_id, 'reason': e})
404 redirect = reverse(self.failure_url)
405 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/project/firewalls/tables.py b/openstack_dashboard/dashboards/project/firewalls/tables.py
index a917e1d..2817f0a 100644
--- a/openstack_dashboard/dashboards/project/firewalls/tables.py
+++ b/openstack_dashboard/dashboards/project/firewalls/tables.py
@@ -409,7 +409,6 @@ class FirewallsTable(tables.DataTable):
409 'fwaasrouterinsertion'): 409 'fwaasrouterinsertion'):
410 del self.columns['router_ids'] 410 del self.columns['router_ids']
411 except Exception as e: 411 except Exception as e:
412 msg = _('Failed to verify extension support %(reason)s') % { 412 LOG.error('Failed to verify extension support %s', e)
413 'reason': e} 413 msg = _('Failed to verify extension support %s') % e
414 LOG.error(msg)
415 exceptions.handle(request, msg) 414 exceptions.handle(request, msg)
diff --git a/openstack_dashboard/dashboards/project/networks/forms.py b/openstack_dashboard/dashboards/project/networks/forms.py
index f28a211..3a8695e 100644
--- a/openstack_dashboard/dashboards/project/networks/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/forms.py
@@ -65,11 +65,11 @@ class UpdateNetwork(forms.SelfHandlingForm):
65 data['network_id'], 65 data['network_id'],
66 **params) 66 **params)
67 msg = _('Network %s was successfully updated.') % data['name'] 67 msg = _('Network %s was successfully updated.') % data['name']
68 LOG.debug(msg)
69 messages.success(request, msg) 68 messages.success(request, msg)
70 return network 69 return network
71 except Exception: 70 except Exception as e:
71 LOG.info('Failed to update network %(id)s: %(exc)s',
72 {'id': data['network_id'], 'exc': e})
72 msg = _('Failed to update network %s') % data['name'] 73 msg = _('Failed to update network %s') % data['name']
73 LOG.info(msg)
74 redirect = reverse(self.failure_url) 74 redirect = reverse(self.failure_url)
75 exceptions.handle(request, msg, redirect=redirect) 75 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/project/networks/ports/forms.py b/openstack_dashboard/dashboards/project/networks/ports/forms.py
index 1ab9f69..1830c66 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/forms.py
@@ -156,13 +156,13 @@ class CreatePort(forms.SelfHandlingForm):
156 msg = _('Port %s was successfully created.') % port['name'] 156 msg = _('Port %s was successfully created.') % port['name']
157 else: 157 else:
158 msg = _('Port %s was successfully created.') % port['id'] 158 msg = _('Port %s was successfully created.') % port['id']
159 LOG.debug(msg)
160 messages.success(request, msg) 159 messages.success(request, msg)
161 return port 160 return port
162 except Exception: 161 except Exception as e:
163 msg = _('Failed to create a port for network %s') \ 162 LOG.info('Failed to create a port for network %(id)s: %(exc)s',
164 % data['network_id'] 163 {'id': data['network_id'], 'exc': e})
165 LOG.info(msg) 164 msg = (_('Failed to create a port for network %s')
165 % data['network_id'])
166 redirect = reverse(self.failure_url, 166 redirect = reverse(self.failure_url,
167 args=(data['network_id'],)) 167 args=(data['network_id'],))
168 exceptions.handle(request, msg, redirect=redirect) 168 exceptions.handle(request, msg, redirect=redirect)
@@ -248,12 +248,12 @@ class UpdatePort(forms.SelfHandlingForm):
248 admin_state_up=data['admin_state'], 248 admin_state_up=data['admin_state'],
249 **extension_kwargs) 249 **extension_kwargs)
250 msg = _('Port %s was successfully updated.') % data['port_id'] 250 msg = _('Port %s was successfully updated.') % data['port_id']
251 LOG.debug(msg)
252 messages.success(request, msg) 251 messages.success(request, msg)
253 return port 252 return port
254 except Exception: 253 except Exception as e:
254 LOG.info('Failed to update port %(id)s: %(exc)s',
255 {'id': data['port_id'], 'exc': e})
255 msg = _('Failed to update port %s') % data['port_id'] 256 msg = _('Failed to update port %s') % data['port_id']
256 LOG.info(msg)
257 redirect = reverse(self.failure_url, 257 redirect = reverse(self.failure_url,
258 args=[data['network_id']]) 258 args=[data['network_id']])
259 exceptions.handle(request, msg, redirect=redirect) 259 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/project/networks/ports/tables.py b/openstack_dashboard/dashboards/project/networks/ports/tables.py
index 32952de..9299df1 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/tables.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/tables.py
@@ -106,9 +106,10 @@ class DeletePort(policy.PolicyTargetMixin, tables.DeleteAction):
106 failure_url = "horizon:project:networks:detail" 106 failure_url = "horizon:project:networks:detail"
107 try: 107 try:
108 api.neutron.port_delete(request, port_id) 108 api.neutron.port_delete(request, port_id)
109 except Exception: 109 except Exception as e:
110 msg = _('Failed to delete port: %s') % port_id 110 LOG.info('Failed to delete port %(id)s: %(exc)s',
111 LOG.info(msg) 111 {'id': port_id, 'exc': e})
112 msg = _('Failed to delete port %s') % port_id
112 network_id = self.table.kwargs['network_id'] 113 network_id = self.table.kwargs['network_id']
113 redirect = reverse(failure_url, 114 redirect = reverse(failure_url,
114 args=[network_id]) 115 args=[network_id])
diff --git a/openstack_dashboard/dashboards/project/networks/subnets/tables.py b/openstack_dashboard/dashboards/project/networks/subnets/tables.py
index e4676b0..ca00100 100644
--- a/openstack_dashboard/dashboards/project/networks/subnets/tables.py
+++ b/openstack_dashboard/dashboards/project/networks/subnets/tables.py
@@ -79,9 +79,10 @@ class DeleteSubnet(SubnetPolicyTargetMixin, CheckNetworkEditable,
79 def delete(self, request, obj_id): 79 def delete(self, request, obj_id):
80 try: 80 try:
81 api.neutron.subnet_delete(request, obj_id) 81 api.neutron.subnet_delete(request, obj_id)
82 except Exception: 82 except Exception as e:
83 LOG.info('Failed to delete subnet %(id)s: %(exc)s',
84 {'id': obj_id, 'exc': e})
83 msg = _('Failed to delete subnet %s') % obj_id 85 msg = _('Failed to delete subnet %s') % obj_id
84 LOG.info(msg)
85 network_id = self.table.kwargs['network_id'] 86 network_id = self.table.kwargs['network_id']
86 redirect = reverse('horizon:project:networks:detail', 87 redirect = reverse('horizon:project:networks:detail',
87 args=[network_id]) 88 args=[network_id])
diff --git a/openstack_dashboard/dashboards/project/networks/tables.py b/openstack_dashboard/dashboards/project/networks/tables.py
index 21a1e13..103286d 100644
--- a/openstack_dashboard/dashboards/project/networks/tables.py
+++ b/openstack_dashboard/dashboards/project/networks/tables.py
@@ -75,9 +75,10 @@ class DeleteNetwork(policy.PolicyTargetMixin, CheckNetworkEditable,
75 LOG.debug('Deleted subnet %s', subnet_id) 75 LOG.debug('Deleted subnet %s', subnet_id)
76 api.neutron.network_delete(request, network_id) 76 api.neutron.network_delete(request, network_id)
77 LOG.debug('Deleted network %s successfully', network_id) 77 LOG.debug('Deleted network %s successfully', network_id)
78 except Exception: 78 except Exception as e:
79 LOG.info('Failed to delete network %(id)s: %(exc)s',
80 {'id': network_id, 'exc': e})
79 msg = _('Failed to delete network %s') 81 msg = _('Failed to delete network %s')
80 LOG.info(msg, network_id)
81 redirect = reverse("horizon:project:networks:index") 82 redirect = reverse("horizon:project:networks:index")
82 exceptions.handle(request, msg % network_name, redirect=redirect) 83 exceptions.handle(request, msg % network_name, redirect=redirect)
83 84
diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py
index 15a0c3d..78a5c3e 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -471,9 +471,9 @@ class CreateNetwork(workflows.Workflow):
471 network.name_or_id) 471 network.name_or_id)
472 return network 472 return network
473 except Exception as e: 473 except Exception as e:
474 LOG.info('Failed to create network: %s', e)
474 msg = (_('Failed to create network "%(network)s": %(reason)s') % 475 msg = (_('Failed to create network "%(network)s": %(reason)s') %
475 {"network": data['net_name'], "reason": e}) 476 {"network": data['net_name'], "reason": e})
476 LOG.info(msg)
477 redirect = self.get_failure_url() 477 redirect = self.get_failure_url()
478 exceptions.handle(request, msg, redirect=redirect) 478 exceptions.handle(request, msg, redirect=redirect)
479 return False 479 return False
@@ -562,15 +562,17 @@ class CreateNetwork(workflows.Workflow):
562 """Delete the created network when subnet creation failed.""" 562 """Delete the created network when subnet creation failed."""
563 try: 563 try:
564 api.neutron.network_delete(request, network.id) 564 api.neutron.network_delete(request, network.id)
565 LOG.debug('Delete the created network %s '
566 'due to subnet creation failure.', network.id)
565 msg = _('Delete the created network "%s" ' 567 msg = _('Delete the created network "%s" '
566 'due to subnet creation failure.') % network.name 568 'due to subnet creation failure.') % network.name
567 LOG.debug(msg)
568 redirect = self.get_failure_url() 569 redirect = self.get_failure_url()
569 messages.info(request, msg) 570 messages.info(request, msg)
570 raise exceptions.Http302(redirect) 571 raise exceptions.Http302(redirect)
571 except Exception: 572 except Exception as e:
573 LOG.info('Failed to delete network %(id)s: %(exc)s',
574 {'id': network.id, 'exc': e})
572 msg = _('Failed to delete network "%s"') % network.name 575 msg = _('Failed to delete network "%s"') % network.name
573 LOG.info(msg)
574 redirect = self.get_failure_url() 576 redirect = self.get_failure_url()
575 exceptions.handle(request, msg, redirect=redirect) 577 exceptions.handle(request, msg, redirect=redirect)
576 578
diff --git a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py
index ae6ab70..2345f2f 100644
--- a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/forms.py
@@ -43,18 +43,18 @@ class AddRouterRoute(forms.SelfHandlingForm):
43 router_id, 43 router_id,
44 route) 44 route)
45 msg = _('Static route added') 45 msg = _('Static route added')
46 LOG.debug(msg)
47 messages.success(request, msg) 46 messages.success(request, msg)
48 return True 47 return True
49 except neutron_exc.BadRequest as e: 48 except neutron_exc.BadRequest as e:
50 msg = (_('Invalid format for routes : %s') % e) 49 LOG.info('Invalid format for routes %(route)s: %(exc)s',
51 LOG.info(msg) 50 {'route': route, 'exc': e})
51 msg = _('Invalid format for routes: %s') % e
52 messages.error(request, msg) 52 messages.error(request, msg)
53 redirect = reverse(self.failure_url, args=[router_id]) 53 redirect = reverse(self.failure_url, args=[router_id])
54 exceptions.handle(request, msg, redirect=redirect) 54 exceptions.handle(request, msg, redirect=redirect)
55 except Exception as e: 55 except Exception as e:
56 msg = (_('Failed to add route : %s') % e) 56 LOG.info('Failed to add route: %s', e)
57 LOG.info(msg) 57 msg = _('Failed to add route: %s') % e
58 messages.error(request, msg) 58 messages.error(request, msg)
59 redirect = reverse(self.failure_url, args=[router_id]) 59 redirect = reverse(self.failure_url, args=[router_id])
60 exceptions.handle(request, msg, redirect=redirect) 60 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tabs.py b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tabs.py
index cc0f01f..d1b17fb 100644
--- a/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tabs.py
+++ b/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tabs.py
@@ -36,9 +36,9 @@ class ExtraRoutesTab(tabs.TableTab):
36 def allowed(self, request): 36 def allowed(self, request):
37 try: 37 try:
38 return api.is_extension_supported(request, 'extraroute') 38 return api.is_extension_supported(request, 'extraroute')
39 except Exception: 39 except Exception as e:
40 LOG.info(_("Failed to check if Neutron extraroute extension is " 40 LOG.info("Failed to check if Neutron extraroute extension is "
41 "supported")) 41 "supported: %s", e)
42 return False 42 return False
43 43
44 def get_extra_routes_data(self): 44 def get_extra_routes_data(self):
diff --git a/openstack_dashboard/dashboards/project/routers/forms.py b/openstack_dashboard/dashboards/project/routers/forms.py
index 9b5e726..7598dbe 100644
--- a/openstack_dashboard/dashboards/project/routers/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/forms.py
@@ -75,9 +75,9 @@ class CreateForm(forms.SelfHandlingForm):
75 search_opts = {'router:external': True} 75 search_opts = {'router:external': True}
76 try: 76 try:
77 networks = api.neutron.network_list(request, **search_opts) 77 networks = api.neutron.network_list(request, **search_opts)
78 except Exception: 78 except Exception as e:
79 LOG.info('Failed to get network list: %s', e)
79 msg = _('Failed to get network list.') 80 msg = _('Failed to get network list.')
80 LOG.info(msg)
81 messages.warning(request, msg) 81 messages.warning(request, msg)
82 networks = [] 82 networks = []
83 83
@@ -104,11 +104,11 @@ class CreateForm(forms.SelfHandlingForm):
104 messages.success(request, message) 104 messages.success(request, message)
105 return router 105 return router
106 except Exception as exc: 106 except Exception as exc:
107 LOG.info('Failed to create router: %s', exc)
107 if exc.status_code == 409: 108 if exc.status_code == 409:
108 msg = _('Quota exceeded for resource router.') 109 msg = _('Quota exceeded for resource router.')
109 else: 110 else:
110 msg = _('Failed to create router "%s".') % data['name'] 111 msg = _('Failed to create router "%s".') % data['name']
111 LOG.info(msg)
112 redirect = reverse(self.failure_url) 112 redirect = reverse(self.failure_url)
113 exceptions.handle(request, msg, redirect=redirect) 113 exceptions.handle(request, msg, redirect=redirect)
114 return False 114 return False
@@ -164,10 +164,10 @@ class UpdateForm(forms.SelfHandlingForm):
164 router = api.neutron.router_update(request, data['router_id'], 164 router = api.neutron.router_update(request, data['router_id'],
165 **params) 165 **params)
166 msg = _('Router %s was successfully updated.') % data['name'] 166 msg = _('Router %s was successfully updated.') % data['name']
167 LOG.debug(msg)
168 messages.success(request, msg) 167 messages.success(request, msg)
169 return router 168 return router
170 except Exception: 169 except Exception as exc:
170 LOG.info('Failed to update router %(id)s: %(exc)s',
171 {'id': data['router_id'], 'exc': exc})
171 msg = _('Failed to update router %s') % data['name'] 172 msg = _('Failed to update router %s') % data['name']
172 LOG.info(msg)
173 exceptions.handle(request, msg, redirect=self.redirect_url) 173 exceptions.handle(request, msg, redirect=self.redirect_url)
diff --git a/openstack_dashboard/dashboards/project/routers/ports/forms.py b/openstack_dashboard/dashboards/project/routers/ports/forms.py
index 9184be2..54a0b1d 100644
--- a/openstack_dashboard/dashboards/project/routers/ports/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/ports/forms.py
@@ -59,8 +59,8 @@ class AddInterface(forms.SelfHandlingForm):
59 router_subnet_ids = [fixed_ip["subnet_id"] for port in ports 59 router_subnet_ids = [fixed_ip["subnet_id"] for port in ports
60 for fixed_ip in port.fixed_ips] 60 for fixed_ip in port.fixed_ips]
61 except Exception as e: 61 except Exception as e:
62 msg = _('Failed to get network list %s') % e 62 LOG.info('Failed to get network list: %s', e)
63 LOG.info(msg) 63 msg = _('Failed to get network list: %s') % e
64 messages.error(request, msg) 64 messages.error(request, msg)
65 if router_id: 65 if router_id:
66 redirect = reverse(self.failure_url, args=[router_id]) 66 redirect = reverse(self.failure_url, args=[router_id])
@@ -92,7 +92,6 @@ class AddInterface(forms.SelfHandlingForm):
92 msg = _('Interface added') 92 msg = _('Interface added')
93 if port: 93 if port:
94 msg += ' ' + port.fixed_ips[0]['ip_address'] 94 msg += ' ' + port.fixed_ips[0]['ip_address']
95 LOG.debug(msg)
96 messages.success(request, msg) 95 messages.success(request, msg)
97 return True 96 return True
98 97
@@ -136,17 +135,18 @@ class AddInterface(forms.SelfHandlingForm):
136 return port 135 return port
137 136
138 def _handle_error(self, request, router_id, reason): 137 def _handle_error(self, request, router_id, reason):
139 msg = _('Failed to add_interface: %s') % reason 138 LOG.info('Failed to add_interface: %s', reason)
140 LOG.info(msg) 139 msg = _('Failed to add interface: %s') % reason
141 redirect = reverse(self.failure_url, args=[router_id]) 140 redirect = reverse(self.failure_url, args=[router_id])
142 exceptions.handle(request, msg, redirect=redirect) 141 exceptions.handle(request, msg, redirect=redirect)
143 142
144 def _delete_port(self, request, port): 143 def _delete_port(self, request, port):
145 try: 144 try:
146 api.neutron.port_delete(request, port.id) 145 api.neutron.port_delete(request, port.id)
147 except Exception: 146 except Exception as e:
147 LOG.info('Failed to delete port %(id)s: %(exc)s',
148 {'id': port.id, 'exc': e})
148 msg = _('Failed to delete port %s') % port.id 149 msg = _('Failed to delete port %s') % port.id
149 LOG.info(msg)
150 exceptions.handle(request, msg) 150 exceptions.handle(request, msg)
151 151
152 152
@@ -170,8 +170,8 @@ class SetGatewayForm(forms.SelfHandlingForm):
170 try: 170 try:
171 networks = api.neutron.network_list(request, **search_opts) 171 networks = api.neutron.network_list(request, **search_opts)
172 except Exception as e: 172 except Exception as e:
173 msg = _('Failed to get network list %s') % e 173 LOG.info('Faield to get network list: %s', e)
174 LOG.info(msg) 174 msg = _('Failed to get network list: %s') % e
175 messages.error(request, msg) 175 messages.error(request, msg)
176 redirect = reverse(self.failure_url) 176 redirect = reverse(self.failure_url)
177 exceptions.handle(request, msg, redirect=redirect) 177 exceptions.handle(request, msg, redirect=redirect)
@@ -190,11 +190,11 @@ class SetGatewayForm(forms.SelfHandlingForm):
190 data['router_id'], 190 data['router_id'],
191 data['network_id']) 191 data['network_id'])
192 msg = _('Gateway interface is added') 192 msg = _('Gateway interface is added')
193 LOG.debug(msg)
194 messages.success(request, msg) 193 messages.success(request, msg)
195 return True 194 return True
196 except Exception as e: 195 except Exception as e:
197 msg = _('Failed to set gateway %s') % e 196 LOG.info('Failed to set gateway to router %(id)s: %(exc)s',
198 LOG.info(msg) 197 {'id': data['router_id'], 'exc': e})
198 msg = _('Failed to set gateway: %s') % e
199 redirect = reverse(self.failure_url) 199 redirect = reverse(self.failure_url)
200 exceptions.handle(request, msg, redirect=redirect) 200 exceptions.handle(request, msg, redirect=redirect)
diff --git a/openstack_dashboard/dashboards/project/routers/ports/tables.py b/openstack_dashboard/dashboards/project/routers/ports/tables.py
index 7f1419b..87064a8 100644
--- a/openstack_dashboard/dashboards/project/routers/ports/tables.py
+++ b/openstack_dashboard/dashboards/project/routers/ports/tables.py
@@ -81,9 +81,10 @@ class RemoveInterface(policy.PolicyTargetMixin, tables.DeleteAction):
81 api.neutron.router_remove_interface(request, 81 api.neutron.router_remove_interface(request,
82 router_id, 82 router_id,
83 port_id=obj_id) 83 port_id=obj_id)
84 except Exception: 84 except Exception as e:
85 LOG.info('Failed to delete interface %(id)s: %(exc)s',
86 {'id': obj_id, 'exc': e})
85 msg = _('Failed to delete interface %s') % obj_id 87 msg = _('Failed to delete interface %s') % obj_id
86 LOG.info(msg)
87 router_id = self.table.kwargs['router_id'] 88 router_id = self.table.kwargs['router_id']
88 redirect = reverse(self.failure_url, 89 redirect = reverse(self.failure_url,
89 args=[router_id]) 90 args=[router_id])
diff --git a/openstack_dashboard/dashboards/project/routers/tables.py b/openstack_dashboard/dashboards/project/routers/tables.py
index 1cb493b..a97c4e8 100644
--- a/openstack_dashboard/dashboards/project/routers/tables.py
+++ b/openstack_dashboard/dashboards/project/routers/tables.py
@@ -64,16 +64,23 @@ class DeleteRouter(policy.PolicyTargetMixin, tables.DeleteAction):
64 port_id=port.id) 64 port_id=port.id)
65 api.neutron.router_delete(request, obj_id) 65 api.neutron.router_delete(request, obj_id)
66 except q_ext.NeutronClientException as e: 66 except q_ext.NeutronClientException as e:
67 msg = _('Unable to delete router "%s"') % e 67 # TODO(amotoki): Revisit why Http302 needs to be raised.
68 LOG.info(msg) 68 # We have this pattern ONLY HERE.
69 # Can't we merge two except clauses?
70 LOG.info('Unable to delete router %(id)s: %(exc)s',
71 {'id': obj_id, 'exc': e})
72 obj = self.table.get_object_by_id(obj_id)
73 name = self.table.get_object_display(obj)
74 msg = _('Unable to delete router "%s"') % name
69 messages.error(request, msg) 75 messages.error(request, msg)
70 redirect = reverse(self.redirect_url) 76 redirect = reverse(self.redirect_url)
71 raise exceptions.Http302(redirect, message=msg) 77 raise exceptions.Http302(redirect, message=msg)
72 except Exception: 78 except Exception as e:
79 LOG.info('Unable to delete router %(id)s: %(exc)s',
80 {'id': obj_id, 'exc': e})
73 obj = self.table.get_object_by_id(obj_id) 81 obj = self.table.get_object_by_id(obj_id)
74 name = self.table.get_object_display(obj) 82 name = self.table.get_object_display(obj)
75 msg = _('Unable to delete router "%s"') % name 83 msg = _('Unable to delete router "%s"') % name
76 LOG.info(msg)
77 exceptions.handle(request, msg) 84 exceptions.handle(request, msg)
78 85
79 def allowed(self, request, router=None): 86 def allowed(self, request, router=None):
@@ -158,10 +165,11 @@ class ClearGateway(policy.PolicyTargetMixin, tables.BatchAction):
158 try: 165 try:
159 api.neutron.router_remove_gateway(request, obj_id) 166 api.neutron.router_remove_gateway(request, obj_id)
160 except Exception as e: 167 except Exception as e:
168 LOG.info('Unable to clear gateway for router %(id)s: %(exc)s',
169 {'id': obj_id, 'exc': e})
161 msg = (_('Unable to clear gateway for router ' 170 msg = (_('Unable to clear gateway for router '
162 '"%(name)s": "%(msg)s"') 171 '"%(name)s": "%(msg)s"')
163 % {"name": name, "msg": e}) 172 % {"name": name, "msg": e})
164 LOG.info(msg)
165 redirect = reverse(self.redirect_url) 173 redirect = reverse(self.redirect_url)
166 exceptions.handle(request, msg, redirect=redirect) 174 exceptions.handle(request, msg, redirect=redirect)
167 175
diff --git a/openstack_dashboard/dashboards/project/vpn/forms.py b/openstack_dashboard/dashboards/project/vpn/forms.py
index 1ada5d8..cd2a937 100644
--- a/openstack_dashboard/dashboards/project/vpn/forms.py
+++ b/openstack_dashboard/dashboards/project/vpn/forms.py
@@ -52,12 +52,12 @@ class UpdateVPNService(forms.SelfHandlingForm):
52 request, context['vpnservice_id'], **data) 52 request, context['vpnservice_id'], **data)
53 msg = (_('VPN Service %s was successfully updated.') 53 msg = (_('VPN Service %s was successfully updated.')
54 % context['name']) 54 % context['name'])
55 LOG.debug(msg)
56 messages.success(request, msg) 55 messages.success(request, msg)
57 return vpnservice 56 return vpnservice
58 except Exception as e: 57 except Exception as e:
58 LOG.info('Failed to update VPN Service %(id)s: %(exc)s',
59 {'id': context['vpnservice_id'], 'exc': e})
59 msg = _('Failed to update VPN Service %s') % context['name'] 60 msg = _('Failed to update VPN Service %s') % context['name']
60 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
61 redirect = reverse(self.failure_url) 61 redirect = reverse(self.failure_url)
62 exceptions.handle(request, msg, redirect=redirect) 62 exceptions.handle(request, msg, redirect=redirect)
63 63
@@ -131,12 +131,12 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
131 request, context['ikepolicy_id'], **data) 131 request, context['ikepolicy_id'], **data)
132 msg = (_('IKE Policy %s was successfully updated.') 132 msg = (_('IKE Policy %s was successfully updated.')
133 % context['name']) 133 % context['name'])
134 LOG.debug(msg)
135 messages.success(request, msg) 134 messages.success(request, msg)
136 return ikepolicy 135 return ikepolicy
137 except Exception as e: 136 except Exception as e:
137 LOG.info('Failed to update IKE Policy %(id)s: %(exc)s',
138 {'id': context['ikepolicy_id'], 'exc': e})
138 msg = _('Failed to update IKE Policy %s') % context['name'] 139 msg = _('Failed to update IKE Policy %s') % context['name']
139 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
140 redirect = reverse(self.failure_url) 140 redirect = reverse(self.failure_url)
141 exceptions.handle(request, msg, redirect=redirect) 141 exceptions.handle(request, msg, redirect=redirect)
142 142
@@ -209,12 +209,12 @@ class UpdateIPSecPolicy(forms.SelfHandlingForm):
209 request, context['ipsecpolicy_id'], **data) 209 request, context['ipsecpolicy_id'], **data)
210 msg = (_('IPSec Policy %s was successfully updated.') 210 msg = (_('IPSec Policy %s was successfully updated.')
211 % context['name']) 211 % context['name'])
212 LOG.debug(msg)
213 messages.success(request, msg) 212 messages.success(request, msg)
214 return ipsecpolicy 213 return ipsecpolicy
215 except Exception as e: 214 except Exception as e:
215 LOG.info('Failed to update IPSec Policy %(id)s: %(exc)s',
216 {'id': context['ipsecpolicy_id'], 'exc': e})
216 msg = _('Failed to update IPSec Policy %s') % context['name'] 217 msg = _('Failed to update IPSec Policy %s') % context['name']
217 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
218 redirect = reverse(self.failure_url) 218 redirect = reverse(self.failure_url)
219 exceptions.handle(request, msg, redirect=redirect) 219 exceptions.handle(request, msg, redirect=redirect)
220 220
@@ -318,12 +318,12 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
318 request, context['ipsecsiteconnection_id'], **data) 318 request, context['ipsecsiteconnection_id'], **data)
319 msg = (_('IPSec Site Connection %s was successfully updated.') 319 msg = (_('IPSec Site Connection %s was successfully updated.')
320 % context['name']) 320 % context['name'])
321 LOG.debug(msg)
322 messages.success(request, msg) 321 messages.success(request, msg)
323 return ipsecsiteconnection 322 return ipsecsiteconnection
324 except Exception as e: 323 except Exception as e:
324 LOG.info('Failed to update IPSec Site Connection %(id)s: %(exc)s',
325 {'id': context['ipsecsiteconnection_id'], 'exc': e})
325 msg = (_('Failed to update IPSec Site Connection %s') 326 msg = (_('Failed to update IPSec Site Connection %s')
326 % context['name']) 327 % context['name'])
327 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
328 redirect = reverse(self.failure_url) 328 redirect = reverse(self.failure_url)
329 exceptions.handle(request, msg, redirect=redirect) 329 exceptions.handle(request, msg, redirect=redirect)