Browse Source

Handle log message interpolation by the logger

According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
tags/12.0.0.0b1
Gábor Antal 2 years ago
parent
commit
34a3aa0ba8
34 changed files with 127 additions and 110 deletions
  1. 3
    2
      horizon/base.py
  2. 2
    2
      horizon/middleware/base.py
  3. 13
    10
      horizon/tables/actions.py
  4. 2
    2
      horizon/tables/base.py
  5. 1
    1
      horizon/test/helpers.py
  6. 4
    2
      horizon/utils/file_discovery.py
  7. 4
    5
      openstack_dashboard/api/glance.py
  8. 7
    6
      openstack_dashboard/api/keystone.py
  9. 38
    27
      openstack_dashboard/api/neutron.py
  10. 3
    3
      openstack_dashboard/api/nova.py
  11. 1
    1
      openstack_dashboard/dashboards/admin/floating_ips/tables.py
  12. 8
    4
      openstack_dashboard/dashboards/admin/images/views.py
  13. 1
    2
      openstack_dashboard/dashboards/admin/networks/forms.py
  14. 1
    1
      openstack_dashboard/dashboards/admin/networks/ports/forms.py
  15. 3
    3
      openstack_dashboard/dashboards/identity/domains/tables.py
  16. 2
    2
      openstack_dashboard/dashboards/identity/domains/workflows.py
  17. 1
    1
      openstack_dashboard/dashboards/identity/groups/forms.py
  18. 5
    5
      openstack_dashboard/dashboards/identity/groups/tables.py
  19. 1
    1
      openstack_dashboard/dashboards/identity/projects/workflows.py
  20. 2
    2
      openstack_dashboard/dashboards/identity/users/forms.py
  21. 2
    3
      openstack_dashboard/dashboards/identity/users/views.py
  22. 1
    1
      openstack_dashboard/dashboards/project/floating_ips/tables.py
  23. 3
    3
      openstack_dashboard/dashboards/project/instances/views.py
  24. 2
    2
      openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
  25. 1
    1
      openstack_dashboard/dashboards/project/networks/ports/forms.py
  26. 1
    2
      openstack_dashboard/dashboards/project/networks/subnets/workflows.py
  27. 3
    5
      openstack_dashboard/dashboards/project/networks/workflows.py
  28. 1
    1
      openstack_dashboard/dashboards/project/stacks/forms.py
  29. 2
    2
      openstack_dashboard/dashboards/project/stacks/tabs.py
  30. 4
    4
      openstack_dashboard/dashboards/project/vpn/forms.py
  31. 2
    1
      openstack_dashboard/django_pyscss_fix/__init__.py
  32. 1
    1
      openstack_dashboard/settings.py
  33. 1
    1
      openstack_dashboard/theme_settings.py
  34. 1
    1
      openstack_dashboard/utils/settings.py

+ 3
- 2
horizon/base.py View File

@@ -309,7 +309,8 @@ class Panel(HorizonComponent):
309 309
         except Exception as exc:
310 310
             # Logging here since this will often be called in a template
311 311
             # where the exception would be hidden.
312
-            LOG.info("Error reversing absolute URL for %s: %s" % (self, exc))
312
+            LOG.info("Error reversing absolute URL for %(self)s: %(exc)s",
313
+                     {'self': self, 'exc': exc})
313 314
             raise
314 315
 
315 316
     @property
@@ -524,7 +525,7 @@ class Dashboard(Registry, HorizonComponent):
524 525
         except Exception:
525 526
             # Logging here since this will often be called in a template
526 527
             # where the exception would be hidden.
527
-            LOG.exception("Error reversing absolute URL for %s." % self)
528
+            LOG.exception("Error reversing absolute URL for %s.", self)
528 529
             raise
529 530
 
530 531
     @property

+ 2
- 2
horizon/middleware/base.py View File

@@ -97,8 +97,8 @@ class HorizonMiddleware(object):
97 97
                         'You need to configure file-based or database-backed '
98 98
                         'sessions instead of cookie-based sessions: '
99 99
                         'http://docs.openstack.org/developer/horizon/topics/'
