Browse Source

Replace deprecated LOG.warn with warning

LOG.warn is deprecated. It still used in a few places. This updates
those one to use the non-deprecated LOG.warning instead.

Closes-Bug: 1508442
Change-Id: Id947e4c8ae9894f480192a5ab034c24c25125788
tags/4.3.0
Anton Arefiev 4 years ago
parent
commit
5d22ccf016

+ 4
- 4
ironic/common/disk_partitioner.py View File

@@ -214,10 +214,10 @@ def list_partitions(device):
214 214
     for line in lines:
215 215
         match = _PARTED_PRINT_RE.match(line)
216 216
         if match is None:
217
-            LOG.warn(_LW("Partition information from parted for device "
218
-                         "%(device)s does not match "
219
-                         "expected format: %(line)s"),
220
-                     dict(device=device, line=line))
217
+            LOG.warning(_LW("Partition information from parted for device "
218
+                            "%(device)s does not match "
219
+                            "expected format: %(line)s"),
220
+                        dict(device=device, line=line))
221 221
             continue
222 222
         # Cast int fields to ints (some are floats and we round them down)
223 223
         groups = [int(float(x)) if i < 4 else x

+ 11
- 9
ironic/common/utils.py View File

@@ -476,8 +476,8 @@ def unlink_without_raise(path):
476 476
         if e.errno == errno.ENOENT:
477 477
             return
478 478
         else:
479
-            LOG.warn(_LW("Failed to unlink %(path)s, error: %(e)s"),
480
-                     {'path': path, 'e': e})
479
+            LOG.warning(_LW("Failed to unlink %(path)s, error: %(e)s"),
480
+                        {'path': path, 'e': e})
481 481
 
482 482
 
483 483
 def rmtree_without_raise(path):
@@ -485,8 +485,8 @@ def rmtree_without_raise(path):
485 485
         if os.path.isdir(path):
486 486
             shutil.rmtree(path)
487 487
     except OSError as e:
488
-        LOG.warn(_LW("Failed to remove dir %(path)s, error: %(e)s"),
489
-                 {'path': path, 'e': e})
488
+        LOG.warning(_LW("Failed to remove dir %(path)s, error: %(e)s"),
489
+                    {'path': path, 'e': e})
490 490
 
491 491
 
492 492
 def write_to_file(path, contents):
@@ -501,9 +501,10 @@ def create_link_without_raise(source, link):
501 501
         if e.errno == errno.EEXIST:
502 502
             return
503 503
         else:
504
-            LOG.warn(_LW("Failed to create symlink from %(source)s to %(link)s"
505
-                         ", error: %(e)s"),
506
-                     {'source': source, 'link': link, 'e': e})
504
+            LOG.warning(
505
+                _LW("Failed to create symlink from %(source)s to %(link)s"
506
+                    ", error: %(e)s"),
507
+                {'source': source, 'link': link, 'e': e})
507 508
 
508 509
 
509 510
 def safe_rstrip(value, chars=None):
@@ -515,8 +516,9 @@ def safe_rstrip(value, chars=None):
515 516
 
516 517
     """
517 518
     if not isinstance(value, six.string_types):
518
-        LOG.warn(_LW("Failed to remove trailing character. Returning original "
519
-                     "object. Supplied object is not a string: %s,"), value)
519
+        LOG.warning(_LW("Failed to remove trailing character. Returning "
520
+                        "original object. Supplied object is not a string: "
521
+                        "%s,"), value)
520 522
         return value
521 523
 
522 524
     return value.rstrip(chars) or value

+ 9
- 8
ironic/conductor/manager.py View File

@@ -286,9 +286,10 @@ class ConductorManager(periodic_task.PeriodicTasks):
286 286
         except exception.ConductorAlreadyRegistered:
287 287
             # This conductor was already registered and did not shut down
288 288
             # properly, so log a warning and update the record.
289
-            LOG.warn(_LW("A conductor with hostname %(hostname)s "
290
-                         "was previously registered. Updating registration"),
291
-                     {'hostname': self.host})
289
+            LOG.warning(
290
+                _LW("A conductor with hostname %(hostname)s "
291
+                    "was previously registered. Updating registration"),
292
+                {'hostname': self.host})
292 293
             cdr = self.dbapi.register_conductor({'hostname': self.host,
293 294
                                                  'drivers': self.drivers},
294 295
                                                 update_existing=True)
@@ -1789,27 +1790,27 @@ class ConductorManager(periodic_task.PeriodicTasks):
1789 1790
                     sensors_data = task.driver.management.get_sensors_data(
1790 1791
                         task)
1791 1792
             except NotImplementedError:
1792
-                LOG.warn(_LW(
1793
+                LOG.warning(_LW(
1793 1794
                     'get_sensors_data is not implemented for driver'
1794 1795
                     ' %(driver)s, node_uuid is %(node)s'),
1795 1796
                     {'node': node_uuid, 'driver': driver})
1796 1797
             except exception.FailedToParseSensorData as fps:
1797
-                LOG.warn(_LW(
1798
+                LOG.warning(_LW(
1798 1799
                     "During get_sensors_data, could not parse "
1799 1800
                     "sensor data for node %(node)s. Error: %(err)s."),
1800 1801
                     {'node': node_uuid, 'err': str(fps)})
1801 1802
             except exception.FailedToGetSensorData as fgs:
1802
-                LOG.warn(_LW(
1803
+                LOG.warning(_LW(
1803 1804
                     "During get_sensors_data, could not get "
1804 1805
                     "sensor data for node %(node)s. Error: %(err)s."),
1805 1806
                     {'node': node_uuid, 'err': str(fgs)})
1806 1807
             except exception.NodeNotFound:
1807
-                LOG.warn(_LW(
1808
+                LOG.warning(_LW(
1808 1809
                     "During send_sensor_data, node %(node)s was not "
1809 1810
                     "found and presumed deleted by another process."),
1810 1811
                     {'node': node_uuid})
1811 1812
             except Exception as e:
1812
-                LOG.warn(_LW(
1813
+                LOG.warning(_LW(
1813 1814
                     "Failed to get sensor data for node %(node)s. "
1814 1815
                     "Error: %(error)s"), {'node': node_uuid, 'error': str(e)})
1815 1816
             else:

+ 5
- 5
ironic/conductor/utils.py View File

@@ -89,15 +89,15 @@ def node_power_action(task, new_state):
89 89
             node['power_state'] = new_state
90 90
             node['target_power_state'] = states.NOSTATE
91 91
             node.save()
92
-            LOG.warn(_LW("Not going to change node power state because "
93
-                         "current state = requested state = '%(state)s'."),
94
-                     {'state': curr_state})
92
+            LOG.warning(_LW("Not going to change node power state because "
93
+                            "current state = requested state = '%(state)s'."),
94
+                        {'state': curr_state})
95 95
             return
96 96
 
97 97
         if curr_state == states.ERROR:
98 98
             # be optimistic and continue action
99
-            LOG.warn(_LW("Driver returns ERROR power state for node %s."),
100
-                     node.uuid)
99
+            LOG.warning(_LW("Driver returns ERROR power state for node %s."),
100
+                        node.uuid)
101 101
 
102 102
     # Set the target_power_state and clear any last_error, if we're
103 103
     # starting a new operation. This will expose to other processes

+ 3
- 2
ironic/db/sqlalchemy/api.py View File

@@ -578,8 +578,9 @@ class Connection(api.Connection):
578 578
 
579 579
         if nodes:
580 580
             nodes = ', '.join(nodes)
581
-            LOG.warn(_LW('Cleared reservations held by %(hostname)s: '
582
-                         '%(nodes)s'), {'hostname': hostname, 'nodes': nodes})
581
+            LOG.warning(
582
+                _LW('Cleared reservations held by %(hostname)s: '
583
+                    '%(nodes)s'), {'hostname': hostname, 'nodes': nodes})
583 584
 
584 585
     def get_active_driver_dict(self, interval=None):
585 586
         if interval is None:

+ 4
- 4
ironic/dhcp/neutron.py View File

@@ -279,10 +279,10 @@ class NeutronDHCPApi(base.BaseDHCP):
279 279
                 failures.append(port.uuid)
280 280
 
281 281
         if failures:
282
-            LOG.warn(_LW("Some errors were encountered on node %(node)s"
283
-                         " while retrieving IP address on the following"
284
-                         " ports: %(ports)s."),
285
-                     {'node': task.node.uuid, 'ports': failures})
282
+            LOG.warning(_LW("Some errors were encountered on node %(node)s"
283
+                            " while retrieving IP address on the following"
284
+                            " ports: %(ports)s."),
285
+                        {'node': task.node.uuid, 'ports': failures})
286 286
 
287 287
         return ip_addresses
288 288
 

+ 1
- 1
ironic/drivers/base.py View File

@@ -1055,7 +1055,7 @@ def driver_periodic_task(parallel=True, **other):
1055 1055
 
1056 1056
                 eventlet.greenthread.spawn_n(_internal)
1057 1057
             else:
1058
-                LOG.warn(_LW(
1058
+                LOG.warning(_LW(
1059 1059
                     'Using periodic tasks with parallel=False is deprecated, '
1060 1060
                     '"parallel" argument will be ignored starting with '
1061 1061
                     'the Mitaka release'))

+ 2
- 2
ironic/drivers/modules/drac/bios.py View File

@@ -356,8 +356,8 @@ def set_config(task, **kwargs):
356 356
             attrib_names.append(k)
357 357
 
358 358
     if unchanged_attribs:
359
-        LOG.warn(_LW('Ignoring unchanged BIOS settings %r'),
360
-                 unchanged_attribs)
359
+        LOG.warning(_LW('Ignoring unchanged BIOS settings %r'),
360
+                    unchanged_attribs)
361 361
 
362 362
     if invalid_attribs_msgs or read_only_keys:
363 363
         raise exception.DracOperationFailed(

+ 2
- 2
ironic/drivers/modules/ilo/deploy.py View File

@@ -447,8 +447,8 @@ def _disable_secure_boot_if_supported(task):
447 447
     # attempted deploy. Handling this exception here, will help the
448 448
     # user to tear down such a Node.
449 449
     except exception.IloOperationNotSupported:
450
-        LOG.warn(_LW('Secure boot mode is not supported for node %s'),
451
-                 task.node.uuid)
450
+        LOG.warning(_LW('Secure boot mode is not supported for node %s'),
451
+                    task.node.uuid)
452 452
 
453 453
 
454 454
 class IloVirtualMediaIscsiDeploy(base.DeployInterface):

+ 3
- 3
ironic/drivers/modules/ilo/inspect.py View File

@@ -56,9 +56,9 @@ def _create_ports_if_not_exist(node, macs):
56 56
             LOG.info(_LI("Port created for MAC address %(address)s for node "
57 57
                          "%(node)s"), {'address': mac, 'node': node.uuid})
58 58
         except exception.MACAlreadyExists:
59
-            LOG.warn(_LW("Port already exists for MAC address %(address)s "
60
-                         "for node %(node)s"),
61
-                     {'address': mac, 'node': node.uuid})
59
+            LOG.warning(_LW("Port already exists for MAC address %(address)s "
60
+                            "for node %(node)s"),
61
+                        {'address': mac, 'node': node.uuid})
62 62
 
63 63
 
64 64
 def _get_essential_properties(node, ilo_object):

+ 3
- 3
ironic/drivers/modules/ilo/management.py View File

@@ -98,9 +98,9 @@ def _execute_ilo_clean_step(node, step, *args, **kwargs):
98 98
     except ilo_error.IloCommandNotSupportedError:
99 99
         # This clean step is not supported on Gen8 and below servers.
100 100
         # Log the failure and continue with cleaning.
101
-        LOG.warn(_LW("'%(step)s' clean step is not supported on node "
102
-                     "%(uuid)s. Skipping the clean step."),
103
-                 {'step': step, 'uuid': node.uuid})
101
+        LOG.warning(_LW("'%(step)s' clean step is not supported on node "
102
+                        "%(uuid)s. Skipping the clean step."),
103
+                    {'step': step, 'uuid': node.uuid})
104 104
     except ilo_error.IloError as ilo_exception:
105 105
         raise exception.NodeCleaningFailure(_(
106 106
             "Clean step %(step)s failed "

+ 14
- 13
ironic/drivers/modules/image_cache.py View File

@@ -201,10 +201,11 @@ class ImageCache(object):
201 201
             return
202 202
         amount = self._clean_up_ensure_cache_size(survived, amount)
203 203
         if amount is not None and amount > 0:
204
-            LOG.warn(_LW("Cache clean up was unable to reclaim %(required)d "
205
-                         "MiB of disk space, still %(left)d MiB required"),
206
-                     {'required': amount_copy / 1024 / 1024,
207
-                      'left': amount / 1024 / 1024})
204
+            LOG.warning(
205
+                _LW("Cache clean up was unable to reclaim %(required)d "
206
+                    "MiB of disk space, still %(left)d MiB required"),
207
+                {'required': amount_copy / 1024 / 1024,
208
+                 'left': amount / 1024 / 1024})
208 209
 
209 210
     def _clean_up_too_old(self, listing, amount):
210 211
         """Clean up stage 1: drop images that are older than TTL.
@@ -228,9 +229,9 @@ class ImageCache(object):
228 229
                 try:
229 230
                     os.unlink(file_name)
230 231
                 except EnvironmentError as exc:
231
-                    LOG.warn(_LW("Unable to delete file %(name)s from "
232
-                                 "master image cache: %(exc)s"),
233
-                             {'name': file_name, 'exc': exc})
232
+                    LOG.warning(_LW("Unable to delete file %(name)s from "
233
+                                    "master image cache: %(exc)s"),
234
+                                {'name': file_name, 'exc': exc})
234 235
                 else:
235 236
                     if amount is not None:
236 237
                         amount -= stat.st_size
@@ -267,9 +268,9 @@ class ImageCache(object):
267 268
             try:
268 269
                 os.unlink(file_name)
269 270
             except EnvironmentError as exc:
270
-                LOG.warn(_LW("Unable to delete file %(name)s from "
271
-                             "master image cache: %(exc)s"),
272
-                         {'name': file_name, 'exc': exc})
271
+                LOG.warning(_LW("Unable to delete file %(name)s from "
272
+                                "master image cache: %(exc)s"),
273
+                            {'name': file_name, 'exc': exc})
273 274
             else:
274 275
                 total_size -= stat.st_size
275 276
                 if amount is not None:
@@ -402,9 +403,9 @@ def _delete_master_path_if_stale(master_path, href, ctx):
402 403
         if not img_mtime:
403 404
             # This means that href is not a glance image and doesn't have an
404 405
             # updated_at attribute
405
-            LOG.warn(_LW("Image service couldn't determine last "
406
-                         "modification time of %(href)s, considering "
407
-                         "cached image up to date."), {'href': href})
406
+            LOG.warning(_LW("Image service couldn't determine last "
407
+                            "modification time of %(href)s, considering "
408
+                            "cached image up to date."), {'href': href})
408 409
             return True
409 410
         master_mtime = utils.unix_file_modification_datetime(master_path)
410 411
         if img_mtime <= master_mtime:

+ 16
- 13
ironic/drivers/modules/pxe.py View File

@@ -134,10 +134,11 @@ def _get_pxe_conf_option(task, opt_name):
134 134
                                               CONF.pybasedir)
