示例#1
0
def test_script(obj):
    """
    """
    sn = obj.sn # 取得SN号
    DeviceType = "ADSL"  # 绑定tr069模板类型.只支持ADSL\LAN\EPON三种
    AccessMode = 'DHCP'    # WAN接入模式,可选PPPoE_Bridge,PPPoE,DHCP,Static
    rollbacklist = []  # 存储工单失败时需回退删除的实例.目前缺省是不开启回退
    # 初始化日志
    obj.dict_ret.update(str_result=u"开始执行工单:%s........\n" %
                        os.path.basename(os.path.dirname(__file__)))
    
    # data传参
    PVC_OR_VLAN = "Null"    # 由于是VOIP取消脚本,所以不关心此值,但又必须传参
    X_CT_COM_ServiceList = obj.dict_data.get("X_CT_COM_ServiceList")[0]
    WANEnable_Switch = "Null" # 由于是VOIP取消脚本,所以不关心此值,但又必须传参
    
    # "InternetGatewayDevice.Services.VoiceService.1."
    # 注意,H248的Capabilities.SignalingProtocols节点是只读的,但贝曼工单里有下发这个参数,所以.....
    dict_voiceservice = {"VoiceProfile.1.Line.1.Enable":[1, "Disabled"],
                         "VoiceProfile.1.Line.2.Enable":[0, "Disabled"]}
    
    # 对X_CT_COM_LanInterface重新解析,兼容GUI或RF传参数LAN1,lan1格式
    #ret, X_CT_COM_LanInterface = ParseLANName(X_CT_COM_LanInterface)
    #if ret == ERR_FAIL:
    #    info = u'输入的X_CT_COM_LanInterface参数错误'
    #    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + info)
    #    return ret_res
    
    
    # WANDSLLinkConfig节点参数
    dict_wanlinkconfig = {}
    
    # WANPPPConnection节点参数
    # 注意:X_CT-COM_IPMode节点有些V4版本没有做,所以不能使能为1.实际贝曼工单也是没有下发的
    dict_wanpppconnection = {}
    
    # WANIPConnection节点参数
    dict_wanipconnection = {'X_CT-COM_ServiceList':[1, X_CT_COM_ServiceList],
                            'ConnectionType':[1, "IP_Routed"]}
    
    # 执行VOIP开通工单
    ret, ret_data = VOIP(obj, sn, WANEnable_Switch, DeviceType, 
                        AccessMode, PVC_OR_VLAN,
                        dict_voiceservice,
                        dict_wanlinkconfig, 
                        dict_wanpppconnection, dict_wanipconnection,
                        rollbacklist=rollbacklist)
    
    # 将工单脚本执行结果返回到OBJ的结果中
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + ret_data)
    
    # 如果执行失败,统一调用回退机制(缺省是关闭的)
    if ret == ERR_FAIL:
        ret_rollback, ret_data_rollback = rollback(sn, rollbacklist, obj)
        obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + ret_data_rollback)
    
    info = u"工单:%s执行结束\n" % os.path.basename(os.path.dirname(__file__))
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + info)    
    return ret