100
-                        'deployment.html#session-storage'
101
-                        % {
100
+                        'deployment.html#session-storage',
101
+                        {
102 102
                             'user_id': request.session.get(
103 103
                                 'user_id', 'Unknown'),
104 104
                             'cookie_size': cookie_size,

+ 13
- 10
horizon/tables/actions.py View File

@@ -405,7 +405,8 @@ class LinkAction(BaseAction):
405 405
             else:
406 406
                 return urlresolvers.reverse(self.url)
407 407
         except urlresolvers.NoReverseMatch as ex:
408
-            LOG.info('No reverse found for "%s": %s' % (self.url, ex))
408
+            LOG.info('No reverse found for "%(url)s": %(exception)s',
409
+                     {'url': self.url, 'exception': ex})
409 410
             return self.url
410 411
 
411 412
 
@@ -846,8 +847,9 @@ class BatchAction(Action):
846 847
                 self.update(request, datum)
847 848
                 action_success.append(datum_display)
848 849
                 self.success_ids.append(datum_id)
849
-                LOG.info(u'%s: "%s"' %
850
-                         (self._get_action_name(past=True), datum_display))
850
+                LOG.info(u'%(action)s: "%(datum_display)s"',
851
+                         {'action': self._get_action_name(past=True),
852
+                          'datum_display': datum_display})
851 853
             except Exception as ex:
852 854
                 # Handle the exception but silence it since we'll display
853 855
                 # an aggregate error message later. Otherwise we'd get
@@ -972,14 +974,15 @@ class Deprecated(type):
972 974
     # oslo_log.versionutils when it's finally added in 11.0
973 975
     def __new__(meta, name, bases, kwargs):
974 976
         cls = super(Deprecated, meta).__new__(meta, name, bases, kwargs)
975
-        message = ("WARNING:The UpdateAction class defined in module '%s'"
976
-                   " is deprecated as of Newton and may be removed in "
977
-                   "Horizon P (12.0). Class '%s' defined at module '%s' "
978
-                   "shall no longer subclass it.")
979 977
         if name != 'UpdateAction':
980
-            LOG.warning(message % (UpdateAction.__module__,
981
-                                   name,
982
-                                   kwargs['__module__']))
978
+            LOG.warning(
979
+                "WARNING:The UpdateAction class defined in module '%(mod)s' "
980
+                "is deprecated as of Newton and may be removed in "
981
+                "Horizon P (12.0). Class '%(name)s' defined at "
982
+                "module '%(module)s' shall no longer subclass it.",
983
+                {'mod': UpdateAction.__module__,
984
+                 'name': name,
985
+                 'module': kwargs['__module__']})
983 986
         return cls
984 987
 
985 988
 

+ 2
- 2
horizon/tables/base.py View File

@@ -1673,8 +1673,8 @@ class DataTable(object):
1673 1673
             # If not allowed, neither edit mod or updating is allowed.
1674 1674
             if not cell.update_allowed:
1675 1675
                 datum_display = (self.get_object_display(datum) or "N/A")
1676
-                LOG.info('Permission denied to %s: "%s"' %
1677
-                         ("Update Action", datum_display))
1676
+                LOG.info('Permission denied to Update Action: "%s"',
1677
+                         datum_display)
1678 1678
                 return HttpResponse(status=401)
1679 1679
             # If it is post request, we are updating the cell.
1680 1680
             if request.method == "POST":

+ 1
- 1
horizon/test/helpers.py View File

@@ -52,7 +52,7 @@ try:
52 52
 
53 53
     from horizon.test.webdriver import WebDriver
54 54
 except ImportError as e:
55
-    LOG.warning("{0}, force WITH_SELENIUM=False".format(str(e)))
55
+    LOG.warning("%s, force WITH_SELENIUM=False", e)
56 56
     os.environ['WITH_SELENIUM'] = ''
57 57
 
58 58
 

+ 4
- 2
horizon/utils/file_discovery.py View File

@@ -108,5 +108,7 @@ def _log(file_list, list_name, in_path):
108 108
     """Logs result at debug level
109 109
     """
110 110
     file_names = '\n'.join(file_list)
111
-    LOG.debug("\nDiscovered {0} {1} file(s) in {2}:\n{3}\n"
112
-              .format(len(file_list), list_name, in_path, file_names))
111
+    LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
112
+              "%(files)s\n",
113
+              {'size': len(file_list), 'name': list_name, 'path': in_path,
114
+               'files': file_names})

+ 4
- 5
openstack_dashboard/api/glance.py View File

@@ -351,10 +351,9 @@ def image_update(request, image_id, **kwargs):
351 351
                 filename = str(image_data.file)
352 352
                 if hasattr(image_data.file, 'name'):
353 353
                     filename = image_data.file.name
354
-                msg = (('Failed to remove temporary image file '
355
-                        '%(file)s (%(e)s)') %
356
-                       dict(file=filename, e=str(e)))
357
-                LOG.warning(msg)
354
+                LOG.warning('Failed to remove temporary image file '
355
+                            '%(file)s (%(e)s)',
356
+                            {'file': filename, 'e': e})
358 357
 
359 358
 
360 359
 def get_image_upload_mode():
@@ -363,7 +362,7 @@ def get_image_upload_mode():
363 362
     mode = getattr(settings, 'HORIZON_IMAGES_UPLOAD_MODE', 'legacy')
364 363
     if mode not in ('off', 'legacy', 'direct'):
365 364
         LOG.warning('HORIZON_IMAGES_UPLOAD_MODE has an unrecognized value of '
366
-                    '"%s", reverting to default "legacy" value' % mode)
365
+                    '"%s", reverting to default "legacy" value', mode)
367 366
         mode = 'legacy'
368 367
     return mode
369 368
 

+ 7
- 6
openstack_dashboard/api/keystone.py View File

@@ -186,7 +186,7 @@ def keystoneclient(request, admin=False):
186 186
         endpoint = _get_endpoint_url(request, endpoint_type)
187 187
         insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
188 188
         cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
189
-        LOG.debug("Creating a new keystoneclient connection to %s." % endpoint)
189
+        LOG.debug("Creating a new keystoneclient connection to %s.", endpoint)
190 190
         remote_addr = request.environ.get('REMOTE_ADDR', '')
