Exemplo n.º 1
0
 def __init__(self, drsu_id, is_sim, drc_id, encode='utf-8'):
     DrsuSSHConnection.__init__(
         self,
         drsu_id=drsu_id,
         is_sim=is_sim,
         drc_id=drc_id,
     )
     self.fp = None
     self.sheet1 = None
     self.encoding = encode
     self.rq = time.strftime('%Y%m%d', time.localtime(time.time()))
Exemplo n.º 2
0
def mod_cfg(drsu_id):
    drsuconn = DrsuSSHConnection(drsu_id, False, '0')
    drsuconn.chmod_cfg()
    drsuconn.close()
Exemplo n.º 3
0
def start_drsu(drsu_id):
    drsuconn = DrsuSSHConnection(drsu_id, False, '0')
    if not drsuconn.is_drsu_ready():
        drsuconn.remote_start_drsu()
        time.sleep(30)
        drsuconn.is_drsu_ready()
Exemplo n.º 4
0
def set_version(drsu_id, version):
    drsuconn = DrsuSSHConnection(drsu_id, False, '0')
    drsuconn.set_update_version(version)
    drsuconn.close()
Exemplo n.º 5
0
def bk_drsu_sigble(drsu_id):
    drsuconn = DrsuSSHConnection(drsu_id, False, '0')
    # if drsuconn.is_drsu_ready():
    drsuconn.bk_cfg()
    drsuconn.close()
Exemplo n.º 6
0
def recover_drsu_single(drsu_id):
    drsuconn = DrsuSSHConnection(drsu_id, False, '0')
    # 直接将配置文件替换
    drsuconn.chmod_cfg()
    # dr_drsu_3.2.0_Release-build-3169_1015.gz 演示版本,dr_drsu_3.2.0_Release-build-3233.gz测试版本
    drsuconn.set_update_version(version_demon)
    if drsuconn.remote_ps_drsu_process_num() != 0:
        # 如果有残余进程,先杀进程 然后再重新启动
        drsuconn.remote_kill()
        time.sleep(30)
    drsuconn.remote_start_drsu()
    time.sleep(100)
    if drsuconn.is_drsu_ready():
        logger.info('drsu:%s启动成功' % drsu_id)
        drsuconn.close()
        return True
    else:
        logger.info('drsu:%s启动失败' % drsu_id)
        drsuconn.close()
        return False
Exemplo n.º 7
0
def gather_drsu_data(drsu_id):
    drsuconn = DrsuSSHConnection(str(drsu_id), is_sim=False, drc_id=None)

    if drsuconn.remote_ps_drsu_process_num() != 0:
        # 如果有残余进程,先杀进程 然后再重新启动
        drsuconn.remote_kill()
        time.sleep(10)
    drsuconn.remote_start_drsu()
    time.sleep(100)
    if drsuconn.is_drsu_ready():
        time.sleep(100)
        drsuconn.remote_kill()
        time.sleep(10)
        drsuconn.download_data()
    else:
        drsuconn.remote_kill()
Exemplo n.º 8
0
def deploy_drsu_highway(
    host,
    is_sim,
    remote_path,
    local_path,
    drsu_id='16388',
):
    drsuconn = DrsuSSHConnection(drsu_id,
                                 host=host,
                                 is_sim=is_sim,
                                 drc_id='8200')
    # 從遠端服務器拷貝dr壓縮文件到當前設備
    drsuconn.scp_download(remote_path,
                          local_path,
                          'broadxt333',
                          size=476955837)
    # 解壓dr壓縮文件
    drsuconn.tar_dr()
    # 修改文件夹名 例如将/drsu/drsu_16388 修改为/drsu/drsu_${drsu_id}

    # 修改文件所有用戶為當前用戶
    drsuconn.chmod_dr()
    # 修改配置文件,參數radar
    drsuconn.chmod_cfg('820020021')
    # 修改rc.local添加設備啟動時自啟動drsu
    drsuconn.chmod_rc()

    drsuconn.is_sim = False
    drsuconn.chmod_cfg_not_sim()
    drsuconn.remote_replace_drsu_id()
    if drsuconn.remote_ps_drsu_process_num() != 0:
        # 如果有残余进程,先杀进程 然后再重新启动
        drsuconn.remote_kill()
        time.sleep(5)
    drsuconn.remote_start_drsu()
    time.sleep(30)
    if not drsuconn.is_drsu_ready():
        logger.error('真实drc环境下drsu启动不成功')
        return False

    if drsuconn.remote_ps_drsu_process_num() != 0:
        # 如果有残余进程,先杀进程 然后再重新启动
        drsuconn.remote_kill()
        time.sleep(5)
    drsuconn.remote_start_drsu()
    time.sleep(30)
    if not drsuconn.is_drsu_ready():
        logger.error('虚拟drc环境下drsu启动不成功')
        return False

    drsuconn.close()