Change in vdsm[master]: hostdev: use specific device classes in HostDevice
by Martin Polednik
Martin Polednik has posted comments on this change.
Change subject: hostdev: use specific device classes in HostDevice
......................................................................
Patch Set 8:
(1 comment)
https://gerrit.ovirt.org/#/c/57963/8/vdsm/virt/vmdevices/hostdevice.py
File vdsm/virt/vmdevices/hostdevice.py:
PS8, Line 320: @classmethod
: def update_device_info(cls, vm, device_conf):
: for device_xml in vm.domain.get_device_elements('hostdev'):
: device_type = device_xml.getAttribute('type')
: cls._DEVICE_MAPPING[device_type].update_device_info(
: vm, device_conf, device_xml)
> another alternative:
That is slightly confusing. I don't understand how we'd create the device classes without special case in vm.py's code again.
--
To view, visit https://gerrit.ovirt.org/57963
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2734b7ec789c0ce57b64d7699cbe967c774bb608
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
Gerrit-HasComments: Yes
7 years, 10 months
Change in vdsm[master]: hostdev: use specific device classes in HostDevice
by fromani@redhat.com
Francesco Romani has posted comments on this change.
Change subject: hostdev: use specific device classes in HostDevice
......................................................................
Patch Set 8:
(1 comment)
https://gerrit.ovirt.org/#/c/57963/8/vdsm/virt/vmdevices/hostdevice.py
File vdsm/virt/vmdevices/hostdevice.py:
PS8, Line 320: @classmethod
: def update_device_info(cls, vm, device_conf):
: for device_xml in vm.domain.get_device_elements('hostdev'):
: device_type = device_xml.getAttribute('type')
: cls._DEVICE_MAPPING[device_type].update_device_info(
: vm, device_conf, device_xml)
another alternative:
have a simple empty base class:
class _HostDevice(core.Base):
@classmethod
def update_device_info(cls, vm, device_conf):
for device_xml in vm.domain.get_device_elements('hostdev'):
device_type = device_xml.getAttribute('type')
cls._DEVICE_MAPPING[device_type].update_device_info(
vm, device_conf, device_xml)
have a module function like
def new(conf, log **kwargs):
device_params = get_device_params(kwargs['device'])
device = cls._DEVICE_MAPPING[
device_params['capability']](conf, log, **kwargs)
return device
perhaps overall simpler?
again, no real strong feelings against __new__, just tryint different approaches
--
To view, visit https://gerrit.ovirt.org/57963
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2734b7ec789c0ce57b64d7699cbe967c774bb608
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
Gerrit-HasComments: Yes
7 years, 10 months
Change in vdsm[master]: hostdev: use specific device classes in HostDevice
by mzamazal@redhat.com
Milan Zamazal has posted comments on this change.
Change subject: hostdev: use specific device classes in HostDevice
......................................................................
Patch Set 8:
(1 comment)
https://gerrit.ovirt.org/#/c/57963/8/vdsm/virt/vmdevices/hostdevice.py
File vdsm/virt/vmdevices/hostdevice.py:
Line 301: # way of reconstructing the udev name we use as unique id.
Line 302:
Line 303:
Line 304: class HostDevice(core.Base):
Line 305: __slots__ = ('_device',)
Shouldn't this be removed?
Line 306:
Line 307: _DEVICE_MAPPING = {
Line 308: 'pci': PciDevice,
Line 309: 'usb_device': UsbDevice,
--
To view, visit https://gerrit.ovirt.org/57963
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2734b7ec789c0ce57b64d7699cbe967c774bb608
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik(a)redhat.com>
Gerrit-Reviewer: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
Gerrit-HasComments: Yes
7 years, 10 months
Change in vdsm[ovirt-3.6]: migration: fix typo
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: migration: fix typo
......................................................................
migration: fix typo
This typo sneaked in during the review of commit 1e7d561
Change-Id: I421a7ba0d0ffedc2a90a79aab37712fabbddebca
Label: ovirt-3.6-only
Bug-Url: https://bugzilla.redhat.com/1339521
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/60037/1
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 40668a3..2fc8d4a 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -611,7 +611,7 @@
self._vm.log.debug('new iteration detected: %i',
iterationCount)
if (iterationCount == 1 and
- not self._dowtime_thread.is_alive()):
+ not self._downtime_thread.is_alive()):
# it does not make sense to do any adjustments before
# first iteration.
self.downtime_thread.start()
--
To view, visit https://gerrit.ovirt.org/60037
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I421a7ba0d0ffedc2a90a79aab37712fabbddebca
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 10 months
Change in vdsm[ovirt-4.0]: API: doc: reformat docstring for consistency
by fromani@redhat.com
Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59875
to review the following change.
Change subject: API: doc: reformat docstring for consistency
......................................................................
API: doc: reformat docstring for consistency
Change-Id: I13e3b6e85ab6a935ec15e581fba9fecc02fc588b
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/59668
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
Continuous-Integration: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/API.py
1 file changed, 8 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/59875/1
diff --git a/vdsm/API.py b/vdsm/API.py
index c38fbe9..67d3115 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1368,13 +1368,15 @@
def setLogLevel(self, level, name=''):
"""
Set verbosity level of vdsm's log.
+ Doesn't survive a restart.
- params
- level: requested logging level. `logging.DEBUG` `logging.ERROR`
- name: logger name to set. If not provided, defaults to the root
- logger. Otherwise, tune the specific logger provided.
-
- Doesn't survive a restart
+ :param level: requested logging level.
+ Examples: `logging.DEBUG` `logging.ERROR`
+ :type level: string
+ :param name: logger name to set. If not provided,
+ defaults to the root logger.
+ Otherwise, tune the specific logger provided.
+ :type name: string
"""
logUtils.set_level(level, name)
return dict(status=doneCode)
--
To view, visit https://gerrit.ovirt.org/59875
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I13e3b6e85ab6a935ec15e581fba9fecc02fc588b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: vdsm: adding handling for NGN in osinfo.py
by emesika@redhat.com
Eli Mesika has uploaded a new change for review.
Change subject: vdsm: adding handling for NGN in osinfo.py
......................................................................
vdsm: adding handling for NGN in osinfo.py
Current osinfo.py implementation lacks handling for NGN (New Generation
Node).
This patch adds another parameter in addition to the osname, release and
version named pretty_name, that is empty bu default and if
/etc/os-release file exists on the OS, will return the content of the
PRETTY_NAME value (if exists) from that file.
Change-Id: Ida119527b263302bf3f78e359bac12113718b744
Bug-Url : https://bugzilla.redhat.com/show_bug.cgi?id=1324447
Signed-off-by: emesika <emesika(a)redhat.com>
---
M lib/api/vdsm-api.yml
M lib/vdsm/osinfo.py
2 files changed, 32 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/59431/1
diff --git a/lib/api/vdsm-api.yml b/lib/api/vdsm-api.yml
index 475ccda..2814fc5 100644
--- a/lib/api/vdsm-api.yml
+++ b/lib/api/vdsm-api.yml
@@ -4650,6 +4650,10 @@
- description: The OS version (eg. 17 for Fedora 17)
name: version
type: string
+
+ - description: The OS pretty name
+ name: pretty_name
+ type: string
type: object
WatchdogEventAction: &WatchdogEventAction
diff --git a/lib/vdsm/osinfo.py b/lib/vdsm/osinfo.py
index 8ad99a1..0910872 100644
--- a/lib/vdsm/osinfo.py
+++ b/lib/vdsm/osinfo.py
@@ -23,6 +23,7 @@
import glob
import linecache
import logging
+import shlex
import time
import os
@@ -106,18 +107,34 @@
return OSName.UNKNOWN
-def _parse_node_version(path):
+def _parse_release_file(path):
data = {}
- with open(path) as f:
- for line in f:
- try:
- key, value = [kv.strip() for kv in line.split('=', 1)]
- except ValueError:
- continue
+ try:
+ with open(path) as f:
+ for line in shlex.split(f, comments=True):
+ try:
+ key, value = line.split('=', 1)
+ except ValueError:
+ continue
- data[key] = value
+ data[key] = value
+ except IOError:
+ logging.exception('Fail to read release file')
+ return data
+
+def _parse_node_version(path):
+ data = _parse_release_file(path)
return data.get('VERSION', ''), data.get('RELEASE', '')
+
+
+def _get_pretty_name():
+ pretty_name = ''
+ if os.path.exists('/etc/os-release'):
+ data = _parse_release_file('/etc/os-release')
+ if data.get('PRETTY_NAME') is not None:
+ pretty_name = data.get('PRETTY_NAME').strip('"')
+ return pretty_name
@utils.memoized
@@ -131,6 +148,7 @@
version = release_name = ''
osname = _release_name()
+ pretty_name = _get_pretty_name()
try:
if osname == OSName.RHEVH or osname == OSName.OVIRT:
version, release_name = _parse_node_version('/etc/default/version')
@@ -150,7 +168,8 @@
except:
logging.error('failed to find version/release', exc_info=True)
- return dict(release=release_name, version=version, name=osname)
+ return dict(release=release_name, version=version,
+ name=osname, pretty_name=pretty_name)
def selinux_status():
--
To view, visit https://gerrit.ovirt.org/59431
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida119527b263302bf3f78e359bac12113718b744
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emesika(a)redhat.com>
7 years, 10 months
Change in vdsm[ovirt-4.0]: API: allow setLogLevel to tune a specific logger
by fromani@redhat.com
Hello Piotr Kliczewski, Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59874
to review the following change.
Change subject: API: allow setLogLevel to tune a specific logger
......................................................................
API: allow setLogLevel to tune a specific logger
The not so known setLogLevel VDSM verb allows to dynamically tune
the log level of the root logger, until the next restart of VDSM.
This patch extends the API to let the client tune any specific
logger.
Change-Id: I8f40488fac04031552f36b9de026a0062ab81db0
Backports-To: 4.0
Backports-To: 3.6
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/38426
Reviewed-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M client/vdsClient.py
M lib/api/vdsm-api.yml
M lib/vdsm/logUtils.py
M lib/vdsm/rpc/bindingxmlrpc.py
M vdsm/API.py
5 files changed, 29 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/59874/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index c7b359d..7ffff54 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1565,9 +1565,13 @@
return 0, ''
def do_setLogLevel(self, args):
- validateArgTypes(args, [int], requiredArgsNumber=1)
+ validateArgTypes(args, [str, str], requiredArgsNumber=1)
level = args[0]
- stats = self.s.setLogLevel(level)
+ if len(args) >= 2:
+ name = args[1]
+ else:
+ name = ''
+ stats = self.s.setLogLevel(level, name)
if stats['status']['code']:
return stats['status']['code'], stats['status']['message']
return 0, ''
@@ -2619,8 +2623,12 @@
'prepareForShutdown': (serv.prepareForShutdown,
('', '')),
'setLogLevel': (serv.do_setLogLevel,
- ('<level> [logName][,logName]...', 'set log verbosity'
- ' level (10=DEBUG, 50=CRITICAL'
+ ('<level> [loggerName]',
+ 'set log verbosity. Arguments:\n'
+ ' <level> is one of DEBUG INFO WARNING ERROR CRITICAL'
+ ' case sensitive\n'
+ ' <loggerName> is the logger to set.'
+ ' If not given, sets the root logger.'
)),
'setMOMPolicy': (serv.do_setMOMPolicy,
('<policyfile>', 'set MOM policy')),
diff --git a/lib/api/vdsm-api.yml b/lib/api/vdsm-api.yml
index ef65165..ab6ca0d 100644
--- a/lib/api/vdsm-api.yml
+++ b/lib/api/vdsm-api.yml
@@ -7459,6 +7459,10 @@
- description: The new verosity level desired
name: level
type: *LoggingLevel
+ - defaultvalue: ''
+ description: The logger to set
+ name: name
+ type: string
Host.setSafeNetworkConfig:
added: '3.1'
diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py
index c9a75c8..60ceca6 100644
--- a/lib/vdsm/logUtils.py
+++ b/lib/vdsm/logUtils.py
@@ -217,13 +217,14 @@
}
-def set_level(level):
+def set_level(level, name=''):
if level not in _LEVELS:
raise ValueError("unknown log level: %r" % level)
log_level = _LEVELS[level]
- logging.warning('Setting loglevel to %s (%d)', level, log_level)
- handlers = logging.getLogger().handlers
- [fileHandler] = [h for h in handlers if
- isinstance(h, logging.FileHandler)]
- fileHandler.setLevel(int(level))
+ log_name = None if not name else name
+ # getLogger() default argument is None, not ''
+ logger = logging.getLogger(log_name)
+ logging.warning('Setting loglevel on %r to %s (%d)',
+ logger.name, level, log_level)
+ logger.setLevel(log_level)
diff --git a/lib/vdsm/rpc/bindingxmlrpc.py b/lib/vdsm/rpc/bindingxmlrpc.py
index d2f05fa..ee92d26 100644
--- a/lib/vdsm/rpc/bindingxmlrpc.py
+++ b/lib/vdsm/rpc/bindingxmlrpc.py
@@ -638,9 +638,9 @@
return api.fenceNode(addr, port, agent, username, password, action,
secure, options, policy)
- def setLogLevel(self, level):
+ def setLogLevel(self, level, name=''):
api = API.Global()
- return api.setLogLevel(level)
+ return api.setLogLevel(level, name)
def setMOMPolicy(self, policy):
api = API.Global()
diff --git a/vdsm/API.py b/vdsm/API.py
index dd72c2b..c38fbe9 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1365,16 +1365,18 @@
'info': hostapi.get_stats(self._cif,
sampling.host_samples.stats())}
- def setLogLevel(self, level):
+ def setLogLevel(self, level, name=''):
"""
Set verbosity level of vdsm's log.
params
level: requested logging level. `logging.DEBUG` `logging.ERROR`
+ name: logger name to set. If not provided, defaults to the root
+ logger. Otherwise, tune the specific logger provided.
Doesn't survive a restart
"""
- logUtils.set_level(level)
+ logUtils.set_level(level, name)
return dict(status=doneCode)
# VM-related functions
--
To view, visit https://gerrit.ovirt.org/59874
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f40488fac04031552f36b9de026a0062ab81db0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
7 years, 10 months
Change in vdsm[ovirt-4.0]: API: streamline and make setLogLevel correct
by fromani@redhat.com
Hello Piotr Kliczewski, Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59873
to review the following change.
Change subject: API: streamline and make setLogLevel correct
......................................................................
API: streamline and make setLogLevel correct
According to the schema, setLogLevel should accept
a log level string ('DEBUG', 'INFO',...). But the code
actually blindly casted the given value to int(), and this suggests
the code actually expected an integer value.
To make things a bit user friendlier and comformant to schema,
change the argument to actually be a log level in string format.
Along the way, this patch streamlines the implementation of
setLogLevel and makes it simpler.
Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Backports-To: 4.0
Backports-To: 3.6
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/38425
Reviewed-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
Continuous-Integration: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/logUtils.py
1 file changed, 14 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/59873/1
diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py
index 8a6c501..c9a75c8 100644
--- a/lib/vdsm/logUtils.py
+++ b/lib/vdsm/logUtils.py
@@ -208,8 +208,21 @@
return logging.handlers.WatchedFileHandler._open(self)
+_LEVELS = {
+ 'DEBUG': logging.DEBUG,
+ 'INFO': logging.INFO,
+ 'WARNING': logging.WARNING,
+ 'ERROR': logging.ERROR,
+ 'CRITICAL': logging.CRITICAL
+}
+
+
def set_level(level):
- logging.warning('Setting loglevel to %s', level)
+ if level not in _LEVELS:
+ raise ValueError("unknown log level: %r" % level)
+
+ log_level = _LEVELS[level]
+ logging.warning('Setting loglevel to %s (%d)', level, log_level)
handlers = logging.getLogger().handlers
[fileHandler] = [h for h in handlers if
isinstance(h, logging.FileHandler)]
--
To view, visit https://gerrit.ovirt.org/59873
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
7 years, 10 months
Change in vdsm[ovirt-4.0]: API: logging: move setLogLevel code into logUtils
by fromani@redhat.com
Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59872
to review the following change.
Change subject: API: logging: move setLogLevel code into logUtils
......................................................................
API: logging: move setLogLevel code into logUtils
Move the implementation of API.setLogLevel into the
logUtils module, with minimal changes and renaming,
to make it less coupled.
The rationale for this move is that we should not have
logic in API.py besides the bare minimum.
Furthermore, setLogLevel fits nicely in the logUtils domain.
Change-Id: Iacda9f82c6e0bc22a19403b99acbfffbdb7fd2bf
Backport-To: 4.0
Backport-To: 3.6
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/58990
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/logUtils.py
M vdsm/API.py
2 files changed, 10 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/59872/1
diff --git a/lib/vdsm/logUtils.py b/lib/vdsm/logUtils.py
index 5a651c9..8a6c501 100644
--- a/lib/vdsm/logUtils.py
+++ b/lib/vdsm/logUtils.py
@@ -206,3 +206,11 @@
raise RuntimeError(
"Attempt to open log with incorrect credentials")
return logging.handlers.WatchedFileHandler._open(self)
+
+
+def set_level(level):
+ logging.warning('Setting loglevel to %s', level)
+ handlers = logging.getLogger().handlers
+ [fileHandler] = [h for h in handlers if
+ isinstance(h, logging.FileHandler)]
+ fileHandler.setLevel(int(level))
diff --git a/vdsm/API.py b/vdsm/API.py
index e37569d..dd72c2b 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -21,7 +21,6 @@
# pylint: disable=R0904
import os
-import logging
from vdsm.network.errors import ConfigNetworkError
@@ -30,6 +29,7 @@
from clientIF import clientIF
from vdsm import constants
from vdsm import exception
+from vdsm import logUtils
from vdsm import hooks
from vdsm import hostdev
from vdsm import response
@@ -1374,12 +1374,7 @@
Doesn't survive a restart
"""
- logging.warning('Setting loglevel to %s', level)
- handlers = logging.getLogger().handlers
- [fileHandler] = [h for h in handlers if
- isinstance(h, logging.FileHandler)]
- fileHandler.setLevel(int(level))
-
+ logUtils.set_level(level)
return dict(status=doneCode)
# VM-related functions
--
To view, visit https://gerrit.ovirt.org/59872
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacda9f82c6e0bc22a19403b99acbfffbdb7fd2bf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
7 years, 10 months
Change in vdsm[ovirt-4.0]: rpc: Log also error codes of RPC calls
by mzamazal@redhat.com
Hello Piotr Kliczewski, Nir Soffer,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59999
to review the following change.
Change subject: rpc: Log also error codes of RPC calls
......................................................................
rpc: Log also error codes of RPC calls
In one of the previous commits, we added logging of RPC calls on info
level. It'd be useful to have information about response codes there,
so this patch adds that information.
Change-Id: I776e667fcfd1a20a9ef5f6c638d6c3d950672314
Bug-Url: https://bugzilla.redhat.com/1351247
Backport-To: 4.0
Signed-off-by: Milan Zamazal <mzamazal(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/59234
Reviewed-by: Nir Soffer <nsoffer(a)redhat.com>
Reviewed-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Continuous-Integration: Jenkins CI
---
M lib/vdsm/rpc/bindingxmlrpc.py
M lib/yajsonrpc/__init__.py
2 files changed, 27 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/59999/1
diff --git a/lib/vdsm/rpc/bindingxmlrpc.py b/lib/vdsm/rpc/bindingxmlrpc.py
index 732918f..c60e204 100644
--- a/lib/vdsm/rpc/bindingxmlrpc.py
+++ b/lib/vdsm/rpc/bindingxmlrpc.py
@@ -318,15 +318,18 @@
self.log.debug(fmt, *logargs)
+ res = {}
try:
- return f(*args, **kwargs)
+ res = f(*args, **kwargs)
except:
self.log.error("Unexpected exception", exc_info=True)
- return errCode['unexpected']
- finally:
- self.log.info("RPC call %s finished in %.2f seconds",
- f.__name__,
- utils.monotonic_time() - start_time)
+ res = errCode['unexpected']
+ self.log.info("RPC call %s finished (code=%s) in "
+ "%.2f seconds",
+ f.__name__,
+ res.get('status', {}).get('code'),
+ utils.monotonic_time() - start_time)
+ return res
wrapper.__name__ = f.__name__
wrapper.__doc__ = f.__doc__
@@ -1198,6 +1201,7 @@
def wrapApiMethod(f):
def wrapper(*args, **kwargs):
start_time = utils.monotonic_time()
+ res = {}
try:
logLevel = logging.DEBUG
suppress_args = f.__name__ in ('fenceNode',)
@@ -1258,18 +1262,23 @@
except libvirt.libvirtError as e:
f.__self__.cif.log.error("libvirt error", exc_info=True)
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
- return errCode['noVM']
+ res = errCode['noVM']
else:
- return errCode['unexpected']
+ res = errCode['unexpected']
+ return res
except VdsmException as e:
f.__self__.cif.log.error("vdsm exception occured", exc_info=True)
- return e.response()
+ res = e.response()
+ return res
except:
f.__self__.cif.log.error("unexpected error", exc_info=True)
- return errCode['unexpected']
+ res = errCode['unexpected']
+ return res
finally:
- f.__self__.cif.log.info("RPC call %s finished in %.2f seconds",
+ f.__self__.cif.log.info("RPC call %s finished (code=%s) in "
+ "%.2f seconds",
f.__name__,
+ res.get('status', {}).get('code'),
utils.monotonic_time() - start_time)
wrapper.__name__ = f.__name__
wrapper.__doc__ = f.__doc__
diff --git a/lib/yajsonrpc/__init__.py b/lib/yajsonrpc/__init__.py
index ff8e4ae..3583dff 100644
--- a/lib/yajsonrpc/__init__.py
+++ b/lib/yajsonrpc/__init__.py
@@ -503,8 +503,13 @@
def _serveRequest(self, ctx, req):
start_time = monotonic_time()
response = self._handle_request(req, ctx.server_address)
- self.log.info("RPC call %s finished in %.2f seconds",
- req.method, monotonic_time() - start_time)
+ error = getattr(response, "error", None)
+ if error is None:
+ response_log = "succeeded"
+ else:
+ response_log = "failed (error %s)" % (error.code,)
+ self.log.info("RPC call %s %s in %.2f seconds",
+ req.method, response_log, monotonic_time() - start_time)
if response is not None:
ctx.requestDone(response)
--
To view, visit https://gerrit.ovirt.org/59999
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I776e667fcfd1a20a9ef5f6c638d6c3d950672314
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
7 years, 10 months