Skip to content

Commit

Permalink
Use LOG.warning instead of deprecated LOG.warn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kajinamit committed Jun 7, 2024
1 parent c01a7a7 commit 2c2bb5e
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion cloudbaseinit/metadata/services/baseopenstackservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def _parse_dns_data(services_data):
for service_data in services_data:
service_type = service_data.get("type")
if service_type != NETWORK_SERVICE_TYPE_DNS:
LOG.warn("Skipping unsupported service type: %s", service_type)
LOG.warning("Skipping unsupported service type: %s",
service_type)
continue

address = service_data.get("address")
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/common/networkconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _process_network_details(self, network_details):
for mac in adapter_macs:
nic = macnics.pop(mac, None)
if not nic:
LOG.warn("Missing details for adapter %s", mac)
LOG.warning("Missing details for adapter %s", mac)
continue

name = osutils.get_network_adapter_name_by_mac_address(mac)
Expand Down Expand Up @@ -168,7 +168,7 @@ def _process_network_details(self, network_details):
reboot_required = reboot or reboot_required
configured = True
for mac in macnics:
LOG.warn("Details not used for adapter %s", mac)
LOG.warning("Details not used for adapter %s", mac)
if not configured:
LOG.error("No adapters were configured")

Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/common/setuserpassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def _get_password(self, service, shared_data):

if password:
injected = True
LOG.warn('Using admin_pass metadata user password. Consider '
'changing it as soon as possible')
LOG.warning('Using admin_pass metadata user password. Consider '
'changing it as soon as possible')
else:
password = shared_data.get(plugin_constant.SHARED_DATA_PASSWORD)

Expand Down
6 changes: 3 additions & 3 deletions cloudbaseinit/plugins/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def load_plugins(stage):
for class_path in CONF.plugins:
if class_path in OLD_PLUGINS:
new_class_path = OLD_PLUGINS[class_path]
LOG.warn("Old plugin module %r was found. The new name is %r. "
"The old name will not be supported starting with "
"cloudbaseinit 1.0", class_path, new_class_path)
LOG.warning("Old plugin module %r was found. The new name is %r. "
"The old name will not be supported starting with "
"cloudbaseinit 1.0", class_path, new_class_path)
class_path = new_class_path

try:
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/windows/azureguestagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ def execute(self, service, shared_data):
self._configure_rd_agent(osutils, ga_target_path)

if not osutils.check_dotnet_is_installed("4"):
LOG.warn("The .Net framework 4.5 or greater is required "
"by the Azure guest agent")
LOG.warning("The .Net framework 4.5 or greater is "
"required by the Azure guest agent")
else:
osutils.set_service_start_mode(
SERVICE_NAME_RDAGENT,
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/windows/winrmlistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ConfigWinRMListenerPlugin(base.BasePlugin):

def _check_winrm_service(self, osutils):
if not osutils.check_service_exists(self._winrm_service_name):
LOG.warn("Cannot configure the WinRM listener as the service "
"is not available")
LOG.warning("Cannot configure the WinRM listener as the service "
"is not available")
return False

start_mode = osutils.get_service_start_mode(self._winrm_service_name)
Expand Down
2 changes: 1 addition & 1 deletion cloudbaseinit/tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class LogSnatcher(object):
with LogSnatcher('plugins.windows.createuser') as snatcher:
LOG.info("doing stuff")
LOG.info("doing stuff %s", 1)
LOG.warn("doing other stuff")
LOG.warning("doing other stuff")
...
self.assertEqual(snatcher.output,
['INFO:unknown:doing stuff',
Expand Down
10 changes: 5 additions & 5 deletions cloudbaseinit/utils/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def set_hostname(osutils, hostname):
hostname = hostname.split('.', 1)[0]
if (len(hostname) > NETBIOS_HOST_NAME_MAX_LEN and
CONF.netbios_host_name_compatibility):
LOG.warn('Truncating host name for Netbios compatibility. '
'Old name: %(old_hostname)s, new name: '
'%(new_hostname)s' %
{'old_hostname': hostname,
'new_hostname': hostname[:NETBIOS_HOST_NAME_MAX_LEN]})
LOG.warning('Truncating host name for Netbios compatibility. '
'Old name: %(old_hostname)s, new name: '
'%(new_hostname)s' %
{'old_hostname': hostname,
'new_hostname': hostname[:NETBIOS_HOST_NAME_MAX_LEN]})
hostname = hostname[:NETBIOS_HOST_NAME_MAX_LEN]
hostname = re.sub(r'-$', '0', hostname)
if platform.node().lower() == hostname.lower():
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ def setup(product_name):
formatters.ContextFormatter(project=product_name,
datefmt=datefmt))
except serial.SerialException:
LOG.warn("Serial port: {0} could not be opened".format(
CONF.logging_serial_port_settings))
LOG.warning("Serial port: {0} could not be opened".format(
CONF.logging_serial_port_settings))

0 comments on commit 2c2bb5e

Please sign in to comment.