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

add option to disable hypervisor connection

parent 913e46f2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ if __name__ == '__main__':
                  help='run as daemon and write pid file')
    op.add_option('-p', '--pid-file', default=DEFAULT_PID_FILE,
                  help='pid file (default: %default)')
    op.add_option('-s', '--skip-hypervisor', default=False, action="store_true",
                  help='do not connect to hypervisors (default: %default)')
    
    cliopts, args = op.parse_args()

+12 −6
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#TODO: catch livbirt disconnection errors and handle it 


from interface import Node
from kvm import *
from sjrpc.utils import RpcHandler
from sjrpc.utils import pure
@@ -59,13 +60,18 @@ class NodeHandler(RpcHandler):
    def __init__(self, connection):
        super(RpcHandler, self).__init__()
        self._connection = connection
        #do not detect hypervisor if connection is disable in configuration
        if config[skip_hypervisor]:
            logging.debug('Hypervisor detection disabled, running as regular'
              ' node')
            self.hv_handle = Host()
        else:
            #we set our hypervisor handle
            #FIXME: must be aware of hypervisor type
            logging.debug('Initializing a connection on the hypervisor')
            self.hv_handle = KvmHypervisor()
            logging.debug('Initialized connection to a KVM hypervisor')
    
    
    def _call_hv_method(self, method):
        '''
        Calls the given method in the :class:`Hypervisor` instance
+3 −0
Original line number Diff line number Diff line
@@ -3,3 +3,6 @@

# Set to true to enable the cc-node daemon:
ENABLED=false

# Set to true to skip hypervisor detection (for regular hosts)
NO_HYPERVISOR=true
+13 −7
Original line number Diff line number Diff line
@@ -36,13 +36,19 @@ VERBOSE=yes
# and status_of_proc is working.
. /lib/lsb/init-functions

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Read and parse configuration variable file if it is present
[ -r /etc/default/$NAME ] && {
    . /etc/default/$NAME
    # Do not start if service is disabled
    if [ "$ENABLED" = "false" ] ; then
        echo "$DESC disabled, see /etc/default/$NAME"
        exit 0
    fi
    # Skip connection to any hypervisor
    if [ "$NO_HYPERVISOR" = "true" ] ; then
        DAEMON_OPTS="${DAEMON_OPTS} --skip-hypervisor"
    fi
}

#
# Function that starts the daemon/service