135 135
 
136 136
         if current_value != default_value:
137
-            LOG.warn(_LW("The CONF option [agent]agent_%(opt_name)s is "
138
-                         "deprecated and will be removed in Mitaka release of "
139
-                         "Ironic. Please use [pxe]%(opt_name)s instead."),
140
-                     {'opt_name': opt_name})
137
+            LOG.warning(
138
+                _LW("The CONF option [agent]agent_%(opt_name)s is "
139
+                    "deprecated and will be removed in Mitaka release of "
140
+                    "Ironic. Please use [pxe]%(opt_name)s instead."),
141
+                {'opt_name': opt_name})
141 142
             return current_value
142 143
 
143 144
     # Either task.driver.deploy is ISCSIDeploy() or the default value hasn't
@@ -541,16 +542,18 @@ class PXEBoot(base.BootInterface):
541 542
                 ]
542 543
             except KeyError:
543 544
                 if not iwdi:
544
-                    LOG.warn(_LW("The UUID for the root partition can't be "
545
-                                 "found, unable to switch the pxe config from "
546
-                                 "deployment mode to service (boot) mode for "
547
-                                 "node %(node)s"), {"node": task.node.uuid})
545
+                    LOG.warning(
546
+                        _LW("The UUID for the root partition can't be "
547
+                            "found, unable to switch the pxe config from "
548
+                            "deployment mode to service (boot) mode for "
549
+                            "node %(node)s"), {"node": task.node.uuid})
548 550
                 else:
