Browse Source

Drop i18n support for log messages.

Starting with the Pike series, OpenStack no
longer supports log translation. This got discussed
on the ML with:
http://lists.openstack.org/pipermail/openstack-dev/2017-March/thread.html#113365
This change drops all LE, LW and LI translation helper usage.
Neutron commit here, which dropped the translation marker we imported:
https://github.com/openstack/neutron/commit/7322bd6

Change-Id: I37404141ecb87ea71c456133a15e485e69b08e38
tags/3.0.0.0rc1
sreeteja 1 year ago
parent
commit
5c0ee00415
3 changed files with 47 additions and 54 deletions
  1. 38
    44
      networking_dpm/ml2/dpm_neutron_agent.py
  2. 8
    9
      networking_dpm/ml2/mech_dpm.py
  3. 1
    1
      tox.ini

+ 38
- 44
networking_dpm/ml2/dpm_neutron_agent.py View File

@@ -27,9 +27,6 @@ from networking_dpm.conf import config
27 27
 from networking_dpm.ml2 import constants as const
28 28
 from networking_dpm.ml2.mech_dpm import AGENT_TYPE_DPM
29 29
 
30
-from neutron._i18n import _LE
31
-from neutron._i18n import _LI
32
-from neutron._i18n import _LW
33 30
 from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
34 31
 from neutron.common import config as common_config
35 32
 from neutron.common import topics
@@ -75,11 +72,9 @@ class PhysicalNetworkMapping(object):
75 72
                 'port': int(port)
76 73
             })
77 74
         except zhmcclient.NotFound:
78
-            LOG.error(
79
-                _LE("No vswitch object for adapter/port combination "
80
-                    "%(adapt)s/%(port)s found. Agent terminated!"),
81
-                {'adapt': adapter_id, 'port': port}
82
-            )
75
+            LOG.error("No vswitch object for adapter/port combination "
76
+                      "%(adapt)s/%(port)s found. Agent terminated!",
77
+                      {'adapt': adapter_id, 'port': port})
83 78
             sys.exit(1)
84 79
 
85 80
     def _add_vswitch(self, physnet, adapter_id, port):
@@ -87,10 +82,10 @@ class PhysicalNetworkMapping(object):
87 82
         self._vswitches.append(vswitch)
88 83
         if self._physnet_mapping.get(physnet):
89 84
             # TODO(andreas_s): Lift this restriction
