def bind_set_result(cpe, status_result, node_name): """ in thread """ ret = ERR_FAIL err_message = "" for nwf in [1]: #rpc 3; path_name = "InternetGatewayDevice.X_CT-COM_UserInfo.Result" dict_data = { "ParameterList": [dict(Name=node_name, Value=status_result)] } obj = MsgWorklistBuild("Auto_SetParameterValue", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if (ret != ERR_SUCCESS): log.app_err(err_message) break else: log.app_err(err_message) break except Exception, e: print_trace(e) break
def auto_exec_worklist(worklist, cpe): """ """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # physic worklist --------------- obj = MsgWorklistBuild(worklist, {}) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "worklist(%s) execute success." % worklist log.app_info(desc) else: log.app_err(err_message) break else: desc = "worklist(%s) execute fail." % worklist log.app_err(desc) break except Exception, e: print_trace(e) break ret = ERR_SUCCESS
def start_monitor_worklist(cpe, obj_monitor): """ obj_alarm is MsgMonitorInform """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # physic worklist --------------- dict_data = { "parameterlist": obj_monitor.parameterlist, "timelist": obj_monitor.timelist } obj = MsgWorklistBuild("Inform_Monitor_Monitor_Start", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) save_id2worklistid(obj_monitor.id_, obj_database.id_) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "start_monitor_worklist(id=%s) success." % ( obj_database.id_) log.app_info(desc) obj_monitor.dict_ret["str_result"] = desc else: # worklist(id=worklist_2014-07-08_11:48:15.781_82424709) status is not success(fail) # nwf 2014-07-08; +worklist fail obj_db = restore_acs_worklist(obj_database.id_) err_message = err_message + "\n" + obj_db.dict_ret[ "str_result"] log.app_err(err_message) obj_monitor.dict_ret["str_result"] = err_message break else: log.app_err(err_message) obj_monitor.dict_ret["str_result"] = err_message break except Exception, e: print_trace(e) obj_monitor.dict_ret["str_result"] = e break ret = ERR_SUCCESS
def stop_alarm_worklist(cpe, obj_alarm): """ obj_alarm is MsgAlarmInform """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # physic worklist --------------- start_worklist_id = get_id2worklistid(obj_alarm.id_) pop_id2worklistid(obj_alarm.id_) node_add_object = get_worklist_node_add_object(start_worklist_id) if (not node_add_object): desc = "node_add_object is None." log.app_err(desc) pop_worklist_node_add_object(obj_alarm.id_) dict_data = {"node_add_object": node_add_object} obj = MsgWorklistBuild("Inform_Monitor_Alarm_Stop", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "stop_alarm_worklist success." log.app_info(desc) obj_alarm.dict_ret["str_result"] = desc else: log.app_err(err_message) obj_alarm.dict_ret["str_result"] = err_message break else: log.app_err(err_message) obj_alarm.dict_ret["str_result"] = err_message break except Exception, e: print_trace(e) obj_alarm.dict_ret["str_result"] = e break ret = ERR_SUCCESS
def accountchange_ct(cpe): """ """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # physic worklist --------------- password = random.randrange(10000000, 99999999) password = "******" + str(password) dict_data = { "ParameterList": [ dict( Name= "InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.Enable", Value="1"), dict( Name= "InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.Password", Value=password) ] } obj = MsgWorklistBuild("Auto_SetParameterValue", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: log.app_info( "update InternetGatewayDevice.DeviceInfo.X_CT-COM_TeleComAccount.Password success: %s" % password) else: log.app_err(err_message) break else: log.app_err(err_message) break except Exception, e: print_trace(e) break ret = ERR_SUCCESS
def bootstrap_ct(cpe): """ in thread """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # nwf 2014-06-16; user config #update_interface_version(cpe) # 重置双向的DIGEST认证账号和电信维护账号密码 --added by lana 20131209 ret = reset_digest_account_and_telecom_account_ct(cpe) if ret != ERR_SUCCESS: break # physic worklist --------------- obj = MsgWorklistBuild("Auto_GetRPCMethods", {}) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "worklist(Auto_GetRPCMethods) execute success." log.app_info(desc) else: log.app_err(err_message) break else: desc = "worklist(Auto_GetRPCMethods) execute fail." log.app_err(desc) break except Exception, e: print_trace(e) break ret = ERR_SUCCESS
def update_interface_version(cpe): """ 0 boot need update AUTO version """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # physic worklist --------------- obj = MsgWorklistBuild("Auto_UpdateInterfaceVersion", {}) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "worklist(Auto_UpdateInterfaceVersion) execute success." log.app_info(desc) else: log.app_err(err_message) break else: desc = "worklist(Auto_UpdateInterfaceVersion) execute fail." log.app_err(desc) break except Exception, e: print_trace(e) break ret = ERR_SUCCESS
def reset_digest_account_and_telecom_account_cu(cpe): """ 重置联通双向的DIGEST认证账号和终端维护账号密码 """ ret = ERR_FAIL err_message = "" for i in [1]: # 新的双向的DIGEST认证账号的生成规则为:old+8为随机数 user_name = get_random_8str(cpe.cpe_property.get_cpe2acs_loginname()) password = get_random_8str( cpe.cpe_property.get_cpe2acs_loginpassword()) connection_request_user_name = get_random_8str( cpe.cpe_property.get_acs2cpe_loginname()) connection_request_password = get_random_8str( cpe.cpe_property.get_acs2cpe_loginpassword()) # 新的电信维护账号密码的生成规则为 “cutelecomadmin” + 8位随机数 tele_com_account_password = get_random_8str("cuadmin") # 组建所有要设置的节点参数 dict_data = { "ParameterList": [ dict(Name="InternetGatewayDevice.ManagementServer.Username", Value=user_name), dict(Name="InternetGatewayDevice.ManagementServer.Password", Value=password), dict( Name= "InternetGatewayDevice.ManagementServer.ConnectionRequestUsername", Value=connection_request_user_name), dict( Name= "InternetGatewayDevice.ManagementServer.ConnectionRequestPassword", Value=connection_request_password), dict(Name= "InternetGatewayDevice.X_CU_Function.Web.AdminPassword", Value=tele_com_account_password) ] } # 组建工单消息,下发工单执行命令 obj = MsgWorklistBuild("Auto_SetParameterValue", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: cpe.cpe_property.set_cpe2acs_loginname(user_name) cpe.cpe_property.set_cpe2acs_loginpassword(password) cpe.cpe_property.set_acs2cpe_loginname( connection_request_user_name) cpe.cpe_property.set_acs2cpe_loginpassword( connection_request_password) log.app_info( "worklist(Auto_SetParameterValue) execute success.") log.app_info( "update InternetGatewayDevice.ManagementServer.Username success: %s" % user_name) log.app_info( "update InternetGatewayDevice.ManagementServer.Password success: %s" % password) log.app_info( "update InternetGatewayDevice.ManagementServer.ConnectionRequestUsername success: %s" % connection_request_user_name) log.app_info( "update InternetGatewayDevice.ManagementServer.ConnectionRequestPassword success: %s" % connection_request_password) log.app_info( "update InternetGatewayDevice.X_CU_Function.Web.AdminPassword success: %s" % tele_com_account_password) else: log.app_err(err_message) break else: desc = "worklist(Auto_SetParameterValue) execute fail." log.app_err(desc) break except Exception, e: print_trace(e) break ret = ERR_SUCCESS
def bootstrap_cu(cpe): """ in thread """ ret = ERR_FAIL err_message = "" sn = cpe.get_sn() for nwf in [1]: # 获取上网账号和密码 # 组建工单参数 dict_data = {} # 组建工单消息,下发工单执行命令 obj = MsgWorklistBuild("Auto_GetPPPConnectionAccount", dict_data) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "worklist(Auto_GetPPPConnectionAccount) execute success." log.app_info(desc) else: log.app_err(err_message) # 忽略查询结果 # break else: desc = "worklist(Auto_GetPPPConnectionAccount) execute fail." log.app_err(desc) break except Exception, e: print_trace(e) break # physic worklist --------------- obj = MsgWorklistBuild("Auto_GetRPCMethods", {}) obj_database = EventCode.auto_build_bind_physic_worklist(cpe, obj) try: ret, err_message = EventCode.tx_worklist_exec(obj_database) ret = EventCode.rx_worklist_exec(ret, err_message) if (ret == ERR_SUCCESS): ret, err_message = EventCode.wait_worklist_exec_finish( obj_database) if ret == ERR_SUCCESS: desc = "worklist(Auto_GetRPCMethods) execute success." log.app_info(desc) else: log.app_err(err_message) break else: desc = "worklist(Auto_GetRPCMethods) execute fail." log.app_err(desc) break except Exception, e: print_trace(e) break