Change in vdsm[master]: register: handle non uuid machines
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: register: handle non uuid machines
......................................................................
register: handle non uuid machines
If user machines doesn't provide UUID data this patch
collects a random UUID from system.
Change-Id: I9429e46895a73178cf459d5ced5d39499e993922
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1268854
Signed-off-by: Douglas Schilling Landgraf <dougsland(a)redhat.com>
---
M lib/vdsm/tool/register.py
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/47385/1
diff --git a/lib/vdsm/tool/register.py b/lib/vdsm/tool/register.py
index 47c8412..d088bfc 100644
--- a/lib/vdsm/tool/register.py
+++ b/lib/vdsm/tool/register.py
@@ -256,7 +256,17 @@
if self.vdsm_uuid:
self.uuid = self.vdsm_uuid
else:
- self.uuid = getHostUUID(legacy=False)
+ uuid_node = getHostUUID(legacy=False)
+ if uuid_node is None:
+ self.logger.debug("Collecting random UUID from system")
+ random_uuid_path = '/proc/sys/kernel/random/uuid'
+ if os.path.exists(random_uuid_path):
+ with open(random_uuid_path, 'r') as f:
+ self.uuid = f.readline().strip()
+ else:
+ raise RuntimeError("Unable to determine host UUID!")
+ else:
+ self.uuid = uuid_node
self.url_reg += "&uniqueId={u}".format(u=self.uuid)
--
To view, visit https://gerrit.ovirt.org/47385
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9429e46895a73178cf459d5ced5d39499e993922
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: jsonrpcvdscli: add additional verbs
by stirabos@redhat.com
Simone Tiraboschi has uploaded a new change for review.
Change subject: jsonrpcvdscli: add additional verbs
......................................................................
jsonrpcvdscli: add additional verbs
Add additional verbs required by the hosted-engine upgrade flow.
Change-Id: I57f9c63a05d8354676e68418b08593ea830b42a7
Signed-off-by: Simone Tiraboschi <stirabos(a)redhat.com>
---
M lib/vdsm/jsonrpcvdscli.py
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/60054/1
diff --git a/lib/vdsm/jsonrpcvdscli.py b/lib/vdsm/jsonrpcvdscli.py
index 87a7fee..b5f48df 100644
--- a/lib/vdsm/jsonrpcvdscli.py
+++ b/lib/vdsm/jsonrpcvdscli.py
@@ -54,6 +54,7 @@
'disconnectStoragePool': 'StoragePool.disconnect',
'disconnectStorageServer': 'StoragePool.disconnectStorageServer',
'discoverSendTargets': 'ISCSIConnection.discoverSendTargets',
+ 'extendVolumeSize': 'Volume.extendSize',
'formatStorageDomain': 'StorageDomain.format',
'fullList': 'Host.getVMFullList',
'getAllTasksStatuses': 'Host.getAllTasksStatuses',
@@ -66,6 +67,8 @@
'getStorageDomainsList': 'Host.getStorageDomains',
'getStorageDomainStats': 'StorageDomain.getStats',
'getStoragePoolInfo': 'StoragePool.getInfo',
+ 'getTaskInfo': 'Task.getInfo',
+ 'getTaskStatus': 'Task.getStatus',
'getVdsCapabilities': 'Host.getCapabilities',
'getVdsHardwareInfo': 'Host.getHardwareInfo',
'getVdsStats': 'Host.getStats',
--
To view, visit https://gerrit.ovirt.org/60054
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I57f9c63a05d8354676e68418b08593ea830b42a7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Simone Tiraboschi <stirabos(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: Refactor verify_untrusted_volume
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: Refactor verify_untrusted_volume
......................................................................
Refactor verify_untrusted_volume
In order to test the logic in verify_untrusted_volume we need to
decouple it from HSM (which is too hard to mock properly). Create a new
function in storage.misc that performs the checks and call that function
from HSM. Also, add tests for the current behavior.
Change-Id: I90c06286c5e0b85c3b190026882b937fdb38266e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1344289
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M lib/vdsm/storage/misc.py
M tests/miscTests.py
M vdsm/storage/hsm.py
3 files changed, 52 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/59409/1
diff --git a/lib/vdsm/storage/misc.py b/lib/vdsm/storage/misc.py
index 173d608..0cb99e5 100644
--- a/lib/vdsm/storage/misc.py
+++ b/lib/vdsm/storage/misc.py
@@ -52,6 +52,7 @@
from vdsm import concurrent
from vdsm import constants
from vdsm import logUtils
+from vdsm import qemuimg
from vdsm import utils
from vdsm.storage import exception as se
@@ -779,3 +780,19 @@
def deprecated(f):
"""Used to mark exported methods as deprecated"""
return f
+
+
+def verify_untrusted_volume(path, meta_format):
+ qemu_info = qemuimg.info(path)
+ qemu_format = qemu_info["format"]
+
+ if meta_format != qemu_format:
+ raise se.ImageVerificationError(
+ "Volume's format specified by QEMU is %s, while the format "
+ "specified in VDSM metadata is %s" %
+ (qemu_format, meta_format))
+ if "backingfile" in qemu_info:
+ raise se.ImageVerificationError(
+ "'%s' is defined as a backingfile, while backingfile is not "
+ "allowed for an untrusted volume." %
+ qemu_info["backingfile"])
diff --git a/tests/miscTests.py b/tests/miscTests.py
index 0f90aa2..c8cc8c5 100644
--- a/tests/miscTests.py
+++ b/tests/miscTests.py
@@ -37,13 +37,16 @@
from vdsm import cmdutils
from vdsm import commands
from vdsm import exception
+from vdsm import qemuimg
from vdsm import utils
+from vdsm.storage import exception as se
from vdsm.storage import fileUtils
from vdsm.storage import misc
import storage.outOfProcess as oop
from monkeypatch import MonkeyPatch
+from monkeypatch import MonkeyPatchScope
from testValidation import checkSudo
EXT_CHMOD = "/bin/chmod"
@@ -1135,3 +1138,33 @@
barrier = misc.DynamicBarrier()
self.assertTrue(barrier.enter())
barrier.exit()
+
+
+class FakeQemuimg(object):
+
+ def __init__(self, info):
+ self._info = info
+
+ def info(self, path):
+ return self._info
+
+
+class TestValidateUntrustedVolume(TestCaseBase):
+
+ def check(self, info, vdsm_fmt):
+ with MonkeyPatchScope([(misc.qemuimg, 'info', lambda unused: info)]):
+ misc.verify_untrusted_volume('unused', vdsm_fmt)
+
+ def test_wrong_format_raises(self):
+ info = {"format": qemuimg.FORMAT.RAW}
+ self.assertRaises(se.ImageVerificationError,
+ self.check, info, qemuimg.FORMAT.QCOW2)
+
+ def test_backing_file_raises(self):
+ info = {"format": qemuimg.FORMAT.QCOW2, "backingfile": "foo"}
+ self.assertRaises(se.ImageVerificationError,
+ self.check, info, qemuimg.FORMAT.QCOW2)
+
+ def test_ok(self):
+ info = {"format": qemuimg.FORMAT.RAW}
+ self.assertNotRaises(self.check, info, qemuimg.FORMAT.RAW)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 6ceaf64..17a7464 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1493,20 +1493,9 @@
def verify_untrusted_volume(self, spUUID, sdUUID, imgUUID, volUUID):
dom = sdCache.produce(sdUUID=sdUUID)
vol = dom.produceVolume(imgUUID, volUUID)
- qemu_info = qemuimg.info(vol.getVolumePath())
-
+ path = vol.getVolumePath()
meta_format = sc.FMT2STR[vol.getFormat()]
- qemu_format = qemu_info["format"]
- if meta_format != qemu_format:
- raise se.ImageVerificationError(
- "Volume's format specified by QEMU is %s, while the format "
- "specified in VDSM metadata is %s" %
- (qemu_format, meta_format))
- if "backingfile" in qemu_info:
- raise se.ImageVerificationError(
- "'%s' is defined as a backingfile, while backingfile is not "
- "allowed for an untrusted volume." %
- qemu_info["backingfile"])
+ misc.verify_untrusted_volume(path, meta_format)
def validateImageMove(self, srcDom, dstDom, imgUUID):
"""
--
To view, visit https://gerrit.ovirt.org/59409
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I90c06286c5e0b85c3b190026882b937fdb38266e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: hsm: Use manifest in verify_untrusted_volume
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: hsm: Use manifest in verify_untrusted_volume
......................................................................
hsm: Use manifest in verify_untrusted_volume
New users of storage objects should generally use the new *Manifest
versions rather than the original objects which have unneeded
complexity. Also, the new storagetestlib infrastructure is only
compatible with the newer *Manifest objects.
Change-Id: I6e615f0ad97149d49b13b530819d9c8e58fcdb81
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/60059/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 2d683c2..43403f4 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1490,7 +1490,7 @@
@public
def verify_untrusted_volume(self, spUUID, sdUUID, imgUUID, volUUID):
- dom = sdCache.produce(sdUUID=sdUUID)
+ dom = sdCache.produce(sdUUID=sdUUID).manifest
vol = dom.produceVolume(imgUUID, volUUID)
qemu_info = qemuimg.info(vol.getVolumePath())
--
To view, visit https://gerrit.ovirt.org/60059
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e615f0ad97149d49b13b530819d9c8e58fcdb81
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 11 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, 11 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, 11 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, 11 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, 11 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, 11 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, 11 months