Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use warning() method instead of warn() #25

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mom/Collectors/Collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_collectors(config_str, properties, global_config):
module = __import__('mom.Collectors.' + name, None, None, name)
collectors.append(getattr(module, name)(properties))
except ImportError:
logger.warn("Unable to import collector: %s", name)
logger.warning("Unable to import collector: %s", name)
return None
except FatalError as e:
logger.error("Fatal Collector error: %s", e.msg)
Expand Down
2 changes: 1 addition & 1 deletion mom/Collectors/GuestMemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def stats_error(self, msg):
problem. Otherwise the log will be overrun with noise.
"""
if self.memstats_available:
self.logger.warn(msg)
self.logger.warning(msg)
self.memstats_available = False

def collect(self):
Expand Down
8 changes: 4 additions & 4 deletions mom/Collectors/GuestNetworkDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def get_guest_ip(self, properties):
try:
output = Popen([prog, name], stdout=PIPE).communicate()[0].decode("utf-8")
except OSError as e:
self.logger.warn("Cannot call name-to-ip-helper: %s", e.strerror)
self.logger.warning("Cannot call name-to-ip-helper: %s", e.strerror)
return None
matches = re.findall(r"^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})",
output, re.M)
if len(matches) != 1:
self.logger.warn("Output from name-to-ip-helper %s is not an IP " \
"address. (output = '%s')", name, output)
self.logger.warning("Output from name-to-ip-helper %s is not an IP " \
"address. (output = '%s')", name, output)
return None
else:
ip = matches[0]
Expand Down Expand Up @@ -217,7 +217,7 @@ def session(self, conn, addr):
else:
break
except socket.error as msg:
self.logger.warn("Exception: %s" % msg)
self.logger.warning("Exception: %s" % msg)
break
sock_close(conn)
self.logger.debug("Connection closed")
Expand Down
6 changes: 3 additions & 3 deletions mom/Collectors/GuestQemuAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def __init__(self, properties):
socket_name = socket_name_template % {'name' : self.name}
except KeyError as e:
socket_name = self.name + '.agent'
self.logger.warn("Error substituting socket name " \
"template. Invalid key: %s" % e)
self.logger.warn("Using socket name %s." % socket_name)
self.logger.warning("Error substituting socket name " \
"template. Invalid key: %s" % e)
self.logger.warning("Using socket name %s." % socket_name)

self.sockets = [ None, "%s/%s" % (socket_path, socket_name) ]
self.agent = None
Expand Down
2 changes: 1 addition & 1 deletion mom/Controllers/KSM.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def write_value(self, fname, value):
with open(fname, 'w') as f:
f.write(str(value))
except IOError as e:
self.logger.warn("KSM: Failed to write %s: %s", fname, e.strerror)
self.logger.warning("KSM: Failed to write %s: %s", fname, e.strerror)

def process(self, host, guests):
outputs = {}
Expand Down
18 changes: 9 additions & 9 deletions mom/HypervisorInterfaces/libvirtInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ def _domainGetPid(self, uuid):
p1 = Popen(["ps", "axww"], stdout=PIPE).communicate()[0].decode("utf-8")
matches = re.findall(r"^\s*(\d+)\s+.*" + uuid, p1, re.M)
if len(matches) < 1:
self.logger.warn("No matching process for domain with uuid %s", \
uuid)
self.logger.warning("No matching process for domain with uuid %s", \
uuid)
return None
elif len(matches) > 1:
self.logger.warn("Too many process matches for domain with uuid %s",\
uuid)
self.logger.warning("Too many process matches for domain with uuid %s",\
uuid)
return None
return int(matches[0])

Expand All @@ -158,13 +158,13 @@ def _handleException(self, e):
do_nothing_errors = (libvirt.VIR_ERR_NO_DOMAIN,)
error = e.get_error_code()
if error in reconnect_errors:
self.logger.warn('libvirtInterface: connection lost, reconnecting.')
self.logger.warning('libvirtInterface: connection lost, reconnecting.')
self._reconnect()
elif error in do_nothing_errors:
pass
else:
self.logger.warn('libvirtInterface: Unhandled libvirt exception '\
'(%i).', error)
self.logger.warning('libvirtInterface: Unhandled libvirt exception '\
'(%i).', error)

def _domainSetBalloonTarget(self, domain, target):
try:
Expand Down Expand Up @@ -292,7 +292,7 @@ def setVmBalloonTarget(self, uuid, target):
if dom is not None:
if self._domainSetBalloonTarget(dom, target):
name = self._domainGetName(dom)
self.logger.warn("Error while ballooning guest:%i", name)
self.logger.warning("Error while ballooning guest:%i", name)

def setVmCpuTune(self, uuid, quota, period):
dom = self._getDomainFromUUID(uuid)
Expand All @@ -308,7 +308,7 @@ def write_value(fname, value):
with open(fname, 'w') as f:
f.write(str(value))
except IOError as e:
self.logger.warn("KSM: Failed to write %s: %s", fname, e.strerror)
self.logger.warning("KSM: Failed to write %s: %s", fname, e.strerror)

for (key, val) in tuningParams.items():
write_value('/sys/kernel/mm/ksm/%s' % key, val)
Expand Down
2 changes: 1 addition & 1 deletion mom/HypervisorInterfaces/vdsmjsonrpcclientInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
try:
use_tls = vdsmconfig.getboolean('vars', 'ssl')
except Exception as e:
self._logger.warn("Failed to read VDSM config file, using SSL connection. %s", e)
self._logger.warning("Failed to read VDSM config file, using SSL connection. %s", e)
use_tls = True

try:
Expand Down
2 changes: 1 addition & 1 deletion mom/Monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _disp_collection_error(self, message=None):
if self.ready is False:
self.logger.debug('%s: %s', self.name, message)
else: # True or None
self.logger.warn('%s: %s', self.name, message)
self.logger.warning('%s: %s', self.name, message)

def _set_not_ready(self, message=None):
self.ready = False
Expand Down
2 changes: 1 addition & 1 deletion mom/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, plot_dir, name):
self.file = open(filename, 'a')
except IOError as e:
logger = logging.getLogger('mom.Plotter')
logger.warn("Cannot open plot file %s: %s" , filename, e.strerror)
logger.warning("Cannot open plot file %s: %s" , filename, e.strerror)

def __del__(self):
if self.file is not None:
Expand Down
2 changes: 1 addition & 1 deletion mom/Policy/Policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def set_policy(self, name, policyStr):
try:
self.code = get_code(Evaluator(), self._cat_policies())
except PolicyError as e:
self.logger.warn("Unable to load policy: %s" % e)
self.logger.warning("Unable to load policy: %s" % e)
if oldStr is None:
del self.policy_strings[name]
else:
Expand Down
6 changes: 3 additions & 3 deletions mom/PolicyEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def read_policy(file_name, policy_name):
with open(file_name, 'r') as f:
policyStr = f.read()
except IOError as e:
self.logger.warn("Unable to read policy file: %s" % e)
self.logger.warning("Unable to read policy file: %s" % e)
return False
return self.policy.set_policy(policy_name, policyStr)

Expand All @@ -61,7 +61,7 @@ def read_policy(file_name, policy_name):
try:
names = sorted(os.listdir(policy_dir))
except OSError as e:
self.logger.warn("Unable to read directory '%s': %s" % (
self.logger.warning("Unable to read directory '%s': %s" % (
policy_dir, e.strerror))
return False
for name in names:
Expand Down Expand Up @@ -110,7 +110,7 @@ def get_controllers(self):
module = __import__('mom.Controllers.' + name, None, None, name)
self.logger.debug("Loaded %s controller", name)
except ImportError:
self.logger.warn("Unable to import controller: %s", name)
self.logger.warning("Unable to import controller: %s", name)
continue
self.controllers.append(getattr(module, name)(self.properties))

Expand Down
6 changes: 3 additions & 3 deletions mom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _get_plot_subdir(self, basedir):
try:
names = os.listdir(basedir)
except OSError as e:
self.logger.warn("Cannot read plot-basedir %s: %s", basedir, e.strerror)
self.logger.warning("Cannot read plot-basedir %s: %s", basedir, e.strerror)
return ''
seq_num = -1
for name in names:
Expand All @@ -198,13 +198,13 @@ def _get_plot_subdir(self, basedir):
seq_num = seq_num + 1
dir = "%s/momplot-%03d" % (basedir, seq_num)
if seq_num > 999:
self.logger.warn("Cannot create plot-dir because the sequence number "\
self.logger.warning("Cannot create plot-dir because the sequence number "\
"is out of range. Clear the directory or choose a different one")
return ''
try:
os.mkdir(dir)
except OSError as e:
self.logger.warn("Cannot create plot-dir %s: %s", dir, e.strerror)
self.logger.warning("Cannot create plot-dir %s: %s", dir, e.strerror)
return ''
return dir

Expand Down
Loading