Exemple #1
0
    def _setupVdsConnection(self):
        if self.hibernating:
            return

        hostPort = vdscli.cannonizeHostPort(
            self._dst, config.getint('addresses', 'management_port'))
        self.remoteHost, port = hostPort.rsplit(':', 1)

        try:
            client = self._createClient(port)
            requestQueues = config.get('addresses', 'request_queues')
            requestQueue = requestQueues.split(",")[0]
            self._destServer = jsonrpcvdscli.connect(requestQueue, client)
            self.log.debug('Initiating connection with destination')
            self._destServer.ping()

        except (JsonRpcBindingsError, JsonRpcNoResponseError):
            if config.getboolean('vars', 'ssl'):
                self._destServer = vdscli.connect(
                    hostPort,
                    useSSL=True,
                    TransportClass=kaxmlrpclib.TcpkeepSafeTransport)
            else:
                self._destServer = kaxmlrpclib.Server('http://' + hostPort)

        self.log.debug('Destination server is: ' + hostPort)
Exemple #2
0
    def _setupVdsConnection(self):
        if self.hibernating:
            return

        hostPort = vdscli.cannonizeHostPort(
            self._dst,
            config.getint('addresses', 'management_port'))
        self.remoteHost, port = hostPort.rsplit(':', 1)

        try:
            client = self._createClient(port)
            requestQueues = config.get('addresses', 'request_queues')
            requestQueue = requestQueues.split(",")[0]
            self._destServer = jsonrpcvdscli.connect(requestQueue, client)
            self.log.debug('Initiating connection with destination')
            self._destServer.ping()

        except (JsonRpcBindingsError, JsonRpcNoResponseError):
            if config.getboolean('vars', 'ssl'):
                self._destServer = vdscli.connect(
                    hostPort,
                    useSSL=True,
                    TransportClass=kaxmlrpclib.TcpkeepSafeTransport)
            else:
                self._destServer = kaxmlrpclib.Server('http://' + hostPort)

        self.log.debug('Destination server is: ' + hostPort)
def getVDSMService():
    global service
    if not service:
        logger.debug("getVDSMService() connecting ...")
        rqueues = config.get('addresses', 'request_queues')
        rqueue = rqueues.split(',', 1)[0]
        service = jsonrpcvdscli.connect(rqueue)

    return service
Exemple #4
0
def getVDSMService():
    global service
    if not service:
        logger.debug("getVDSMService() connecting ...")
        rqueues = config.get('addresses', 'request_queues')
        rqueue = rqueues.split(',', 1)[0]
        service = jsonrpcvdscli.connect(rqueue)

    return service
Exemple #5
0
 def start(self):
     if _JSONRPC_ENABLED:
         requestQueues = config.get('addresses', 'request_queues')
         requestQueue = requestQueues.split(",")[0]
         self.vdscli = jsonrpcvdscli.connect(requestQueue, xml_compat=False)
     else:
         self.vdscli = vdscli.connect()
     self.netinfo = self._get_netinfo()
     if config.get('vars', 'net_persistence') == 'unified':
         self.config = RunningConfig()
     else:
         self.config = None
Exemple #6
0
 def start(self):
     if _JSONRPC_ENABLED:
         requestQueues = config.get('addresses', 'request_queues')
         requestQueue = requestQueues.split(",")[0]
         self.vdscli = jsonrpcvdscli.connect(requestQueue, xml_compat=False)
     else:
         self.vdscli = vdscli.connect()
     self.netinfo = self._get_netinfo()
     if config.get('vars', 'net_persistence') == 'unified':
         self.config = RunningConfig()
     else:
         self.config = None