示例#2
0
def test_script(obj):
    """
    """
    sn = obj.sn  # 取得SN号
    DeviceType = "EPON"  # 绑定tr069模板类型.只支持ADSL\LAN\EPON三种
    AccessMode = 'DHCP'  # WAN接入模式,可选PPPoE_Bridge,PPPoE,DHCP,Static
    rollbacklist = []  # 存储工单失败时需回退删除的实例.目前缺省是不开启回退
    # 初始化日志
    obj.dict_ret.update(str_result=u"开始执行工单:%s........\n" %
                        os.path.basename(os.path.dirname(__file__)))

    # data传参
    MediaGatewayControler = obj.dict_data.get("MediaGatewayControler")[0]
    Standby_MediaGatewayControler = obj.dict_data.get(
        "Standby_MediaGatewayControler")[0]
    DeviceID = obj.dict_data.get("DeviceID")[0]
    DeviceIDType = obj.dict_data.get("DeviceIDType")[0]
    PhysicalTermID = obj.dict_data.get("PhysicalTermID")[0]
    PhysicalTermIDPrefix = obj.dict_data.get("PhysicalTermIDPrefix")[0]
    PhysicalTermIDAddLen = obj.dict_data.get("PhysicalTermIDAddLen")[0]
    PVC_OR_VLAN = obj.dict_data.get("PVC_OR_VLAN")[
        0]  # ADSL上行只关心PVC值,LAN和EPON上行则关心VLAN值
    X_CT_COM_ServiceList = obj.dict_data.get("X_CT_COM_ServiceList")[0]
    WANEnable_Switch = obj.dict_data.get("WANEnable_Switch")[0]

    # "InternetGatewayDevice.Services.VoiceService.1."
    # 注意,H248的Capabilities.SignalingProtocols节点是只读的,但贝曼工单里有下发这个参数,所以.....
    dict_voiceservice = {
        "VoiceProfile.1.X_CT-COM_ServerType": [1, "2"],
        "Capabilities.SignalingProtocols": [0, "H.248"],
        "VoiceProfile.1.X_CT-COM_H248.MediaGatewayControler":
        [1, MediaGatewayControler],
        "VoiceProfile.1.X_CT-COM_H248.MediaGatewayControlerPort": [1, "2944"],
        "VoiceProfile.1.X_CT-COM_H248.Standby-MediaGatewayControler":
        [1, Standby_MediaGatewayControler],
        "VoiceProfile.1.X_CT-COM_H248.Standby-MediaGatewayControlerPort":
        [1, "2944"],
        "VoiceProfile.1.X_CT-COM_H248.MediaGatewayPort": [1, "2944"],
        "VoiceProfile.1.X_CT-COM_H248.MessageEncodingType": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.DeviceID": [1, DeviceID],
        "VoiceProfile.1.X_CT-COM_H248.DeviceIDType": [1, DeviceIDType],
        "VoiceProfile.1.X_CT-COM_H248.PhysicalTermID": [1, PhysicalTermID],
        "VoiceProfile.1.X_CT-COM_H248.PhysicalTermIDConfigMethod": [1, "0"],
        "VoiceProfile.1.X_CT-COM_H248.PhysicalTermIDPrefix":
        [1, PhysicalTermIDPrefix],
        "VoiceProfile.1.X_CT-COM_H248.PhysicalTermIDAddLen":
        [1, PhysicalTermIDAddLen],
        "VoiceProfile.1.X_CT-COM_H248.RTPPrefix": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.EphemeralTermIDAddLen": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.EphemeralTermIDUniform": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.EphemeralTermIDStart": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.ThreeHandShake": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.LongTimer": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.PendingTimerInit": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.RetranIntervalTimer": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.MaxRetranCount": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.RetransmissionTime": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.RetransmissionCycle": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.HeartbeatMode": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.HeartbeatCycle": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.HeartbeatCount": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.RegisterCycle": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.MandatoryRegister": [0, "Null"],
        "VoiceProfile.1.X_CT-COM_H248.AuthenticationMethID": [0, "Null"],
        "VoiceProfile.1.Line.1.X_CT-COM_H248.PhysicalTermID": [0, "Null"],
        "VoiceProfile.1.Line.2.X_CT-COM_H248.PhysicalTermID": [0, "Null"],
        "VoiceProfile.1.Line.1.Enable": [1, "Enabled"],
        "VoiceProfile.1.Line.2.Enable": [1, "Enabled"]
    }

    # 对X_CT_COM_LanInterface重新解析,兼容GUI或RF传参数LAN1,lan1格式
    #ret, X_CT_COM_LanInterface = ParseLANName(X_CT_COM_LanInterface)
    #if ret == ERR_FAIL:
    #    info = u'输入的X_CT_COM_LanInterface参数错误'
    #    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + info)
    #    return ret_res

    # X_CT-COM_WANEponLinkConfig节点参数
    if PVC_OR_VLAN == "":
        PVC_OR_VLAN_flag = 0
    else:
        PVC_OR_VLAN_flag = 1

    dict_wanlinkconfig = {
        'Enable': [1, '1'],
        'Mode': [PVC_OR_VLAN_flag, '2'],
        'VLANIDMark': [PVC_OR_VLAN_flag, PVC_OR_VLAN]
    }

    # WANPPPConnection节点参数
    # 注意:X_CT-COM_IPMode节点有些V4版本没有做,所以不能使能为1.实际贝曼工单也是没有下发的
    dict_wanpppconnection = {}

    # WANIPConnection节点参数
    dict_wanipconnection = {
        'Enable': [1, '1'],
        'ConnectionType': [1, 'IP_Routed'],
        'Name': [0, 'Null'],
        'NATEnabled': [0, 'Null'],
        'AddressingType': [1, 'DHCP'],
        'ExternalIPAddress': [0, '10.10.10.10'],
        'SubnetMask': [0, '255.255.255.0'],
        'DefaultGateway': [0, '10.10.10.1'],
        'DNSEnabled': [0, 'Null'],
        'DNSServers': [0, '10.10.10.2'],
        'X_CT-COM_LanInterface': [0, "Null"],
        'X_CT-COM_ServiceList': [1, X_CT_COM_ServiceList]
    }

    # 执行VOIP开通工单
    ret, ret_data = VOIP(obj,
                         sn,
                         WANEnable_Switch,
                         DeviceType,
                         AccessMode,
                         PVC_OR_VLAN,
                         dict_voiceservice,
                         dict_wanlinkconfig,
                         dict_wanpppconnection,
                         dict_wanipconnection,
                         rollbacklist=rollbacklist)

    # 将工单脚本执行结果返回到OBJ的结果中
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + ret_data)

    # 如果执行失败,统一调用回退机制(缺省是关闭的)
    if ret == ERR_FAIL:
        ret_rollback, ret_data_rollback = rollback(sn, rollbacklist, obj)
        obj.dict_ret.update(str_result=obj.dict_ret["str_result"] +
                            ret_data_rollback)

    info = u"工单:%s执行结束\n" % os.path.basename(os.path.dirname(__file__))
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + info)
    return ret