549
-                    LOG.warn(_LW("The disk id for the whole disk image can't "
550
-                                 "be found, unable to switch the pxe config "
551
-                                 "from deployment mode to service (boot) mode "
552
-                                 "for node %(node)s"),
553
-                             {"node": task.node.uuid})
551
+                    LOG.warning(
552
+                        _LW("The disk id for the whole disk image can't "
553
+                            "be found, unable to switch the pxe config "
554
+                            "from deployment mode to service (boot) mode "
555
+                            "for node %(node)s"),
556
+                        {"node": task.node.uuid})
554 557
             else:
555 558
                 pxe_config_path = pxe_utils.get_pxe_config_file_path(
556 559
                     task.node.uuid)

+ 2
- 2
ironic/drivers/utils.py View File

@@ -143,8 +143,8 @@ def get_node_capability(node, capability):
143 143
             if parts[0].strip() == capability:
144 144
                 return parts[1].strip()
145 145
         else:
146
-            LOG.warn(_LW("Ignoring malformed capability '%s'. "
147
-                         "Format should be 'key:val'."), node_capability)
146
+            LOG.warning(_LW("Ignoring malformed capability '%s'. "
147
+                            "Format should be 'key:val'."), node_capability)
148 148
 
149 149
 
150 150
 def add_node_capability(task, capability, value):

