コード例 #1
0
ファイル: houseclean.py プロジェクト: Wiki616/LABOSS
def reset_guacamole_client():
    session = DBSession()
    query = session.query(GuacamoleClientInfo)
    #If I can add another condition for query to lock with update, for example, query.filter(GuacamoleClientInfo.guacamole_client_host=='').filter.......
    #Then this process can be more fine-grained
    result = query.filter(GuacamoleClientInfo.status==1).filter(GuacamoleClientInfo.user_info!='').with_lockmode('update').all()
    if result==None:
        return
    cur_time = datetime.now()
    for res in result:
        seconds = __time_diff(cur_time,res.latest_active_timestamp)
        if seconds>=client_time_limit:
            guacamole_client_vm = res.guacamole_client_vm
            guacamole_client_host = res.guacamole_client_host
            image = res.image
            
            res.user_info = ''
            res.status = 0
            res.image = ''
            protocol = res.protocol
            guacamole_server = res.guacamole_server
            query = session.query(GuacamoleServerLoad)
            result = query.filter(GuacamoleServerLoad.guacamole_server == guacamole_server).with_lockmode('update').first()
            result = __server_protocol_update(protocol,-1,result)
            
            signal = containerservice.shutdown_container(guacamole_client_vm,int(guacamole_client_host[guacamole_client_host.index(':')+1:]),image)
            if signal==False:
                #Record this error
                pass
    session.commit()
    session.close()
コード例 #2
0
ファイル: restserver.py プロジェクト: czx0619/LABOSS
def shutdown_guacamole_client(client_id, image,protocol,mylog):
    guacamole_client_host,guacamole_client_vm = cancel_guacamole_client(client_id, image, protocol)
    if guacamole_client_host==None:
        return
    signal = containerservice.shutdown_container(guacamole_client_vm,int(guacamole_client_host[guacamole_client_host.index(':')+1:]),image)
    if signal==False:
        mylog.info("shutdown a container failed...")
        pass
コード例 #3
0
ファイル: restserver.py プロジェクト: czx0619/LABOSS
def shutdown_guacamole_client(client_id, image, protocol, mylog):
    guacamole_client_host, guacamole_client_vm = cancel_guacamole_client(
        client_id, image, protocol)
    if guacamole_client_host == None:
        return
    signal = containerservice.shutdown_container(
        guacamole_client_vm,
        int(guacamole_client_host[guacamole_client_host.index(':') + 1:]),
        image)
    if signal == False:
        mylog.info("shutdown a container failed...")
        pass
コード例 #4
0
def reset_guacamole_client():
    session = DBSession()
    query = session.query(GuacamoleClientInfo)
    #If I can add another condition for query to lock with update, for example, query.filter(GuacamoleClientInfo.guacamole_client_host=='').filter.......
    #Then this process can be more fine-grained
    result = query.filter(GuacamoleClientInfo.status == 1).filter(
        GuacamoleClientInfo.user_info != '').with_lockmode('update').all()
    if result == None:
        return
    cur_time = datetime.now()
    for res in result:
        seconds = __time_diff(cur_time, res.latest_active_timestamp)
        if seconds >= client_time_limit:
            guacamole_client_vm = res.guacamole_client_vm
            guacamole_client_host = res.guacamole_client_host
            image = res.image

            res.user_info = ''
            res.status = 0
            res.image = ''
            protocol = res.protocol
            guacamole_server = res.guacamole_server
            query = session.query(GuacamoleServerLoad)
            result = query.filter(
                GuacamoleServerLoad.guacamole_server ==
                guacamole_server).with_lockmode('update').first()
            result = __server_protocol_update(protocol, -1, result)

            signal = containerservice.shutdown_container(
                guacamole_client_vm,
                int(guacamole_client_host[guacamole_client_host.index(':') +
                                          1:]), image)
            if signal == False:
                #Record this error
                pass
    session.commit()
    session.close()