示例#3
0
def test_script(obj):
    """
    """
    sn = obj.sn  # 取得SN号
    DeviceType = "EPON"  # 绑定tr069模板类型.只支持ADSL\LAN\EPON三种
    AccessMode = 'DHCP'  # WAN接入模式,可选PPPoE_Bridge,PPPoE,DHCP,Static
    rollbacklist = []  # 存储工单失败时需回退删除的实例.目前缺省是不开启回退
    # 初始化日志
    obj.dict_ret.update(str_result=u"开始执行工单:%s........\n" %
                        os.path.basename(os.path.dirname(__file__)))

    # data传参
    ProxyServer = obj.dict_data.get("ProxyServer")[0]
    ProxyServerPort = obj.dict_data.get("ProxyServerPort")[0]
    RegistrarServer = obj.dict_data.get("RegistrarServer")[0]
    RegistrarServerPort = obj.dict_data.get("RegistrarServerPort")[0]
    OutboundProxy = obj.dict_data.get("OutboundProxy")[0]
    OutboundProxyPort = obj.dict_data.get("OutboundProxyPort")[0]
    X_CU_SecondaryProxyServer = obj.dict_data.get(
        "X_CU_SecondaryProxyServer")[0]
    X_CU_SecondaryProxyServerPort = obj.dict_data.get(
        "X_CU_SecondaryProxyServerPort")[0]
    X_CU_SecondaryRegistrarServer = obj.dict_data.get(
        "X_CU_SecondaryRegistrarServer")[0]
    X_CU_SecondaryRegistrarServerPort = obj.dict_data.get(
        "X_CU_SecondaryRegistrarServerPort")[0]
    X_CU_SecondaryOutboundProxyServer = obj.dict_data.get(
        "X_CU_SecondaryOutboundProxyServer")[0]
    X_CU_SecondaryOutboundProxyServerPort = obj.dict_data.get(
        "X_CU_SecondaryOutboundProxyServerPort")[0]
    AuthUserName1 = obj.dict_data.get("AuthUserName1")[0]
    AuthPassword1 = obj.dict_data.get("AuthPassword1")[0]
    URI1 = obj.dict_data.get("URI1")[0]
    AuthUserName2 = obj.dict_data.get("AuthUserName2")[0]
    AuthPassword2 = obj.dict_data.get("AuthPassword2")[0]
    URI2 = obj.dict_data.get("URI2")[0]
    PVC_OR_VLAN = obj.dict_data.get("PVC_OR_VLAN")[
        0]  # ADSL上行只关心PVC值,LAN和EPON上行则关心VLAN值
    X_CU_ServiceList = obj.dict_data.get("X_CU_ServiceList")[0]
    WANEnable_Switch = obj.dict_data.get("WANEnable_Switch")[0]

    # "InternetGatewayDevice.Services.VoiceService.1."
    dict_voiceservice = {
        "VoiceProfile.1.SIP.ProxyServer": [1, ProxyServer],
        "VoiceProfile.1.SIP.ProxyServerPort": [1, ProxyServerPort],
        "VoiceProfile.1.SIP.ProxyServerTransport": [0, "Null"],
        "VoiceProfile.1.SIP.RegistrarServer": [1, RegistrarServer],
        "VoiceProfile.1.SIP.RegistrarServerPort": [1, RegistrarServerPort],
        "VoiceProfile.1.SIP.RegistrarServerTransport": [0, "Null"],
        "VoiceProfile.1.SIP.OutboundProxy": [1, OutboundProxy],
        "VoiceProfile.1.SIP.OutboundProxyPort": [1, OutboundProxyPort],
        "VoiceProfile.1.SIP.X_CU_SecondaryProxyServer":
        [1, X_CU_SecondaryProxyServer],
        "VoiceProfile.1.SIP.X_CU_SecondaryProxyServerPort":
        [1, X_CU_SecondaryProxyServerPort],
        "VoiceProfile.1.SIP.X_CU_SecondaryProxyServerTransport": [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_SecondaryRegistrarServer":
        [1, X_CU_SecondaryRegistrarServer],
        "VoiceProfile.1.SIP.X_CU_SecondaryRegistrarServerPort":
        [1, X_CU_SecondaryRegistrarServerPort],
        "VoiceProfile.1.SIP.X_CU_SecondaryRegistrarServerTransport":
        [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_SecondaryOutboundProxyServer":
        [1, X_CU_SecondaryOutboundProxyServer],
        "VoiceProfile.1.SIP.X_CU_SecondaryOutboundProxyServerPort":
        [1, X_CU_SecondaryOutboundProxyServerPort],
        "VoiceProfile.1.SIP.UserAgentDomain": [0, "Null"],
        "VoiceProfile.1.SIP.UserAgentPort": [0, "Null"],
        "VoiceProfile.1.SIP.UserAgentTransport": [0, "Null"],
        "VoiceProfile.1.SIP.VLANIDMark": [0, "Null"],
        "VoiceProfile.1.SIP.X_CT-COM_802-1pMark": [0, "Null"],
        "VoiceProfile.1.SIP.DSCPMark": [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_HeartbeatSwitch": [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_HeartbeatCycle": [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_HeartbeatCount": [0, "Null"],
        "VoiceProfile.1.SIP.X_CU_SessionUpdateTimer": [0, "Null"],
        "VoiceProfile.1.SIP.RegisterRetryInterval": [0, "Null"],
        "VoiceProfile.1.SIP.RegisterExpires": [0, "Null"],
        "VoiceProfile.1.SIP.ImplicitRegistrationEnable": [0, "Null"],
        "VoiceProfile.1.Line.1.SIP.AuthUserName": [1, AuthUserName1],
        "VoiceProfile.1.Line.1.SIP.AuthPassword": [1, AuthPassword1],
        "VoiceProfile.1.Line.1.SIP.URI": [1, URI1],
        "VoiceProfile.1.Line.2.SIP.AuthUserName": [1, AuthUserName2],
        "VoiceProfile.1.Line.2.SIP.AuthPassword": [1, AuthPassword2],
        "VoiceProfile.1.Line.2.SIP.URI": [1, URI2],
        "VoiceProfile.1.Line.1.Enable": [1, "Enabled"],
        "VoiceProfile.1.Line.2.Enable": [1, "Enabled"]
    }

    # WANConnectionDevice节点参数
    if PVC_OR_VLAN == "":
        PVC_OR_VLAN_flag = 0
    else:
        PVC_OR_VLAN_flag = 1

    dict_wanlinkconfig = {
        'X_CU_VLANEnabled': [PVC_OR_VLAN_flag, '1'],
        'X_CU_802_1p': [PVC_OR_VLAN_flag, '0'],
        'X_CU_VLAN': [PVC_OR_VLAN_flag, PVC_OR_VLAN]
    }

    # WANPPPConnection节点参数
    # 注意:X_CU_IPMode节点有些V4版本没有做,所以不能使能为1.实际贝曼工单也是没有下发的
    dict_wanpppconnection = {}

    # WANIPConnection节点参数
    dict_wanipconnection = {
        'Enable': [1, '1'],
        'ConnectionType': [1, 'IP_Routed'],
        'Name': [0, 'Null'],
        'NATEnabled': [0, 'Null'],
        'AddressingType': [1, 'DHCP'],
        'ExternalIPAddress': [0, '10.10.10.10'],
        'SubnetMask': [0, '255.255.255.0'],
        'DefaultGateway': [0, '10.10.10.1'],
        'DNSEnabled': [0, 'Null'],
        'DNSServers': [0, '10.10.10.2'],
        'X_CU_LanInterface': [0, "Null"],
        'X_CU_ServiceList': [1, X_CU_ServiceList]
    }

    # 执行VOIP开通工单
    ret, ret_data = VOIP(obj,
                         sn,
                         WANEnable_Switch,
                         DeviceType,
                         AccessMode,
                         PVC_OR_VLAN,
                         dict_voiceservice,
                         dict_wanlinkconfig,
                         dict_wanpppconnection,
                         dict_wanipconnection,
                         rollbacklist=rollbacklist)

    # 将工单脚本执行结果返回到OBJ的结果中
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + ret_data)

    # 如果执行失败,统一调用回退机制(缺省是关闭的)
    if ret == ERR_FAIL:
        ret_rollback, ret_data_rollback = rollback(sn, rollbacklist, obj)
        obj.dict_ret.update(str_result=obj.dict_ret["str_result"] +
                            ret_data_rollback)

    info = u"工单:%s执行结束\n" % os.path.basename(os.path.dirname(__file__))
    obj.dict_ret.update(str_result=obj.dict_ret["str_result"] + info)
    return ret