Commit c02cdb0f authored by Thibault VINCENT's avatar Thibault VINCENT
Browse files

better level selection for logging

parent 4674a09a
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-

from fnmatch import fnmatchcase
from threading import Timer, Lock, RLock
from sjrpc.core import RpcError
from itertools import chain
from __init__ import __version__
from sjrpc.utils import RpcHandler
from sjrpc.utils import pure
from logging import debug, critical, warning, info
from exceptions import CCException, FeatureNotImplemented
from logging import debug, warning, info
from exceptions import HypervisorError
from common import LocalHost


@@ -513,20 +511,19 @@ class NodeHandler(RpcHandler):
    def node_shutdown(self, reboot=True, gracefull=True):
        '''
        '''
        info('shutdown: server requested shutdown of local host')
        debug('shutdown: reboot=%s gracefull=%s' % (reboot, gracefull))
        warning('node_shutdown: server requested shutdown of local host')
        info('node_shutdown: reboot=%s gracefull=%s', reboot, gracefull)
        if reboot:
            method = 'power_reboot' if gracefull else 'power_force_reboot'
        else:
            method = 'power_shutdown' if gracefull else 'power_off'
        if hasattr(self._host_handle, method):
            result = getattr(self._host_handle, method)()
            debug('shutdown: in progress ... action returned `%s`' % result)
            info('node_shutdown: in progress ... action returned `%s`', result)
            return result
        else:
            debug('shutdown: unable to proceed, this feature is not available')
            raise FeatureNotImplemented('host handler has no method `%s`'
                                                                    % method)
            warning('node_shutdown: unable to proceed, this feature is not available')
            raise NotImplementedError('host handler has no method `%s`' %method)
    
    @pure
    def vm_stop(self, vm_names=None, force=False):