Skip to content

Commit 2c2bb5e

Browse files
committed
Use LOG.warning instead of deprecated LOG.warn
The LOG.warn method is deprecated[1] and the LOG.warning method should be used instead. [1] https://docs.python.org/3/library/logging.html#logging.warning Change-Id: I9037d4dfc680586ec5aa14d6f57e12dbdc4a4b91
1 parent c01a7a7 commit 2c2bb5e

9 files changed

Lines changed: 21 additions & 20 deletions

File tree

cloudbaseinit/metadata/services/baseopenstackservice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ def _parse_dns_data(services_data):
167167
for service_data in services_data:
168168
service_type = service_data.get("type")
169169
if service_type != NETWORK_SERVICE_TYPE_DNS:
170-
LOG.warn("Skipping unsupported service type: %s", service_type)
170+
LOG.warning("Skipping unsupported service type: %s",
171+
service_type)
171172
continue
172173

173174
address = service_data.get("address")

cloudbaseinit/plugins/common/networkconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _process_network_details(self, network_details):
140140
for mac in adapter_macs:
141141
nic = macnics.pop(mac, None)
142142
if not nic:
143-
LOG.warn("Missing details for adapter %s", mac)
143+
LOG.warning("Missing details for adapter %s", mac)
144144
continue
145145

146146
name = osutils.get_network_adapter_name_by_mac_address(mac)
@@ -168,7 +168,7 @@ def _process_network_details(self, network_details):
168168
reboot_required = reboot or reboot_required
169169
configured = True
170170
for mac in macnics:
171-
LOG.warn("Details not used for adapter %s", mac)
171+
LOG.warning("Details not used for adapter %s", mac)
172172
if not configured:
173173
LOG.error("No adapters were configured")
174174

cloudbaseinit/plugins/common/setuserpassword.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def _get_password(self, service, shared_data):
4040

4141
if password:
4242
injected = True
43-
LOG.warn('Using admin_pass metadata user password. Consider '
44-
'changing it as soon as possible')
43+
LOG.warning('Using admin_pass metadata user password. Consider '
44+
'changing it as soon as possible')
4545
else:
4646
password = shared_data.get(plugin_constant.SHARED_DATA_PASSWORD)
4747

cloudbaseinit/plugins/factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def load_plugins(stage):
5959
for class_path in CONF.plugins:
6060
if class_path in OLD_PLUGINS:
6161
new_class_path = OLD_PLUGINS[class_path]
62-
LOG.warn("Old plugin module %r was found. The new name is %r. "
63-
"The old name will not be supported starting with "
64-
"cloudbaseinit 1.0", class_path, new_class_path)
62+
LOG.warning("Old plugin module %r was found. The new name is %r. "
63+
"The old name will not be supported starting with "
64+
"cloudbaseinit 1.0", class_path, new_class_path)
6565
class_path = new_class_path
6666

6767
try:

cloudbaseinit/plugins/windows/azureguestagent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ def execute(self, service, shared_data):
241241
self._configure_rd_agent(osutils, ga_target_path)
242242

243243
if not osutils.check_dotnet_is_installed("4"):
244-
LOG.warn("The .Net framework 4.5 or greater is required "
245-
"by the Azure guest agent")
244+
LOG.warning("The .Net framework 4.5 or greater is "
245+
"required by the Azure guest agent")
246246
else:
247247
osutils.set_service_start_mode(
248248
SERVICE_NAME_RDAGENT,

cloudbaseinit/plugins/windows/winrmlistener.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class ConfigWinRMListenerPlugin(base.BasePlugin):
3434

3535
def _check_winrm_service(self, osutils):
3636
if not osutils.check_service_exists(self._winrm_service_name):
37-
LOG.warn("Cannot configure the WinRM listener as the service "
38-
"is not available")
37+
LOG.warning("Cannot configure the WinRM listener as the service "
38+
"is not available")
3939
return False
4040

4141
start_mode = osutils.get_service_start_mode(self._winrm_service_name)

cloudbaseinit/tests/testutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class LogSnatcher(object):
8484
with LogSnatcher('plugins.windows.createuser') as snatcher:
8585
LOG.info("doing stuff")
8686
LOG.info("doing stuff %s", 1)
87-
LOG.warn("doing other stuff")
87+
LOG.warning("doing other stuff")
8888
...
8989
self.assertEqual(snatcher.output,
9090
['INFO:unknown:doing stuff',

cloudbaseinit/utils/hostname.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def set_hostname(osutils, hostname):
4545
hostname = hostname.split('.', 1)[0]
4646
if (len(hostname) > NETBIOS_HOST_NAME_MAX_LEN and
4747
CONF.netbios_host_name_compatibility):
48-
LOG.warn('Truncating host name for Netbios compatibility. '
49-
'Old name: %(old_hostname)s, new name: '
50-
'%(new_hostname)s' %
51-
{'old_hostname': hostname,
52-
'new_hostname': hostname[:NETBIOS_HOST_NAME_MAX_LEN]})
48+
LOG.warning('Truncating host name for Netbios compatibility. '
49+
'Old name: %(old_hostname)s, new name: '
50+
'%(new_hostname)s' %
51+
{'old_hostname': hostname,
52+
'new_hostname': hostname[:NETBIOS_HOST_NAME_MAX_LEN]})
5353
hostname = hostname[:NETBIOS_HOST_NAME_MAX_LEN]
5454
hostname = re.sub(r'-$', '0', hostname)
5555
if platform.node().lower() == hostname.lower():

cloudbaseinit/utils/log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ def setup(product_name):
101101
formatters.ContextFormatter(project=product_name,
102102
datefmt=datefmt))
103103
except serial.SerialException:
104-
LOG.warn("Serial port: {0} could not be opened".format(
105-
CONF.logging_serial_port_settings))
104+
LOG.warning("Serial port: {0} could not be opened".format(
105+
CONF.logging_serial_port_settings))

0 commit comments

Comments
 (0)