def connect_vdsm_json_rpc(logger=None, timeout=None):
    MAX_RETRY = 120
    DELAY = 2
    retry = 0
    vdsmReady = False
    requestQueues = vdsmconfig.get('addresses', 'request_queues')
    requestQueue = requestQueues.split(",")[0]
    while not vdsmReady and retry < MAX_RETRY:
        time.sleep(DELAY)
        retry += 1
        try:
            cli = jsonrpcvdscli.connect(
                requestQueue=requestQueue,
            )
            if timeout:
                cli.set_default_timeout(timeout)
            vdsmReady = True
        except socket.error:
            if logger:
                logger.info('Waiting for VDSM to reply')
    if not vdsmReady:
        raise RuntimeError(
            'Couldn''t  connect to VDSM within {timeout} seconds'.format(
                timeout=MAX_RETRY * DELAY
            )
        )

    vdsmReady = False
    retry = 0
    while not vdsmReady and retry < MAX_RETRY:
        retry += 1
        try:
            hwinfo = cli.getVdsHardwareInfo()
            if logger:
                logger.debug(str(hwinfo))
            if hwinfo['status']['code'] == 0:
                vdsmReady = True
            else:
                if logger:
                    logger.info('Waiting for VDSM hardware info')
                time.sleep(DELAY)
        except socket.error:
            if logger:
                logger.info('Waiting for VDSM hardware info')
            time.sleep(DELAY)
    if not vdsmReady:
        raise RuntimeError(
            'Couldn''t  connect to VDSM within {timeout} seconds'.format(
                timeout=MAX_RETRY * DELAY
            )
        )
    return cli
def init_callback():
    restore_sigchld()

    # TODO: add ssl option
    log("Init: Check VDSM availability")
    if service.service_status("vdsmd"):
        log("vdsmd is not running.")
        return

    global client
    client = jsonrpcvdscli.connect('jms.topic.vdsm_requests')
    # TODO: add to jsonrpcvdscli even method registration
    client._client.registerEventCallback(event_recieved)
Exemple #9
0
def init_callback():
    restore_sigchld()

    # TODO: add ssl option
    log("Init: Check VDSM availability")
    if service.service_status("vdsmd"):
        log("vdsmd is not running.")
        return

    global client
    client = jsonrpcvdscli.connect('jms.topic.vdsm_requests')
    # TODO: add to jsonrpcvdscli even method registration
    client._client.registerEventCallback(event_recieved)
Exemple #10
0
    def _setupVdsConnection(self):
        if self.hibernating:
            return

        hostPort = _cannonize_host_port(
            self._dst, config.getint('addresses', 'management_port'))
        self.remoteHost, port = hostPort.rsplit(':', 1)

        client = self._createClient(port)
        requestQueues = config.get('addresses', 'request_queues')
        requestQueue = requestQueues.split(",")[0]
        self._destServer = jsonrpcvdscli.connect(requestQueue, client)
        self.log.debug('Initiating connection with destination')
        self._destServer.ping()

        self.log.debug('Destination server is: ' + hostPort)
Exemple #11
0
    def _setupVdsConnection(self):
        if self.hibernating:
            return

        hostPort = _cannonize_host_port(
            self._dst,
            config.getint('addresses', 'management_port'))
        self.remoteHost, port = hostPort.rsplit(':', 1)

        client = self._createClient(port)
        requestQueues = config.get('addresses', 'request_queues')
        requestQueue = requestQueues.split(",")[0]
        self._destServer = jsonrpcvdscli.connect(requestQueue, client)
        self.log.debug('Initiating connection with destination')
        self._destServer.ping()

        self.log.debug('Destination server is: ' + hostPort)
Exemple #12
0
def resume_paused_vm(vm_id):
    unpause_file = MARK_FOR_UNPAUSE_PATH % vm_id
    if os.path.isfile(unpause_file):
        with closing(jsonrpcvdscli.connect()) as server:
            server.cont(vm_id)
        os.remove(unpause_file)
Exemple #13
0
def _vdscli():
    request_queues = config.get('addresses', 'request_queues')
    request_queue = request_queues.split(',')[0]
    return jsonrpcvdscli.connect(request_queue)
Exemple #14
0
 def start(self):
     requestQueues = config.get('addresses', 'request_queues')
     requestQueue = requestQueues.split(",")[0]
     self.vdscli = jsonrpcvdscli.connect(requestQueue, xml_compat=False)
     self.netinfo = self._get_netinfo()
     self.config = RunningConfig()
Exemple #15
0
 def start(self):
     requestQueues = config.get('addresses', 'request_queues')
     requestQueue = requestQueues.split(",")[0]
     self.vdscli = jsonrpcvdscli.connect(requestQueue, xml_compat=False)
     self.netinfo = self._get_netinfo()
     self.config = RunningConfig()
Exemple #16
0
def _vdscli():
    request_queues = config.get('addresses', 'request_queues')
    request_queue = request_queues.split(',')[0]
    return jsonrpcvdscli.connect(request_queue)