Francesco Romani has uploaded a new change for review. Change subject: API: restore setLogLevel backward compatibility ......................................................................
API: restore setLogLevel backward compatibility Host.setLogLevel implementations was different from the one documented in the schema, but it was consistent to what vdsClient sends. This suggests that the API was somehow used through vdsClient, although not in the advertised way. This patch adds fallback backward compatibility to the old format. Change-Id: I7afabd0676f420621e04377f7781a9133671df05 Signed-off-by: Francesco Romani <[email protected]> --- M vdsm/API.py 1 file changed, 23 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/19/42419/1 diff --git a/vdsm/API.py b/vdsm/API.py index de65e4f..17d306f 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -1379,22 +1379,13 @@ Doesn't survive a restart """ - LEVELS = { - 'DEBUG': logging.DEBUG, - 'INFO': logging.INFO, - 'WARNING': logging.WARNING, - 'ERROR': logging.ERROR, - 'CRITICAL': logging.CRITICAL - } - - try: - log_level = LEVELS[level.upper()] - except KeyError: - return errCode['unavail'] - else: + log_level = _parse_log_level(level) + if log_level is not None: logging.warning('Setting loglevel to %s (%d)', level, log_level) _set_log_level(logging.getLogger(), log_level) return {'status': doneCode} + else: + return errCode['unavail'] # VM-related functions def getVMList(self, fullStatus=False, vmList=(), onlyUUID=False): @@ -1820,6 +1811,25 @@ options[_translationMap[k]] = options.pop(k) +def _parse_log_level(level): + LEVELS = { + 'DEBUG': logging.DEBUG, + 'INFO': logging.INFO, + 'WARNING': logging.WARNING, + 'ERROR': logging.ERROR, + 'CRITICAL': logging.CRITICAL + } + + try: + return LEVELS[level.upper()] + except KeyError: + # for backward compatibility + try: + return int(level) + except ValueError: + return None + + def _set_log_level(logger, log_level): for handler in logger.handlers: if isinstance(handler, logging.FileHandler): -- To view, visit https://gerrit.ovirt.org/42419 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7afabd0676f420621e04377f7781a9133671df05 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
