summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-27 22:39:12 +0000
committerGerrit Code Review <review@openstack.org>2017-04-27 22:39:12 +0000
commit30a00a0dc3a7af3b15a2677be9f7ba2702264ac8 (patch)
tree71848d49505dec0221e9b583ab40352fb5ebb244
parent86028ea5a67bbce4ad6c1746e92c6ed7c97b7624 (diff)
parentced987815d6a091fbcedbd4c319395038cb3f976 (diff)
Merge "Ensure log messages are not translated"
-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 0a57d9b..3c6ad36 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 a226538..ef2bede 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 1ec2c4b..3c06a30 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 2796d13..d636c80 100644
--- a/openstack_dashboard/dashboards/admin/networks/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/forms.py
@@ -262,7 +262,7 @@ class CreateNetwork(forms.SelfHandlingForm):
262 params['provider:segmentation_id'] = ( 262 params['provider:segmentation_id'] = (
263 data['segmentation_id']) 263 data['segmentation_id'])
264 network = api.neutron.network_create(request, **params) 264 network = api.neutron.network_create(request, **params)
265 LOG.debug(_('Network %s was successfully created.'), data['name']) 265 LOG.debug('Network %s was successfully created.', data['name'])
266 return network 266 return network
267 except Exception: 267 except Exception:
268 redirect = reverse('horizon:admin:networks:index') 268 redirect = reverse('horizon:admin:networks:index')
@@ -327,11 +327,11 @@ class UpdateNetwork(forms.SelfHandlingForm):
327 self.initial['network_id'], 327 self.initial['network_id'],
328 **params) 328 **params)
329 msg = _('Network %s was successfully updated.') % data['name'] 329 msg = _('Network %s was successfully updated.') % data['name']
330 LOG.debug(msg)
331 messages.success(request, msg) 330 messages.success(request, msg)
332 return network 331 return network
333 except Exception: 332 except Exception as e:
333 LOG.info('Failed to update network %(id)s: %(exc)s',
334 {'id': self.initial['network_id'], 'exc': e})
334 msg = _('Failed to update network %s') % data['name'] 335 msg = _('Failed to update network %s') % data['name']
335 LOG.info(msg)
336 redirect = reverse(self.failure_url) 336 redirect = reverse(self.failure_url)
337 exceptions.handle(request, msg, redirect=redirect) 337 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 6fd9d8f..db2059b 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/forms.py
@@ -127,15 +127,15 @@ class CreatePort(project_forms.CreatePort):
127 127
128 port = api.neutron.port_create(request, **params) 128 port = api.neutron.port_create(request, **params)
129 msg = _('Port %s was successfully created.') % port['id'] 129 msg = _('Port %s was successfully created.') % port['id']
130 LOG.debug(msg)
131 messages.success(request, msg) 130 messages.success(request, msg)
132 return port 131 return port
133 except Exception: 132 except Exception as e:
134 msg = _('Failed to create a port for network %s') \ 133 net_id = data['network_id']
135 % data['network_id'] 134 LOG.info('Failed to create a port for network %(id)s: %(exc)s',
136 LOG.info(msg) 135 {'id': net_id, 'exc': e})
136 msg = _('Failed to create a port for network %s') % net_id
137 redirect = reverse(self.failure_url, 137 redirect = reverse(self.failure_url,
138 args=(data['network_id'],)) 138 args=(net_id,))
139 exceptions.handle(request, msg, redirect=redirect) 139 exceptions.handle(request, msg, redirect=redirect)
140 140
141 141
@@ -187,12 +187,12 @@ class UpdatePort(project_forms.UpdatePort):
187 mac_address=data['mac_address'], 187 mac_address=data['mac_address'],
188 **extension_kwargs) 188 **extension_kwargs)
189 msg = _('Port %s was successfully updated.') % data['port_id'] 189 msg = _('Port %s was successfully updated.') % data['port_id']
190 LOG.debug(msg)
191 messages.success(request, msg) 190 messages.success(request, msg)
192 return port 191 return port
193 except Exception: 192 except Exception as e:
193 LOG.info('Failed to update port %(id)s: %(exc)s',
194 {'id': data['port_id'], 'exc': e})
194 msg = _('Failed to update port %s') % data['port_id'] 195 msg = _('Failed to update port %s') % data['port_id']
195 LOG.info(msg)
196 redirect = reverse(self.failure_url, 196 redirect = reverse(self.failure_url,
197 args=[data['network_id']]) 197 args=[data['network_id']])
198 exceptions.handle(request, msg, redirect=redirect) 198 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 7fdb5e4..fc7c15b 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 9660288..fc35703 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 ec50456..367590b 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
@@ -167,13 +166,13 @@ class UpdateFirewall(forms.SelfHandlingForm):
167 firewall = api.fwaas.firewall_update(request, firewall_id, 166 firewall = api.fwaas.firewall_update(request, firewall_id,
168 **context) 167 **context)
169 msg = _('Firewall %s was successfully updated.') % name_or_id 168 msg = _('Firewall %s was successfully updated.') % name_or_id
170 LOG.debug(msg)
171 messages.success(request, msg) 169 messages.success(request, msg)
172 return firewall 170 return firewall
173 except Exception as e: 171 except Exception as e:
174 msg = _('Failed to update firewall %(name)s: %(reason)s') % { 172 LOG.error('Failed to update firewall %(id)s: %(reason)s',
175 'name': name_or_id, 'reason': e} 173 {'id': firewall_id, 'reason': e})
176 LOG.error(msg) 174 msg = (_('Failed to update firewall %(name)s: %(reason)s') %
175 {'name': name_or_id, 'reason': e})
177 redirect = reverse(self.failure_url) 176 redirect = reverse(self.failure_url)
178 exceptions.handle(request, msg, redirect=redirect) 177 exceptions.handle(request, msg, redirect=redirect)
179 178
@@ -207,8 +206,8 @@ class InsertRuleToPolicy(forms.SelfHandlingForm):
207 current_choices = [(r.id, r.name_or_id) for r in current_rules] 206 current_choices = [(r.id, r.name_or_id) for r in current_rules]
208 207
209 except Exception as e: 208 except Exception as e:
209 LOG.error('Failed to retrieve available rules: %s', e)
210 msg = _('Failed to retrieve available rules: %s') % e 210 msg = _('Failed to retrieve available rules: %s') % e
211 LOG.error(msg)
212 redirect = reverse(self.failure_url) 211 redirect = reverse(self.failure_url)
213 exceptions.handle(request, msg, redirect=redirect) 212 exceptions.handle(request, msg, redirect=redirect)
214 213
@@ -230,13 +229,13 @@ class InsertRuleToPolicy(forms.SelfHandlingForm):
230 '%(policy)s.') % { 229 '%(policy)s.') % {
231 'rule': insert_rule.name or insert_rule.id, 230 'rule': insert_rule.name or insert_rule.id,
232 'policy': policy_name_or_id} 231 'policy': policy_name_or_id}
233 LOG.debug(msg)
234 messages.success(request, msg) 232 messages.success(request, msg)
235 return policy 233 return policy
236 except Exception as e: 234 except Exception as e:
237 msg = _('Failed to insert rule to policy %(name)s: %(reason)s') % { 235 LOG.error('Failed to insert rule to policy %(id)s: %(reason)s',
238 'name': policy_id, 'reason': e} 236 {'id': policy_id, 'reason': e})
239 LOG.error(msg) 237 msg = (_('Failed to insert rule to policy %(name)s: %(reason)s') %
238 {'name': policy_id, 'reason': e})
240 redirect = reverse(self.failure_url) 239 redirect = reverse(self.failure_url)
241 exceptions.handle(request, msg, redirect=redirect) 240 exceptions.handle(request, msg, redirect=redirect)
242 241
@@ -260,9 +259,12 @@ class RemoveRuleFromPolicy(forms.SelfHandlingForm):
260 259
261 current_choices = [(r.id, r.name_or_id) for r in current_rules] 260 current_choices = [(r.id, r.name_or_id) for r in current_rules]
262 except Exception as e: 261 except Exception as e:
263 msg = _('Failed to retrieve current rules in policy %(name)s: ' 262 LOG.error('Failed to retrieve current rules in policy %(id)s: '
264 '%(reason)s') % {'name': self.initial['name'], 'reason': e} 263 '%(reason)s',
265 LOG.error(msg) 264 {'id': self.initial['policy_id'], 'reason': e})
265 msg = (_('Failed to retrieve current rules in policy %(name)s: '
266 '%(reason)s') %
267 {'name': self.initial['name'], 'reason': e})
266 redirect = reverse(self.failure_url) 268 redirect = reverse(self.failure_url)
267 exceptions.handle(request, msg, redirect=redirect) 269 exceptions.handle(request, msg, redirect=redirect)
268 270
@@ -280,39 +282,47 @@ class RemoveRuleFromPolicy(forms.SelfHandlingForm):
280 '%(policy)s.') % { 282 '%(policy)s.') % {
281 'rule': remove_rule.name or remove_rule.id, 283 'rule': remove_rule.name or remove_rule.id,
282 'policy': policy_name_or_id} 284 'policy': policy_name_or_id}
283 LOG.debug(msg)
284 messages.success(request, msg) 285 messages.success(request, msg)
285 return policy 286 return policy
286 except Exception as e: 287 except Exception as e:
287 msg = _('Failed to remove rule from policy %(name)s: ' 288 LOG.error('Failed to remove rule from policy %(id)s: %(reason)s',
288 '%(reason)s') % {'name': self.initial['name'], 289 {'id': policy_id, 'reason': e})
289 'reason': e} 290 msg = (_('Failed to remove rule from policy %(name)s: %(reason)s')
290 LOG.error(msg) 291 % {'name': self.initial['name'], 'reason': e})
291 redirect = reverse(self.failure_url) 292 redirect = reverse(self.failure_url)
292 exceptions.handle(request, msg, redirect=redirect) 293 exceptions.handle(request, msg, redirect=redirect)
293 294
294 295
295class RouterInsertionFormBase(forms.SelfHandlingForm): 296class AddRouterToFirewall(forms.SelfHandlingForm):
297 router_ids = forms.MultipleChoiceField(
298 label=_("Add Routers"),
299 required=False,
300 widget=forms.ThemableCheckboxSelectMultiple(),
301 help_text=_("Add selected router(s) to the firewall."))
302
303 failure_url = 'horizon:project:firewalls:index'
296 304
297 def __init__(self, request, *args, **kwargs): 305 def __init__(self, request, *args, **kwargs):
298 super(RouterInsertionFormBase, self).__init__(request, *args, **kwargs) 306 super(AddRouterToFirewall, self).__init__(request, *args, **kwargs)
299 try: 307 try:
300 router_choices = self.get_router_choices(request, kwargs) 308 router_choices = self.get_router_choices(request, kwargs)
301 self.fields['router_ids'].choices = router_choices 309 self.fields['router_ids'].choices = router_choices
302 except Exception as e: 310 except Exception as e:
303 msg = self.init_failure_msg % {'name': self.initial['name'], 311 LOG.error('Failed to retrieve available routers: %s', e)
304 'reason': e} 312 msg = _('Failed to retrieve available routers: %s') % e
305 LOG.error(msg)
306 redirect = reverse(self.failure_url) 313 redirect = reverse(self.failure_url)
307 exceptions.handle(request, msg, redirect=redirect) 314 exceptions.handle(request, msg, redirect=redirect)
308 315
309 @abc.abstractmethod
310 def get_router_choices(self, request, kwargs): 316 def get_router_choices(self, request, kwargs):
311 """Return a list of selectable routers.""" 317 tenant_id = self.request.user.tenant_id
318 routers_list = api.fwaas.firewall_unassociated_routers_list(
319 request, tenant_id)
320 return [(r.id, r.name_or_id) for r in routers_list]
312 321
313 @abc.abstractmethod
314 def get_new_router_ids(self, context): 322 def get_new_router_ids(self, context):
315 """Return a new list of router IDs associated with the firewall.""" 323 existing_router_ids = self.initial['router_ids']
324 add_router_ids = context['router_ids']
325 return add_router_ids + existing_router_ids
316 326
317 def handle(self, request, context): 327 def handle(self, request, context):
318 firewall_id = self.initial['firewall_id'] 328 firewall_id = self.initial['firewall_id']
@@ -320,43 +330,22 @@ class RouterInsertionFormBase(forms.SelfHandlingForm):
320 try: 330 try:
321 body = {'router_ids': self.get_new_router_ids(context)} 331 body = {'router_ids': self.get_new_router_ids(context)}
322 firewall = api.fwaas.firewall_update(request, firewall_id, **body) 332 firewall = api.fwaas.firewall_update(request, firewall_id, **body)
323 msg = self.success_msg % {'firewall': firewall_name_or_id} 333 msg = (_('Router(s) was/were successfully added to firewall '
324 LOG.debug(msg) 334 '%(firewall)s.') %
335 {'firewall': firewall_name_or_id})
325 messages.success(request, msg) 336 messages.success(request, msg)
326 return firewall 337 return firewall
327 except Exception as e: 338 except Exception as e:
328 msg = self.failure_msg % {'name': firewall_name_or_id, 'reason': e} 339 LOG.error('Failed to add router(s) to firewall %(id)s: %(reason)s',
329 LOG.error(msg) 340 {'id': firewall_id, 'reason': e})
341 msg = (_('Failed to add router(s) to firewall %(name)s: '
342 '%(reason)s') %
343 {'name': firewall_name_or_id, 'reason': e})
330 redirect = reverse(self.failure_url) 344 redirect = reverse(self.failure_url)
331 exceptions.handle(request, msg, redirect=redirect) 345 exceptions.handle(request, msg, redirect=redirect)
332 346
333 347
334class AddRouterToFirewall(RouterInsertionFormBase): 348class RemoveRouterFromFirewall(forms.SelfHandlingForm):
335 router_ids = forms.MultipleChoiceField(
336 label=_("Add Routers"),
337 required=False,
338 widget=forms.ThemableCheckboxSelectMultiple(),
339 help_text=_("Add selected router(s) to the firewall."))
340
341 failure_url = 'horizon:project:firewalls:index'
342 success_msg = _('Router(s) was/were successfully added to firewall '
343 '%(firewall)s.')
344 failure_msg = _('Failed to add router(s) to firewall %(name)s: %(reason)s')
345 init_failure_msg = _('Failed to retrieve available routers: %(reason)s')
346
347 def get_router_choices(self, request, kwargs):
348 tenant_id = self.request.user.tenant_id
349 routers_list = api.fwaas.firewall_unassociated_routers_list(
350 request, tenant_id)
351 return [(r.id, r.name_or_id) for r in routers_list]
352
353 def get_new_router_ids(self, context):
354 existing_router_ids = self.initial['router_ids']
355 add_router_ids = context['router_ids']
356 return add_router_ids + existing_router_ids
357
358
359class RemoveRouterFromFirewall(RouterInsertionFormBase):
360 router_ids = forms.MultipleChoiceField( 349 router_ids = forms.MultipleChoiceField(
361 label=_("Associated Routers"), 350 label=_("Associated Routers"),
362 required=False, 351 required=False,
@@ -364,12 +353,22 @@ class RemoveRouterFromFirewall(RouterInsertionFormBase):
364 help_text=_("Unselect the router(s) to be removed from firewall.")) 353 help_text=_("Unselect the router(s) to be removed from firewall."))
365 354
366 failure_url = 'horizon:project:firewalls:index' 355 failure_url = 'horizon:project:firewalls:index'
367 success_msg = _('Router(s) was successfully removed from firewall ' 356
368 '%(firewall)s.') 357 def __init__(self, request, *args, **kwargs):
369 failure_msg = _('Failed to remove router(s) from firewall %(name)s: ' 358 super(RemoveRouterFromFirewall, self).__init__(request,
370 '%(reason)s') 359 *args, **kwargs)
371 init_failure_msg = _('Failed to retrieve current routers in firewall ' 360 try:
372 '%(name)s: %(reason)s') 361 router_choices = self.get_router_choices(request, kwargs)
362 self.fields['router_ids'].choices = router_choices
363 except Exception as e:
364 LOG.error('Failed to retrieve current routers in firewall %(id)s: '
365 '%(reason)s',
366 {'id': self.initial['firewall_id'], 'reason': e})
367 msg = (_('Failed to retrieve current routers in firewall '
368 '%(name)s: %(reason)s') %
369 {'name': self.initial['name'], 'reason': e})
370 redirect = reverse(self.failure_url)
371 exceptions.handle(request, msg, redirect=redirect)
373 372
374 def get_router_choices(self, request, kwargs): 373 def get_router_choices(self, request, kwargs):
375 tenant_id = self.request.user.tenant_id 374 tenant_id = self.request.user.tenant_id
@@ -381,3 +380,23 @@ class RemoveRouterFromFirewall(RouterInsertionFormBase):
381 def get_new_router_ids(self, context): 380 def get_new_router_ids(self, context):
382 # context[router_ids] is router IDs to be kept. 381 # context[router_ids] is router IDs to be kept.
383 return context['router_ids'] 382 return context['router_ids']
383
384 def handle(self, request, context):
385 firewall_id = self.initial['firewall_id']
386 firewall_name_or_id = self.initial['name'] or firewall_id
387 try:
388 body = {'router_ids': self.get_new_router_ids(context)}
389 firewall = api.fwaas.firewall_update(request, firewall_id, **body)
390 msg = (_('Router(s) was successfully removed from firewall '
391 '%(firewall)s.') %
392 {'firewall': firewall_name_or_id})
393 messages.success(request, msg)
394 return firewall
395 except Exception as e:
396 LOG.error('Failed to remove router(s) from firewall %(id)s: '
397 '%(reason)s', {'id': firewall_id, 'reason': e})
398 msg = (_('Failed to remove router(s) from firewall %(name)s: '
399 '%(reason)s') %
400 {'name': firewall_name_or_id, 'reason': e})
401 redirect = reverse(self.failure_url)
402 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 dee2d5e..d268167 100644
--- a/openstack_dashboard/dashboards/project/firewalls/tables.py
+++ b/openstack_dashboard/dashboards/project/firewalls/tables.py
@@ -418,7 +418,6 @@ class FirewallsTable(tables.DataTable):
418 'fwaasrouterinsertion'): 418 'fwaasrouterinsertion'):
419 del self.columns['router_ids'] 419 del self.columns['router_ids']
420 except Exception as e: 420 except Exception as e:
421 msg = _('Failed to verify extension support %(reason)s') % { 421 LOG.error('Failed to verify extension support %s', e)
422 'reason': e} 422 msg = _('Failed to verify extension support %s') % e
423 LOG.error(msg)
424 exceptions.handle(request, msg) 423 exceptions.handle(request, msg)
diff --git a/openstack_dashboard/dashboards/project/networks/forms.py b/openstack_dashboard/dashboards/project/networks/forms.py
index 3e2c3d3..aee300b 100644
--- a/openstack_dashboard/dashboards/project/networks/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/forms.py
@@ -62,11 +62,11 @@ class UpdateNetwork(forms.SelfHandlingForm):
62 data['network_id'], 62 data['network_id'],
63 **params) 63 **params)
64 msg = _('Network %s was successfully updated.') % data['name'] 64 msg = _('Network %s was successfully updated.') % data['name']
65 LOG.debug(msg)
66 messages.success(request, msg) 65 messages.success(request, msg)
67 return network 66 return network
68 except Exception: 67 except Exception as e:
68 LOG.info('Failed to update network %(id)s: %(exc)s',
69 {'id': data['network_id'], 'exc': e})
69 msg = _('Failed to update network %s') % data['name'] 70 msg = _('Failed to update network %s') % data['name']
70 LOG.info(msg)
71 redirect = reverse(self.failure_url) 71 redirect = reverse(self.failure_url)
72 exceptions.handle(request, msg, redirect=redirect) 72 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 00d5cfd..d93db59 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/forms.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/forms.py
@@ -159,13 +159,13 @@ class CreatePort(forms.SelfHandlingForm):
159 msg = _('Port %s was successfully created.') % port['name'] 159 msg = _('Port %s was successfully created.') % port['name']
160 else: 160 else:
161 msg = _('Port %s was successfully created.') % port['id'] 161 msg = _('Port %s was successfully created.') % port['id']
162 LOG.debug(msg)
163 messages.success(request, msg) 162 messages.success(request, msg)
164 return port 163 return port
165 except Exception: 164 except Exception as e:
166 msg = _('Failed to create a port for network %s') \ 165 LOG.info('Failed to create a port for network %(id)s: %(exc)s',
167 % data['network_id'] 166 {'id': data['network_id'], 'exc': e})
168 LOG.info(msg) 167 msg = (_('Failed to create a port for network %s')
168 % data['network_id'])
169 redirect = reverse(self.failure_url, 169 redirect = reverse(self.failure_url,
170 args=(data['network_id'],)) 170 args=(data['network_id'],))
171 exceptions.handle(request, msg, redirect=redirect) 171 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 51724f3..3e39978 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 b4f9bdb..ebb9b94 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 20f31ef..85140ec 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 12fa00e..8cde19e 100644
--- a/openstack_dashboard/dashboards/project/networks/workflows.py
+++ b/openstack_dashboard/dashboards/project/networks/workflows.py
@@ -469,9 +469,9 @@ class CreateNetwork(workflows.Workflow):
469 network.name_or_id) 469 network.name_or_id)
470 return network 470 return network
471 except Exception as e: 471 except Exception as e:
472 LOG.info('Failed to create network: %s', e)
472 msg = (_('Failed to create network "%(network)s": %(reason)s') % 473 msg = (_('Failed to create network "%(network)s": %(reason)s') %
473 {"network": data['net_name'], "reason": e}) 474 {"network": data['net_name'], "reason": e})
474 LOG.info(msg)
475 redirect = self.get_failure_url() 475 redirect = self.get_failure_url()
476 exceptions.handle(request, msg, redirect=redirect) 476 exceptions.handle(request, msg, redirect=redirect)
477 return False 477 return False
@@ -560,15 +560,17 @@ class CreateNetwork(workflows.Workflow):
560 """Delete the created network when subnet creation failed.""" 560 """Delete the created network when subnet creation failed."""
561 try: 561 try:
562 api.neutron.network_delete(request, network.id) 562 api.neutron.network_delete(request, network.id)
563 LOG.debug('Delete the created network %s '
564 'due to subnet creation failure.', network.id)
563 msg = _('Delete the created network "%s" ' 565 msg = _('Delete the created network "%s" '
564 'due to subnet creation failure.') % network.name 566 'due to subnet creation failure.') % network.name
565 LOG.debug(msg)
566 redirect = self.get_failure_url() 567 redirect = self.get_failure_url()
567 messages.info(request, msg) 568 messages.info(request, msg)
568 raise exceptions.Http302(redirect) 569 raise exceptions.Http302(redirect)
569 except Exception: 570 except Exception as e:
571 LOG.info('Failed to delete network %(id)s: %(exc)s',
572 {'id': network.id, 'exc': e})
570 msg = _('Failed to delete network "%s"') % network.name 573 msg = _('Failed to delete network "%s"') % network.name
571 LOG.info(msg)
572 redirect = self.get_failure_url() 574 redirect = self.get_failure_url()
573 exceptions.handle(request, msg, redirect=redirect) 575 exceptions.handle(request, msg, redirect=redirect)
574 576
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 51cd96a..0c60397 100644
--- a/openstack_dashboard/dashboards/project/routers/forms.py
+++ b/openstack_dashboard/dashboards/project/routers/forms.py
@@ -74,9 +74,9 @@ class CreateForm(forms.SelfHandlingForm):
74 search_opts = {'router:external': True} 74 search_opts = {'router:external': True}
75 try: 75 try:
76 networks = api.neutron.network_list(request, **search_opts) 76 networks = api.neutron.network_list(request, **search_opts)
77 except Exception: 77 except Exception as e:
78 LOG.info('Failed to get network list: %s', e)
78 msg = _('Failed to get network list.') 79 msg = _('Failed to get network list.')
79 LOG.info(msg)
80 messages.warning(request, msg) 80 messages.warning(request, msg)
81 networks = [] 81 networks = []
82 82
@@ -103,11 +103,11 @@ class CreateForm(forms.SelfHandlingForm):
103 messages.success(request, message) 103 messages.success(request, message)
104 return router 104 return router
105 except Exception as exc: 105 except Exception as exc:
106 LOG.info('Failed to create router: %s', exc)
106 if exc.status_code == 409: 107 if exc.status_code == 409:
107 msg = _('Quota exceeded for resource router.') 108 msg = _('Quota exceeded for resource router.')
108 else: 109 else:
109 msg = _('Failed to create router "%s".') % data['name'] 110 msg = _('Failed to create router "%s".') % data['name']
110 LOG.info(msg)
111 redirect = reverse(self.failure_url) 111 redirect = reverse(self.failure_url)
112 exceptions.handle(request, msg, redirect=redirect) 112 exceptions.handle(request, msg, redirect=redirect)
113 return False 113 return False
@@ -162,10 +162,10 @@ class UpdateForm(forms.SelfHandlingForm):
162 router = api.neutron.router_update(request, data['router_id'], 162 router = api.neutron.router_update(request, data['router_id'],
163 **params) 163 **params)
164 msg = _('Router %s was successfully updated.') % data['name'] 164 msg = _('Router %s was successfully updated.') % data['name']
165 LOG.debug(msg)
166 messages.success(request, msg) 165 messages.success(request, msg)
167 return router 166 return router
168 except Exception: 167 except Exception as exc:
168 LOG.info('Failed to update router %(id)s: %(exc)s',
169 {'id': data['router_id'], 'exc': exc})
169 msg = _('Failed to update router %s') % data['name'] 170 msg = _('Failed to update router %s') % data['name']
170 LOG.info(msg)
171 exceptions.handle(request, msg, redirect=self.redirect_url) 171 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 d865006..d94ff04 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 e7b126f..b60ba8b 100644
--- a/openstack_dashboard/dashboards/project/vpn/forms.py
+++ b/openstack_dashboard/dashboards/project/vpn/forms.py
@@ -49,12 +49,12 @@ class UpdateVPNService(forms.SelfHandlingForm):
49 request, context['vpnservice_id'], **data) 49 request, context['vpnservice_id'], **data)
50 msg = (_('VPN Service %s was successfully updated.') 50 msg = (_('VPN Service %s was successfully updated.')
51 % context['name']) 51 % context['name'])
52 LOG.debug(msg)
53 messages.success(request, msg) 52 messages.success(request, msg)
54 return vpnservice 53 return vpnservice
55 except Exception as e: 54 except Exception as e:
55 LOG.info('Failed to update VPN Service %(id)s: %(exc)s',
56 {'id': context['vpnservice_id'], 'exc': e})
56 msg = _('Failed to update VPN Service %s') % context['name'] 57 msg = _('Failed to update VPN Service %s') % context['name']
57 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
58 redirect = reverse(self.failure_url) 58 redirect = reverse(self.failure_url)
59 exceptions.handle(request, msg, redirect=redirect) 59 exceptions.handle(request, msg, redirect=redirect)
60 60
@@ -128,12 +128,12 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
128 request, context['ikepolicy_id'], **data) 128 request, context['ikepolicy_id'], **data)
129 msg = (_('IKE Policy %s was successfully updated.') 129 msg = (_('IKE Policy %s was successfully updated.')
130 % context['name']) 130 % context['name'])
131 LOG.debug(msg)
132 messages.success(request, msg) 131 messages.success(request, msg)
133 return ikepolicy 132 return ikepolicy
134 except Exception as e: 133 except Exception as e:
134 LOG.info('Failed to update IKE Policy %(id)s: %(exc)s',
135 {'id': context['ikepolicy_id'], 'exc': e})
135 msg = _('Failed to update IKE Policy %s') % context['name'] 136 msg = _('Failed to update IKE Policy %s') % context['name']
136 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
137 redirect = reverse(self.failure_url) 137 redirect = reverse(self.failure_url)
138 exceptions.handle(request, msg, redirect=redirect) 138 exceptions.handle(request, msg, redirect=redirect)
139 139
@@ -206,12 +206,12 @@ class UpdateIPSecPolicy(forms.SelfHandlingForm):
206 request, context['ipsecpolicy_id'], **data) 206 request, context['ipsecpolicy_id'], **data)
207 msg = (_('IPSec Policy %s was successfully updated.') 207 msg = (_('IPSec Policy %s was successfully updated.')
208 % context['name']) 208 % context['name'])
209 LOG.debug(msg)
210 messages.success(request, msg) 209 messages.success(request, msg)
211 return ipsecpolicy 210 return ipsecpolicy
212 except Exception as e: 211 except Exception as e:
212 LOG.info('Failed to update IPSec Policy %(id)s: %(exc)s',
213 {'id': context['ipsecpolicy_id'], 'exc': e})
213 msg = _('Failed to update IPSec Policy %s') % context['name'] 214 msg = _('Failed to update IPSec Policy %s') % context['name']
214 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
215 redirect = reverse(self.failure_url) 215 redirect = reverse(self.failure_url)
216 exceptions.handle(request, msg, redirect=redirect) 216 exceptions.handle(request, msg, redirect=redirect)
217 217
@@ -312,12 +312,12 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
312 request, context['ipsecsiteconnection_id'], **data) 312 request, context['ipsecsiteconnection_id'], **data)
313 msg = (_('IPSec Site Connection %s was successfully updated.') 313 msg = (_('IPSec Site Connection %s was successfully updated.')
314 % context['name']) 314 % context['name'])
315 LOG.debug(msg)
316 messages.success(request, msg) 315 messages.success(request, msg)
317 return ipsecsiteconnection 316 return ipsecsiteconnection
318 except Exception as e: 317 except Exception as e:
318 LOG.info('Failed to update IPSec Site Connection %(id)s: %(exc)s',
319 {'id': context['ipsecsiteconnection_id'], 'exc': e})
319 msg = (_('Failed to update IPSec Site Connection %s') 320 msg = (_('Failed to update IPSec Site Connection %s')
320 % context['name']) 321 % context['name'])
321 LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
322 redirect = reverse(self.failure_url) 322 redirect = reverse(self.failure_url)
323 exceptions.handle(request, msg, redirect=redirect) 323 exceptions.handle(request, msg, redirect=redirect)