191 191
         conn = api_version['client'].Client(token=token_id,
192 192
                                             endpoint=endpoint,
@@ -247,7 +247,7 @@ def domain_update(request, domain_id, name=None, description=None,
247 247
         response = manager.update(domain_id, name=name,
248 248
                                   description=description, enabled=enabled)
249 249
     except Exception:
250
-        LOG.exception("Unable to update Domain: %s" % domain_id)
250
+        LOG.exception("Unable to update Domain: %s", domain_id)
251 251
         raise
252 252
     return response
253 253
 
@@ -299,11 +299,12 @@ def get_default_domain(request, get_name=True):
299 299
                 # we recognize this condition and return the user's
300 300
                 # domain information instead.
301 301
                 LOG.debug("Cannot retrieve domain information for "
302
-                          "user (%s) that does not have an admin role "
303
-                          "on project (%s)" %
304
-                          (request.user.username, request.user.project_name))
302
+                          "user (%(user)s) that does not have an admin role "
303
+                          "on project (%(project)s)",
304
+                          {'user': request.user.username,
305
+                           'project': request.user.project_name})
305 306
             except Exception:
306
-                LOG.warning("Unable to retrieve Domain: %s" % domain_id)
307
+                LOG.warning("Unable to retrieve Domain: %s", domain_id)
307 308
     domain = base.APIDictWrapper({"id": domain_id,
308 309
                                   "name": domain_name})
309 310
     return domain

+ 38
- 27
openstack_dashboard/api/neutron.py View File

@@ -645,8 +645,8 @@ def network_list_for_tenant(request, tenant_id, include_external=False,
645 645
     The list contains networks owned by the tenant and public networks.
646 646
     If requested_networks specified, it searches requested_networks only.
647 647
     """
648
-    LOG.debug("network_list_for_tenant(): tenant_id=%s, params=%s"
649
-              % (tenant_id, params))
648
+    LOG.debug("network_list_for_tenant(): tenant_id=%(tenant_id)s, "
649
+              "params=%(params)s", {'tenant_id': tenant_id, 'params': params})
650 650
 
651 651
     networks = []
652 652
     shared = params.get('shared')
@@ -682,7 +682,8 @@ def network_list_for_tenant(request, tenant_id, include_external=False,
682 682
 
683 683
 @profiler.trace
684 684
 def network_get(request, network_id, expand_subnet=True, **params):
685
-    LOG.debug("network_get(): netid=%s, params=%s" % (network_id, params))
685
+    LOG.debug("network_get(): netid=%(network_id)s, params=%(params)s",
686
+              {'network_id': network_id, 'params': params})
686 687
     network = neutronclient(request).show_network(network_id,
687 688
                                                   **params).get('network')
688 689
     if expand_subnet:
@@ -704,7 +705,7 @@ def network_create(request, **kwargs):
704 705
     :param name: (optional) name of the network created
705 706
     :returns: Network object
706 707
     """
707
-    LOG.debug("network_create(): kwargs = %s" % kwargs)
708
+    LOG.debug("network_create(): kwargs = %s", kwargs)
708 709
     if 'tenant_id' not in kwargs:
709 710
         kwargs['tenant_id'] = request.user.project_id
710 711
     body = {'network': kwargs}
@@ -714,7 +715,8 @@ def network_create(request, **kwargs):
714 715
 
715 716
 @profiler.trace
716 717
 def network_update(request, network_id, **kwargs):
717
-    LOG.debug("network_update(): netid=%s, params=%s" % (network_id, kwargs))
718
+    LOG.debug("network_update(): netid=%(network_id)s, params=%(params)s",
719
+              {'network_id': network_id, 'params': kwargs})
718 720
     body = {'network': kwargs}
719 721
     network = neutronclient(request).update_network(network_id,
720 722
                                                     body=body).get('network')
@@ -723,20 +725,21 @@ def network_update(request, network_id, **kwargs):
723 725
 
724 726
 @profiler.trace
725 727
 def network_delete(request, network_id):
726
-    LOG.debug("network_delete(): netid=%s" % network_id)
728
+    LOG.debug("network_delete(): netid=%s", network_id)
727 729
     neutronclient(request).delete_network(network_id)
728 730
 
729 731
 
730 732
 @profiler.trace
731 733
 def subnet_list(request, **params):
732
-    LOG.debug("subnet_list(): params=%s" % (params))
734
+    LOG.debug("subnet_list(): params=%s", params)
733 735
     subnets = neutronclient(request).list_subnets(**params).get('subnets')
734 736
     return [Subnet(s) for s in subnets]
735 737
 
736 738
 
737 739
 @profiler.trace
738 740
 def subnet_get(request, subnet_id, **params):
739
-    LOG.debug("subnet_get(): subnetid=%s, params=%s" % (subnet_id, params))
741
+    LOG.debug("subnet_get(): subnetid=%(subnet_id)s, params=%(params)s",
742
+              {'subnet_id': subnet_id, 'params': params})
740 743
     subnet = neutronclient(request).show_subnet(subnet_id,
741 744
                                                 **params).get('subnet')
742 745
     return Subnet(subnet)
@@ -761,8 +764,8 @@ def subnet_create(request, network_id, **kwargs):
761 764
     optional you MUST pass along one of the combinations to get a successful
762 765
     result.
763 766
     """
764
-    LOG.debug("subnet_create(): netid=%s, kwargs=%s"
765
-              % (network_id, kwargs))
767
+    LOG.debug("subnet_create(): netid=%(network_id)s, kwargs=%(kwargs)s",
768
+              {'network_id': network_id, 'kwargs': kwargs})
766 769
     body = {'subnet': {'network_id': network_id}}
767 770
     if 'tenant_id' not in kwargs:
768 771
         kwargs['tenant_id'] = request.user.project_id
@@ -773,7 +776,8 @@ def subnet_create(request, network_id, **kwargs):
773 776
 
774 777
 @profiler.trace
775 778
 def subnet_update(request, subnet_id, **kwargs):
776
-    LOG.debug("subnet_update(): subnetid=%s, kwargs=%s" % (subnet_id, kwargs))
779
+    LOG.debug("subnet_update(): subnetid=%(subnet_id)s, kwargs=%(kwargs)s",
780
+              {'subnet_id': subnet_id, 'kwargs': kwargs})
777 781
     body = {'subnet': kwargs}
778 782
     subnet = neutronclient(request).update_subnet(subnet_id,
779 783
                                                   body=body).get('subnet')
@@ -782,13 +786,13 @@ def subnet_update(request, subnet_id, **kwargs):
782 786
 
783 787
 @profiler.trace
784 788
 def subnet_delete(request, subnet_id):
785
-    LOG.debug("subnet_delete(): subnetid=%s" % subnet_id)
789
+    LOG.debug("subnet_delete(): subnetid=%s", subnet_id)
786 790
     neutronclient(request).delete_subnet(subnet_id)
787 791
 
788 792
 
789 793
 @profiler.trace
790 794
 def subnetpool_list(request, **params):
791
-    LOG.debug("subnetpool_list(): params=%s" % (params))
795
+    LOG.debug("subnetpool_list(): params=%s", params)
792 796
     subnetpools = \
793 797
         neutronclient(request).list_subnetpools(**params).get('subnetpools')
794 798
     return [SubnetPool(s) for s in subnetpools]
@@ -796,8 +800,9 @@ def subnetpool_list(request, **params):
796 800
 
797 801
 @profiler.trace
798 802
 def subnetpool_get(request, subnetpool_id, **params):
799
-    LOG.debug("subnetpool_get(): subnetpoolid=%s, params=%s" %
800
-              (subnetpool_id, params))
803
+    LOG.debug("subnetpool_get(): subnetpoolid=%(subnetpool_id)s, "
804
+              "params=%(params)s", {'subnetpool_id': subnetpool_id,
805
+                                    'params': params})
801 806
     subnetpool = \
802 807
         neutronclient(request).show_subnetpool(subnetpool_id,
803 808
                                                **params).get('subnetpool')
@@ -826,8 +831,9 @@ def subnetpool_create(request, name, prefixes, **kwargs):
826 831
     Returns:
827 832
     SubnetPool object
828 833
     """
829
-    LOG.debug("subnetpool_create(): name=%s, prefixes=%s, kwargs=%s"
830
-              % (name, prefixes, kwargs))
834
+    LOG.debug("subnetpool_create(): name=%(name)s, prefixes=%(prefixes)s, "
835
+              "kwargs=%(kwargs)s", {'name': name, 'prefixes': prefixes,
836
+                                    'kwargs': kwargs})
831 837
     body = {'subnetpool':
832 838
             {'name': name,
833 839
              'prefixes': prefixes,
@@ -843,8 +849,9 @@ def subnetpool_create(request, name, prefixes, **kwargs):
843 849
 
844 850
 @profiler.trace
845 851
 def subnetpool_update(request, subnetpool_id, **kwargs):
846
-    LOG.debug("subnetpool_update(): subnetpoolid=%s, kwargs=%s" %
847
-              (subnetpool_id, kwargs))
852
+    LOG.debug("subnetpool_update(): subnetpoolid=%(subnetpool_id)s, "
853
+              "kwargs=%(kwargs)s", {'subnetpool_id': subnetpool_id,
854
+                                    'kwargs': kwargs})
848 855
     body = {'subnetpool': kwargs}
849 856
     subnetpool = \
850 857
         neutronclient(request).update_subnetpool(subnetpool_id,
@@ -854,20 +861,21 @@ def subnetpool_update(request, subnetpool_id, **kwargs):
854 861
 
855 862
 @profiler.trace
856 863
 def subnetpool_delete(request, subnetpool_id):
857
-    LOG.debug("subnetpool_delete(): subnetpoolid=%s" % subnetpool_id)
864
+    LOG.debug("subnetpool_delete(): subnetpoolid=%s", subnetpool_id)
858 865
     return neutronclient(request).delete_subnetpool(subnetpool_id)
859 866
 
860 867
 
861 868
 @profiler.trace
862 869
 def port_list(request, **params):
863
-    LOG.debug("port_list(): params=%s" % (params))
870
+    LOG.debug("port_list(): params=%s", params)
864 871
     ports = neutronclient(request).list_ports(**params).get('ports')
865 872
     return [Port(p) for p in ports]
866 873
 
867 874
 
868 875
 @profiler.trace
869 876
 def port_get(request, port_id, **params):
870
-    LOG.debug("port_get(): portid=%s, params=%s" % (port_id, params))
877
+    LOG.debug("port_get(): portid=%(port_id)s, params=%(params)s",
878
+              {'port_id': port_id, 'params': params})
871 879
     port = neutronclient(request).show_port(port_id, **params).get('port')
872 880
     return Port(port)
873 881
 
@@ -890,7 +898,8 @@ def port_create(request, network_id, **kwargs):
890 898
     :param name: (optional) name of the port created
891 899
     :returns: Port object
892 900
     """
893
-    LOG.debug("port_create(): netid=%s, kwargs=%s" % (network_id, kwargs))
901
+    LOG.debug("port_create(): netid=%(network_id)s, kwargs=%(kwargs)s",
902
+              {'network_id': network_id, 'kwargs': kwargs})
894 903
     kwargs = unescape_port_kwargs(**kwargs)
895 904
     body = {'port': {'network_id': network_id}}
896 905
     if 'tenant_id' not in kwargs:
@@ -902,13 +911,14 @@ def port_create(request, network_id, **kwargs):
902 911
 
903 912
 @profiler.trace
904 913
 def port_delete(request, port_id):
905
-    LOG.debug("port_delete(): portid=%s" % port_id)
914
+    LOG.debug("port_delete(): portid=%s", port_id)
906 915
     neutronclient(request).delete_port(port_id)
907 916
 
908 917
 
909 918
 @profiler.trace
910 919
 def port_update(request, port_id, **kwargs):
911
-    LOG.debug("port_update(): portid=%s, kwargs=%s" % (port_id, kwargs))
920
+    LOG.debug("port_update(): portid=%(port_id)s, kwargs=%(kwargs)s",
921
+              {'port_id': port_id, 'kwargs': kwargs})
912 922
     kwargs = unescape_port_kwargs(**kwargs)
913 923
     body = {'port': kwargs}
914 924
     port = neutronclient(request).update_port(port_id, body=body).get('port')
@@ -917,7 +927,7 @@ def port_update(request, port_id, **kwargs):
917 927
 
918 928
 @profiler.trace
919 929
 def router_create(request, **kwargs):
920
-    LOG.debug("router_create():, kwargs=%s" % kwargs)
930
+    LOG.debug("router_create():, kwargs=%s", kwargs)
921 931
     body = {'router': {}}
922 932
     if 'tenant_id' not in kwargs:
923 933
         kwargs['tenant_id'] = request.user.project_id
@@ -928,7 +938,8 @@ def router_create(request, **kwargs):
928 938
 
929 939
 @profiler.trace
930 940
 def router_update(request, r_id, **kwargs):
931
-    LOG.debug("router_update(): router_id=%s, kwargs=%s" % (r_id, kwargs))
941
+    LOG.debug("router_update(): router_id=%(r_id)s, kwargs=%(kwargs)s",
942
+              {'r_id': r_id, 'kwargs': kwargs})
932 943
     body = {'router': {}}
933 944
     body['router'].update(kwargs)
934 945
     router = neutronclient(request).update_router(r_id, body=body)

+ 3
- 3
openstack_dashboard/api/nova.py View File

@@ -339,9 +339,9 @@ class SecurityGroupManager(network_base.SecurityGroupManager):
339 339
                 num_groups_to_modify -= 1
340 340
         except nova_exceptions.ClientException as err:
341 341
             LOG.error(_("Failed to modify %(num_groups_to_modify)d instance "
342
-                        "security groups: %(err)s") %
343
-                      dict(num_groups_to_modify=num_groups_to_modify,
344
-                           err=err))
342
+                        "security groups: %(err)s"),
343
+                      {'num_groups_to_modify': num_groups_to_modify,
344
+                       'err': err})
345 345
             # reraise novaclient.exceptions.ClientException, but with
346 346
             # a sanitized error message so we don't risk exposing
347 347
             # sensitive information to the end user. This has to be

+ 1
- 1
openstack_dashboard/dashboards/admin/floating_ips/tables.py View File

@@ -62,7 +62,7 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
62 62
         try:
63 63
             fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
64 64
             api.network.floating_ip_disassociate(request, fip.id)
65
-            LOG.info('Disassociating Floating IP "%s".' % obj_id)
65
+            LOG.info('Disassociating Floating IP "%s".', obj_id)
66 66
             messages.success(request,
67 67
                              _('Successfully disassociated Floating IP: %s')
68 68
                              % fip.ip)

+ 8
- 4
openstack_dashboard/dashboards/admin/images/views.py View File

@@ -120,16 +120,20 @@ class IndexView(tables.DataTableView):
120 120
         if filter_field and filter_string and (
121 121
                 filter_action.is_api_filter(filter_field)):
122 122
             if filter_field in ['size_min', 'size_max']:
123
-                invalid_msg = ('API query is not valid and is ignored: %s=%s'
124
-                               % (filter_field, filter_string))
123
+                invalid_msg = ('API query is not valid and is ignored: '
124
+                               '%(field)s=%(string)s')
125 125
                 try:
126 126
                     filter_string = long(float(filter_string) * (units.Mi))
127 127
                     if filter_string >= 0:
128 128
                         filters[filter_field] = filter_string
129 129
                     else:
130
-                        LOG.warning(invalid_msg)
130
+                        LOG.warning(invalid_msg,
131
+                                    {'field': filter_field,
132
+                                     'string': filter_string})
131 133
                 except ValueError:
132
-                    LOG.warning(invalid_msg)
134
+                    LOG.warning(invalid_msg,
135
+                                {'field': filter_field,
136
+                                 'string': filter_string})
133 137
             elif (filter_field == 'disk_format' and
134 138
                   filter_string.lower() == 'docker'):
135 139
                 filters['disk_format'] = 'raw'

+ 1
- 2
openstack_dashboard/dashboards/admin/networks/forms.py View File

@@ -263,8 +263,7 @@ class CreateNetwork(forms.SelfHandlingForm):
263 263
                     params['provider:segmentation_id'] = (
264 264
                         data['segmentation_id'])
265 265
             network = api.neutron.network_create(request, **params)
266
-            msg = _('Network %s was successfully created.') % data['name']
267
-            LOG.debug(msg)
266
+            LOG.debug(_('Network %s was successfully created.'), data['name'])
268 267
             return network
269 268
         except Exception:
270 269
             redirect = reverse('horizon:admin:networks:index')

+ 1
- 1
openstack_dashboard/dashboards/admin/networks/ports/forms.py View File

@@ -156,7 +156,7 @@ class UpdatePort(project_forms.UpdatePort):
156 156
 
157 157
     def handle(self, request, data):
158 158
         try:
159
-            LOG.debug('params = %s' % data)
159
+            LOG.debug('params = %s', data)
160 160
             extension_kwargs = {}
161 161
             data['admin_state'] = (data['admin_state'] == 'True')
162 162
             if 'binding__vnic_type' in data:

+ 3
- 3
openstack_dashboard/dashboards/identity/domains/tables.py View File

@@ -118,7 +118,7 @@ class DeleteDomainsAction(tables.DeleteAction):
118 118
             messages.error(request, msg)
119 119
             raise exceptions.ClientException(409, msg)
120 120
         else:
121
-            LOG.info('Deleting domain "%s".' % obj_id)
121
+            LOG.info('Deleting domain "%s".', obj_id)
122 122
             api.keystone.domain_delete(request, obj_id)
123 123
 
124 124
 
@@ -150,7 +150,7 @@ class DisableDomainsAction(tables.BatchAction):
150 150
     def action(self, request, obj_id):
151 151
         domain = self.table.get_object_by_id(obj_id)
152 152
         if domain.enabled:
153
-            LOG.info('Disabling domain "%s".' % obj_id)
153
+            LOG.info('Disabling domain "%s".', obj_id)
154 154
             try:
155 155
                 api.keystone.domain_update(request,
156 156
                                            domain_id=domain.id,
@@ -190,7 +190,7 @@ class EnableDomainsAction(tables.BatchAction):
190 190
     def action(self, request, obj_id):
191 191
         domain = self.table.get_object_by_id(obj_id)
192 192
         if not domain.enabled:
193
-            LOG.info('Enabling domain "%s".' % obj_id)
193
+            LOG.info('Enabling domain "%s".', obj_id)
194 194
             try:
195 195
                 api.keystone.domain_update(request,
196 196
                                            domain_id=domain.id,

+ 2
- 2
openstack_dashboard/dashboards/identity/domains/workflows.py View File

@@ -265,7 +265,7 @@ class CreateDomain(workflows.Workflow):
265 265
     def handle(self, request, data):
266 266
         # create the domain
267 267
         try:
268
-            LOG.info('Creating domain with name "%s"' % data['name'])
268
+            LOG.info('Creating domain with name "%s"', data['name'])
269 269
             desc = data['description']
270 270
             api.keystone.domain_create(request,
271 271
                                        name=data['name'],
@@ -491,7 +491,7 @@ class UpdateDomain(workflows.Workflow):
491 491
         domain_id = data.pop('domain_id')
492 492
 
493 493
         try:
494
-            LOG.info('Updating domain with name "%s"' % data['name'])
494
+            LOG.info('Updating domain with name "%s"', data['name'])
495 495
             api.keystone.domain_update(request,
496 496
                                        domain_id,
497 497
                                        name=data['name'],

+ 1
- 1
openstack_dashboard/dashboards/identity/groups/forms.py View File

@@ -36,7 +36,7 @@ class CreateGroupForm(forms.SelfHandlingForm):
36 36
 
37 37
     def handle(self, request, data):
38 38
         try:
39
-            LOG.info('Creating group with name "%s"' % data['name'])
39
+            LOG.info('Creating group with name "%s"', data['name'])
40 40
             api.keystone.group_create(
41 41
                 request,
42 42
                 domain_id=identity_utils.get_domain_id_for_operation(

+ 5
- 5
openstack_dashboard/dashboards/identity/groups/tables.py View File

@@ -83,7 +83,7 @@ class DeleteGroupsAction(policy.PolicyTargetMixin, tables.DeleteAction):
83 83
         return api.keystone.keystone_can_edit_group()
84 84
 
85 85
     def delete(self, request, obj_id):
86
-        LOG.info('Deleting group "%s".' % obj_id)
86
+        LOG.info('Deleting group "%s".', obj_id)
87 87
         api.keystone.group_delete(request, obj_id)
88 88
 
89 89
 
@@ -154,8 +154,8 @@ class RemoveMembers(tables.DeleteAction):
154 154
     def action(self, request, obj_id):
155 155
         user_obj = self.table.get_object_by_id(obj_id)
156 156
         group_id = self.table.kwargs['group_id']
157
-        LOG.info('Removing user %s from group %s.' % (user_obj.id,
158
-                                                      group_id))
157
+        LOG.info('Removing user %(user)s from group %(group)s.',
158
+                 {'user': user_obj.id, 'group': group_id})
159 159
         api.keystone.remove_group_user(request,
160 160
                                        group_id=group_id,
161 161
                                        user_id=user_obj.id)
@@ -233,8 +233,8 @@ class AddMembers(tables.BatchAction):
233 233
     def action(self, request, obj_id):
234 234
         user_obj = self.table.get_object_by_id(obj_id)
235 235
         group_id = self.table.kwargs['group_id']
236
-        LOG.info('Adding user %s to group %s.' % (user_obj.id,
237
-                                                  group_id))
236
+        LOG.info('Adding user %(user)s to group %(group)s.',
237
+                 {'user': user_obj.id, 'group': group_id})
238 238
         api.keystone.add_group_user(request,
239 239
                                     group_id=group_id,
240 240
                                     user_id=user_obj.id)

+ 1
- 1
openstack_dashboard/dashboards/identity/projects/workflows.py View File

@@ -705,7 +705,7 @@ class UpdateProject(CommonQuotaWorkflow):
705 705
             self.failure_message = msg
706 706
             return
707 707
         except Exception as e:
708
-            LOG.debug('Project update failed: %s' % e)
708
+            LOG.debug('Project update failed: %s', e)
709 709
             exceptions.handle(request, ignore=True)
710 710
             return
711 711
 

+ 2
- 2
openstack_dashboard/dashboards/identity/users/forms.py View File

@@ -90,7 +90,7 @@ class BaseUserForm(forms.SelfHandlingForm):
90 90
             self.fields['project'].choices = project_choices
91 91
 
92 92
         except Exception:
93
-            LOG.debug("User: %s has no projects" % user_id)
93
+            LOG.debug("User: %s has no projects", user_id)
94 94
 
95 95
 
96 96
 class AddExtraColumnMixIn(object):
@@ -162,7 +162,7 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn):
162 162
     def handle(self, request, data):
163 163
         domain = api.keystone.get_default_domain(self.request, False)
164 164
         try:
165
-            LOG.info('Creating user with name "%s"' % data['name'])
165
+            LOG.info('Creating user with name "%s"', data['name'])
166 166
             desc = data["description"]
167 167
             if "email" in data:
168 168
                 data['email'] = data['email'] or None

+ 2
- 3
openstack_dashboard/dashboards/identity/users/views.py View File

@@ -241,9 +241,8 @@ class DetailView(views.HorizonTemplateView):
241 241
             try:
242 242
                 tenant = api.keystone.tenant_get(self.request, project_id)
243 243
             except Exception as e:
244
-                msg = ('Failed to get tenant %(project_id)s: %(reason)s' %
245
-                       {'project_id': project_id, 'reason': e})
246
-                LOG.error(msg)
244
+                LOG.error('Failed to get tenant %(project_id)s: %(reason)s',
245
+                          {'project_id': project_id, 'reason': e})
247 246
         return tenant
248 247
 
249 248
     @memoized.memoized_method

+ 1
- 1
openstack_dashboard/dashboards/project/floating_ips/tables.py View File

@@ -145,7 +145,7 @@ class DisassociateIP(tables.Action):
145 145
         try:
146 146
             fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
147 147
             api.network.floating_ip_disassociate(request, fip.id)
148
-            LOG.info('Disassociating Floating IP "%s".' % obj_id)
148
+            LOG.info('Disassociating Floating IP "%s".', obj_id)
149 149
             messages.success(request,
150 150
                              _('Successfully disassociated Floating IP: %s')
151 151
                              % fip.ip)

+ 3
- 3
openstack_dashboard/dashboards/project/instances/views.py View File

@@ -141,9 +141,9 @@ class IndexView(tables.DataTableView):
141 141
                     instance.full_flavor = api.nova.flavor_get(
142 142
                         self.request, flavor_id)
143 143
             except Exception:
144
-                msg = ('Unable to retrieve flavor "%s" for instance "%s".'
145
-                       % (flavor_id, instance.id))
146
-                LOG.info(msg)
144
+                LOG.info('Unable to retrieve flavor "%(flavor)s" for '
145
+                         'instance "%(id)s".',
146
+                         {'flavor': flavor_id, 'id': instance.id})
147 147
 
148 148
         return instances
149 149
 

+ 2
- 2
openstack_dashboard/dashboards/project/instances/workflows/create_instance.py View File

@@ -677,7 +677,7 @@ class CustomizeAction(workflows.Action):
677 677
         if has_upload:
678 678
             upload_file = files[upload_str]
679 679
             log_script_name = upload_file.name
680
-            LOG.info('got upload %s' % log_script_name)
680
+            LOG.info('got upload %s', log_script_name)
681 681
 
682 682
             if upload_file._size > 16 * units.Ki:  # 16kb
683 683
                 msg = _('File exceeds maximum size (16kb)')
@@ -975,7 +975,7 @@ def _cleanup_ports_on_failed_vm_launch(request, nics):
975 975
     LOG.debug('Cleaning up stale VM ports.')
976 976
     for nic in nics:
977 977
         try:
978
-            LOG.debug('Deleting port with id: %s' % nic['port-id'])
978
+            LOG.debug('Deleting port with id: %s', nic['port-id'])
979 979
             api.neutron.port_delete(request, nic['port-id'])
980 980
         except Exception:
981 981
             ports_failing_deletes.append(nic['port-id'])

+ 1
- 1
openstack_dashboard/dashboards/project/networks/ports/forms.py View File

@@ -223,7 +223,7 @@ class UpdatePort(forms.SelfHandlingForm):
223 223
     def handle(self, request, data):
224 224
         data['admin_state'] = (data['admin_state'] == 'True')
225 225
         try:
226
-            LOG.debug('params = %s' % data)
226
+            LOG.debug('params = %s', data)
227 227
             extension_kwargs = {}
228 228
             if 'binding__vnic_type' in data:
229 229
                 extension_kwargs['binding__vnic_type'] = \

+ 1
- 2
openstack_dashboard/dashboards/project/networks/subnets/workflows.py View File

@@ -188,8 +188,7 @@ class UpdateSubnet(network_workflows.CreateNetwork):
188 188
             self._setup_subnet_parameters(params, data, is_create=False)
189 189
 
190 190
             subnet = api.neutron.subnet_update(request, subnet_id, **params)
191
-            msg = _('Subnet "%s" was successfully updated.') % data['cidr']
192
-            LOG.debug(msg)
191
+            LOG.debug('Subnet "%s" was successfully updated.', data['cidr'])
193 192
             return subnet
194 193
         except Exception as e:
195 194
             msg = (_('Failed to update subnet "%(sub)s": '

+ 3
- 5
openstack_dashboard/dashboards/project/networks/workflows.py View File

@@ -467,9 +467,8 @@ class CreateNetwork(workflows.Workflow):
467 467
                       'shared': data['shared']}
468 468
             network = api.neutron.network_create(request, **params)
469 469
             self.context['net_id'] = network.id
470
-            msg = (_('Network "%s" was successfully created.') %
471
-                   network.name_or_id)
472
-            LOG.debug(msg)
470
+            LOG.debug('Network "%s" was successfully created.',
471
+                      network.name_or_id)
473 472
             return network
474 473
         except Exception as e:
475 474
             msg = (_('Failed to create network "%(network)s": %(reason)s') %
@@ -541,8 +540,7 @@ class CreateNetwork(workflows.Workflow):
541 540
 
542 541
             subnet = api.neutron.subnet_create(request, **params)
543 542
             self.context['subnet_id'] = subnet.id
544
-            msg = _('Subnet "%s" was successfully created.') % data['cidr']
545
-            LOG.debug(msg)
543
+            LOG.debug('Subnet "%s" was successfully created.', data['cidr'])
546 544
             return subnet
547 545
         except Exception as e:
548 546
             if network_name:

+ 1
- 1
openstack_dashboard/dashboards/project/stacks/forms.py View File

@@ -191,7 +191,7 @@ class TemplateForm(forms.SelfHandlingForm):
191 191
         # Uploaded file handler
192 192
         if has_upload and not url:
193 193
             log_template_name = files[upload_str].name
194
-            LOG.info('got upload %s' % log_template_name)
194
+            LOG.info('got upload %s', log_template_name)
195 195
 
196 196
             tpl = files[upload_str].read()
197 197
             if tpl.startswith('{'):

+ 2
- 2
openstack_dashboard/dashboards/project/stacks/tabs.py View File

@@ -100,7 +100,7 @@ class StackEventsTab(tabs.Tab):
100 100
         try:
101 101
             stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
102 102
             events = api.heat.events_list(self.request, stack_identifier)
103
-            LOG.debug('got events %s' % events)
103
+            LOG.debug('got events %s', events)
104 104
             # The stack id is needed to generate the resource URL.
105 105
             for event in events:
106 106
                 event.stack_id = stack.id
@@ -131,7 +131,7 @@ class StackResourcesTab(tabs.Tab):
131 131
         try:
132 132
             stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
133 133
             resources = api.heat.resources_list(self.request, stack_identifier)
134
-            LOG.debug('got resources %s' % resources)
134
+            LOG.debug('got resources %s', resources)
135 135
             # The stack id is needed to generate the resource URL.
136 136
             for r in resources:
137 137
                 r.stack_id = stack.id

+ 4
- 4
openstack_dashboard/dashboards/project/vpn/forms.py View File

@@ -57,7 +57,7 @@ class UpdateVPNService(forms.SelfHandlingForm):
57 57
             return vpnservice
58 58
         except Exception as e:
59 59
             msg = _('Failed to update VPN Service %s') % context['name']
60
-            LOG.info('%s: %s' % (msg, e))
60
+            LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
61 61
             redirect = reverse(self.failure_url)
62 62
             exceptions.handle(request, msg, redirect=redirect)
63 63
 
@@ -136,7 +136,7 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
136 136
             return ikepolicy
137 137
         except Exception as e:
138 138
             msg = _('Failed to update IKE Policy %s') % context['name']
139
-            LOG.info('%s: %s' % (msg, e))
139
+            LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
140 140
             redirect = reverse(self.failure_url)
141 141
             exceptions.handle(request, msg, redirect=redirect)
142 142
 
@@ -214,7 +214,7 @@ class UpdateIPSecPolicy(forms.SelfHandlingForm):
214 214
             return ipsecpolicy
215 215
         except Exception as e:
216 216
             msg = _('Failed to update IPSec Policy %s') % context['name']
217
-            LOG.info('%s: %s' % (msg, e))
217
+            LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
218 218
             redirect = reverse(self.failure_url)
219 219
             exceptions.handle(request, msg, redirect=redirect)
220 220
 
@@ -324,6 +324,6 @@ class UpdateIPSecSiteConnection(forms.SelfHandlingForm):
324 324
         except Exception as e:
325 325
             msg = (_('Failed to update IPSec Site Connection %s')
326 326
                    % context['name'])
327
-            LOG.info('%s: %s' % (msg, e))
327
+            LOG.info('%(msg)s: %(exception)s', {'msg': msg, 'exception': e})
328 328
             redirect = reverse(self.failure_url)
329 329
             exceptions.handle(request, msg, redirect=redirect)

+ 2
- 1
openstack_dashboard/django_pyscss_fix/__init__.py View File

@@ -33,4 +33,5 @@ try:
33 33
     if not os.path.exists(scss_asset_root):
34 34
         os.makedirs(scss_asset_root)
35 35
 except Exception as e:
36
-    LOG.info("Error precreating path %s, %s" % (scss_asset_root, e))
36
+    LOG.info("Error precreating path %(root)s, %(exc)s",
37
+             {'root': scss_asset_root, 'exc': e})

+ 1
- 1
openstack_dashboard/settings.py View File

@@ -360,7 +360,7 @@ if os.path.exists(LOCAL_SETTINGS_DIR_PATH):
360 360
                         exec(f.read())
361 361
                 except Exception as e:
362 362
                     logging.exception(
363
-                        "Can not exec settings snippet %s" % filename)
363
+                        "Can not exec settings snippet %s", filename)
364 364
 
365 365
 # The purpose of OPENSTACK_IMAGE_FORMATS is to provide a simple object
366 366
 # that does not contain the lazy-loaded translations, so the list can

+ 1
- 1
openstack_dashboard/theme_settings.py View File

@@ -77,7 +77,7 @@ def get_available_themes(available_themes, custom_path, default_path,
77 77
         default_theme = available_themes[custom_ndx][0]
78 78
         logging.warning("Your AVAILABLE_THEMES already contains your "
79 79
                         "CUSTOM_THEME_PATH, therefore using configuration in "
80
-                        "AVAILABLE_THEMES for %s." % custom_path)
80
+                        "AVAILABLE_THEMES for %s.", custom_path)
81 81
 
82 82
     elif custom_path is not None:
83 83
         new_theme_list.append(

+ 1
- 1
openstack_dashboard/utils/settings.py View File

@@ -29,7 +29,7 @@ def import_submodules(module):
29 29
             submodule = import_module(name)
30 30
         except ImportError as e:
31 31
             # FIXME: Make the errors non-fatal (do we want that?).
32
-            logging.warning("Error importing %s" % name)
32
+            logging.warning("Error importing %s", name)
33 33
             logging.exception(e)
34 34
         else:
35 35
             parent, child = name.rsplit('.', 1)

Loading…
Cancel
Save