90
-            LOG.error(_LE("Multiple vswitches for physical network "
91
-                          "%(net)s defined but only a single vswitch "
92
-                          "definition per physical network is supported."
93
-                          "Agent terminated!"),
85
+            LOG.error("Multiple vswitches for physical network "
86
+                      "%(net)s defined but only a single vswitch "
87
+                      "definition per physical network is supported."
88
+                      "Agent terminated!",
94 89
                       {'net': physnet})
95 90
             sys.exit(1)
96 91
         self._physnet_mapping[physnet] = [vswitch.get_property('object-id')]
@@ -101,9 +96,9 @@ class PhysicalNetworkMapping(object):
101 96
             # whole list of items is retrieved
102 97
             return self._cpc.adapters.find(**{'object-id': adapter_id})
103 98
         except zhmcclient.NotFound:
104
-            LOG.error(_LE("Configured adapter %s could not be "
105
-                          "found. Please update the agent "
106
-                          "configuration. Agent terminated!"),
99
+            LOG.error("Configured adapter %s could not be "
100
+                      "found. Please update the agent "
101
+                      "configuration. Agent terminated!",
107 102
                       adapter_id)
108 103
             sys.exit(1)
109 104
 
@@ -111,10 +106,10 @@ class PhysicalNetworkMapping(object):
111 106
     def _validate_adapter_type(adapter):
112 107
         adapt_type = adapter.get_property('type')
113 108
         if adapt_type not in ['osd', 'hipersockets']:
114
-            LOG.error(_LE("Configured adapter %s is not an OSA "
115
-                          "or a hipersockets adapter. Please update "
116
-                          "the agent configuration. Agent "
117
-                          "terminated!"), adapter)
109
+            LOG.error("Configured adapter %s is not an OSA "
110
+                      "or a hipersockets adapter. Please update "
111
+                      "the agent configuration. Agent "
112
+                      "terminated!", adapter)
118 113
             sys.exit(1)
119 114
 
120 115
     @staticmethod
@@ -124,11 +119,10 @@ class PhysicalNetworkMapping(object):
124 119
             # whole list of items is retrieved
125 120
             adapter.ports.find(**{'element-id': port})
126 121
         except zhmcclient.NotFound:
127
-            LOG.error(_LE("Configured port %(port)s for adapter "
128
-                          "%(adapt)s does not exist. Please update "
129
-                          "the agent configuration. Agent "
130
-                          "terminated!"), {'adapt': adapter,
131
-                                           'port': port})
122
+            LOG.error("Configured port %(port)s for adapter "
123
+                      "%(adapt)s does not exist. Please update "
124
+                      "the agent configuration. Agent "
125
+                      "terminated!", {'adapt': adapter, 'port': port})
132 126
             sys.exit(1)
133 127
 
134 128
     @staticmethod
@@ -260,8 +254,8 @@ class DPMManager(amb.CommonAgentManagerBase):
260 254
                     LOG.debug("NIC %s got deleted concurrently."
261 255
                               "Continuing...", nic)
262 256
                 else:
263
-                    LOG.warning(_LW("NIC %(nic)s will be reported as "
264
-                                    "'DOWN' due to error: %(err)s"),
257
+                    LOG.warning("NIC %(nic)s will be reported as "
258
+                                "'DOWN' due to error: %(err)s",
265 259
                                 {'nic': nic, 'err': http_error})
266 260
         return macs
267 261
 
@@ -278,16 +272,16 @@ class DPMManager(amb.CommonAgentManagerBase):
278 272
                 devices = devices.union(
279 273
                     self._filter_agent_managed_nic_macs(nics))
280 274
             except zhmcclient.ConnectionError as con_err:
281
-                LOG.error(_LE(
275
+                LOG.error(
282 276
                     "%(message)s, %(details)s. Lost connection to HMC of "
283 277
                     "CPC %(cpc)s. All NICs of this CPC and its corresponding "
284
-                    "Neutron ports wil be reported as 'DOWN'."),
278
+                    "Neutron ports wil be reported as 'DOWN'.",
285 279
                     {"cpc": self.cpc, "message": con_err,
286 280
                      "details": con_err.details})
287 281
 
288 282
             except zhmcclient.HTTPError as http_error:
289 283
                 if http_error.http_status == const.HTTP_STATUS_NOT_FOUND:
290
-                    LOG.error(_LE(
284
+                    LOG.error(
291 285
                         "An unrecoverable error occurred: %(err)s "
292 286
                         "DPM vSwitch object %(vswitch)s is "
293 287
                         "not available anymore. This can happen if "
@@ -296,16 +290,16 @@ class DPMManager(amb.CommonAgentManagerBase):
296 290
                         "hipersockets network got deleted. Please "
297 291
                         "check the physical_network_adapter_mappings "
298 292
                         "configuration and start the "
299
-                        "agent again. Agent terminated!"),
293
+                        "agent again. Agent terminated!",
300 294
                         {'vswitch': vswitch, 'err': http_error})
301 295
                     # Need to exit with sys.exit, as calling code catches
302 296
                     # exceptions
303 297
                     sys.exit(1)
304 298
 
305
-                LOG.warning(_LW("An error occurred while retrieving the "
306
-                                "connected nics of vswitch %(vswitch)s: "
307
-                                "%(err)s. All NICs of this vswitch will "
308
-                                "be reported as 'DOWN'."),
299
+                LOG.warning("An error occurred while retrieving the "
300
+                            "connected nics of vswitch %(vswitch)s: "
301
+                            "%(err)s. All NICs of this vswitch will "
302
+                            "be reported as 'DOWN'.",
309 303
                             {'vswitch': vswitch, 'err': http_error})
310 304
         return devices
311 305
 
@@ -343,11 +337,11 @@ def _validate_firewall_driver():
343 337
     supported_fw_drivers = ['neutron.agent.firewall.NoopFirewallDriver',
344 338
                             'noop']
345 339
     if fw_driver not in supported_fw_drivers:
346
-        LOG.error(_LE('Unsupported configuration option for "SECURITYGROUP.'
347
-                      'firewall_driver"! Only the NoopFirewallDriver is '
348
-                      'supported by DPM agent, but "%s" is configured. '
349
-                      'Set the firewall_driver to "noop" and start the '
350
-                      'agent again. Agent terminated!'),
340
+        LOG.error('Unsupported configuration option for "SECURITYGROUP.'
341
+                  'firewall_driver"! Only the NoopFirewallDriver is '
342
+                  'supported by DPM agent, but "%s" is configured. '
343
+                  'Set the firewall_driver to "noop" and start the '
344
+                  'agent again. Agent terminated!',
351 345
                   fw_driver)
352 346
         sys.exit(1)
353 347
 
@@ -357,9 +351,9 @@ def _get_cpc(client, cpc_oid):
357 351
         cpc = client.cpcs.find(**{'object-id': cpc_oid})
358 352
         if cpc.dpm_enabled:
359 353
             return cpc
360
-        LOG.error(_LE("CPC %s not in DPM mode.") % cpc_oid)
354
+        LOG.error("CPC %s not in DPM mode." % cpc_oid)
361 355
     except zhmcclient.NotFound:
362
-        LOG.error(_LE("Could not find CPC with object-id %s") % cpc_oid)
356
+        LOG.error("Could not find CPC with object-id %s" % cpc_oid)
363 357
     sys.exit(1)
364 358
 
365 359
 
@@ -371,8 +365,8 @@ def setup_logging():
371 365
     logging.set_defaults(default_log_levels=logging.get_default_log_levels() +
372 366
                          ["zhmcclient=WARNING"])
373 367
     logging.setup(CONF, 'neutron')
374
-    LOG.info(_LI("Logging enabled!"))
375
-    LOG.info(_LI("%(prog)s"), {'prog': sys.argv[0]})
368
+    LOG.info("Logging enabled!")
369
+    LOG.info("%(prog)s", {'prog': sys.argv[0]})
376 370
     LOG.debug("command line: %s", " ".join(sys.argv))
377 371
 
378 372
 
@@ -399,5 +393,5 @@ def main():
399 393
                                quitting_rpc_timeout,
400 394
                                AGENT_TYPE_DPM,
401 395
                                DPM_AGENT_BINARY)
402
-    LOG.info(_LI("Agent initialized successfully, now running... "))
396
+    LOG.info("Agent initialized successfully, now running... ")
403 397
     service.launch(CONF, agent).wait()

+ 8
- 9
networking_dpm/ml2/mech_dpm.py View File

@@ -17,7 +17,6 @@
17 17
 from neutron_lib.api.definitions import portbindings
18 18
 from oslo_log import log
19 19
 
20
-from neutron._i18n import _LW
21 20
 from neutron.plugins.common import constants as p_constants
22 21
 from neutron.plugins.ml2 import driver_api as api
23 22
 from neutron.plugins.ml2.drivers import mech_agent
@@ -64,16 +63,16 @@ class DPMMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
64 63
 
65 64
         object_ids = self.get_mappings(agent)[physnet]
66 65
         if not object_ids:
67
-            LOG.warning(_LW("No Object-IDs found in agents %(agent)s mapping "
68
-                            "for physical network %(net)s."), {'agent': agent,
69
-                                                               'net': physnet})
66
+            LOG.warning("No Object-IDs found in agents %(agent)s mapping "
67
+                        "for physical network %(net)s.", {'agent': agent,
68
+                                                          'net': physnet})
70 69
             return False
71 70
         if len(object_ids) > 1:
72
-            LOG.warning(_LW("More than one Object-ID for physical network "
73
-                            "%(net)s on agent %(agent)s found but only a "
74
-                            "single Object-ID is supported. Therefore the "
75
-                            "first one is being chosen!"), {'agent': agent,
76
-                                                            'net': physnet})
71
+            LOG.warning("More than one Object-ID for physical network "
72
+                        "%(net)s on agent %(agent)s found but only a "
73
+                        "single Object-ID is supported. Therefore the "
74
+                        "first one is being chosen!", {'agent': agent,
75
+                                                       'net': physnet})
77 76
         # TODO(andreas_s): In the first release only a single adapter/vswitch
78 77
         # per physical network is supported
79 78
         object_id = object_ids[0]

+ 1
- 1
tox.ini View File

@@ -44,7 +44,7 @@ commands = oslo_debug_helper {posargs}
44 44
 # N530 direct neutron imports not allowed
45 45
 
46 46
 show-source = True
47
-ignore = E123,E125,N530
47
+ignore = E123,E125,N530,N537
48 48
 builtins = _
49 49
 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.tmp
50 50
 

Loading…
Cancel
Save