+ 1
- 1
ironic/tests/unit/common/test_disk_partitioner.py View File

@@ -186,7 +186,7 @@ BYT;
186 186
             'parted', '-s', '-m', '/dev/fake', 'unit', 'MiB', 'print',
187 187
             use_standard_locale=True, run_as_root=True)
188 188
 
189
-    @mock.patch.object(disk_partitioner.LOG, 'warn', autospec=True)
189
+    @mock.patch.object(disk_partitioner.LOG, 'warning', autospec=True)
190 190
     def test_incorrect(self, log_mock, execute_mock):
191 191
         output = """
192 192
 BYT;

+ 6
- 3
ironic/tests/unit/drivers/modules/ilo/test_deploy.py View File

@@ -843,7 +843,8 @@ class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase):
843 843
             self.assertNotIn('boot_iso_created_in_web_server', dinfo)
844 844
             self.assertNotIn('root_uuid_or_disk_id', dinfo)
845 845
 
846
-    @mock.patch.object(ilo_deploy.LOG, 'warn', spec_set=True, autospec=True)
846
+    @mock.patch.object(ilo_deploy.LOG, 'warning',
847
+                       spec_set=True, autospec=True)
847 848
     @mock.patch.object(ilo_deploy, 'exception', spec_set=True, autospec=True)
848 849
     @mock.patch.object(ilo_deploy, '_update_secure_boot_mode', spec_set=True,
849 850
                        autospec=True)
@@ -987,7 +988,8 @@ class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
987 988
             update_secure_boot_mode_mock.assert_called_once_with(task, False)
988 989
             self.assertEqual(states.DELETED, returned_state)
989 990
 
990
-    @mock.patch.object(ilo_deploy.LOG, 'warn', spec_set=True, autospec=True)
991
+    @mock.patch.object(ilo_deploy.LOG, 'warning',
992
+                       spec_set=True, autospec=True)
991 993
     @mock.patch.object(ilo_deploy, 'exception', spec_set=True, autospec=True)
992 994
     @mock.patch.object(ilo_deploy, '_update_secure_boot_mode', spec_set=True,
993 995
                        autospec=True)
@@ -1730,7 +1732,8 @@ class IloPXEDeployTestCase(db_base.DbTestCase):
1730 1732
             pxe_tear_down_mock.assert_called_once_with(mock.ANY, task)
1731 1733
             self.assertEqual(states.DELETED, returned_state)
1732 1734
 
1733
-    @mock.patch.object(ilo_deploy.LOG, 'warn', spec_set=True, autospec=True)
1735
+    @mock.patch.object(ilo_deploy.LOG, 'warning',
1736
+                       spec_set=True, autospec=True)
1734 1737
     @mock.patch.object(iscsi_deploy.ISCSIDeploy, 'tear_down',
1735 1738
                        spec_set=True, autospec=True)
1736 1739
     @mock.patch.object(ilo_deploy, 'exception', spec_set=True, autospec=True)

+ 2
- 1
ironic/tests/unit/drivers/modules/ilo/test_inspect.py View File

@@ -243,7 +243,8 @@ class TestInspectPrivateMethods(db_base.DbTestCase):
243 243
         db_obj.create_port.assert_any_call(port_dict1)
244 244
         db_obj.create_port.assert_any_call(port_dict2)
245 245
 
246
-    @mock.patch.object(ilo_inspect.LOG, 'warn', spec_set=True, autospec=True)
246
+    @mock.patch.object(ilo_inspect.LOG, 'warning',
247
+                       spec_set=True, autospec=True)
247 248
     @mock.patch.object(dbapi, 'get_instance', spec_set=True, autospec=True)
248 249
     def test__create_ports_if_not_exist_mac_exception(self,
249 250
                                                       instance_mock,

+ 1
- 1
ironic/tests/unit/drivers/modules/ilo/test_management.py View File

@@ -220,7 +220,7 @@ class IloManagementTestCase(db_base.DbTestCase):
220 220
         ilo_management._execute_ilo_clean_step(
221 221
             self.node, 'fake-step', 'args', kwarg='kwarg')
222 222
         clean_step_mock.assert_called_once_with('args', kwarg='kwarg')
223
-        self.assertTrue(log_mock.warn.called)
223
+        self.assertTrue(log_mock.warning.called)
224 224
 
225 225
     @mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
226 226
                        autospec=True)

+ 1
- 1
ironic/tests/unit/drivers/modules/test_image_cache.py View File

@@ -469,7 +469,7 @@ class TestImageCacheCleanUp(base.TestCase):
469 469
                           'uuid', 'fake', 'fake')
470 470
         self.assertTrue(mock_rmtree.called)
471 471
 
472
-    @mock.patch.object(image_cache.LOG, 'warn', autospec=True)
472
+    @mock.patch.object(image_cache.LOG, 'warning', autospec=True)
473 473
     @mock.patch.object(image_cache.ImageCache, '_clean_up_too_old',
474 474
                        autospec=True)
475 475
     @mock.patch.object(image_cache.ImageCache, '_clean_up_ensure_cache_size',

Loading…
Cancel
Save