{
    "name"  : "PPPoE配置是否错误",
    "precondition" : ["physicalPort", "dailPort"],
    "problems" : {
        "ip_address_negotiate" : {
            "desc"      : "【问题】dialer口下未配置ip address negotiate",
            "advice"    : "【建议】在dialer口下配置ip address negotiate" 
        },
        "pap_username_password" : {
            "desc"      : "【问题】dialer口下面未配置pap认证的用户名和密码",
            "advice"    : "【建议】 在dialer口下配置ppp pap sent-username 用户名password 密码" 
        },
        "chap_username" : {
            "desc"      : "【问题】dialer口下面未配置chap认证的用户名",
            "advice"    : "【建议】在dialer口下配置ppp chap hostname 用户名" 
        },
        "chap_password" : {
            "desc"      : "【问题】dialer口下面未配置chap认证的密码",
            "advice"    : "【建议】在dialer口下配置ppp chap password密码" 
        },
        "pool_empty" : {
            "desc"      : "【问题】dialer口下面未关联地址池",
            "advice"    : "【建议】在dialer口下配置dialer pool xx" 
        },
        "pool_error" : {
            "desc"      : "【问题】物理口和拨号口下面对应的pool值不相等",
            "advice"    : "【建议】修改配置，将两者的pool值修改为一致" 
        }
    }
}

---------------------------code-------------------------------
physical = precondition('physicalPort')
physical = physical.portName
dialer = precondition('dailPort')

cmd = 'show run int ' + dialer + ' | inc ip address negotiate'
response = cli(cmd)
response = response.split(/\r?\n/)
val = response[2]
if !val  :
    add_problem("ip_address_negotiate")
    return 'warn'
end

cmd = 'show run int ' + dialer + ' | inc ppp pap sent-username'
response = cli(cmd)
response = response.split(/\r?\n/)
val = response[2]
if !val :
    add_problem("pap_username_password")
    return 'warn'
end

cmd = 'show run int ' + dialer + ' | inc ppp chap hostname'
response = cli(cmd)
response = response.split(/\r?\n/)
val = response[2]
if !val :
    add_problem("chap_username")
    return 'warn'
end

cmd = 'show run int ' + dialer + ' | inc ppp chap password'
response = cli(cmd)
response = response.split(/\r?\n/)
val = response[2]
if !val :
    add_problem("chap_password")
    return 'warn'
end

cmd = 'show run int ' + dialer + ' | inc dialer pool'
response = cli(cmd)
response = response.split(/\r?\n/)
val = response[2]
if !val :
    add_problem("pool_empty")
    return 'warn'
end

cmd = 'show run interface ' + physical
response = cli(cmd)
pool_physical = response.match(/dial-pool-number\s(\d+)/)
if !pool_physical :
    add_problem("pool_error")
    return 'warn'
else :
    pool_physical = pool_physical[1]
end
cmd = 'show run interface ' + dialer
response = cli(cmd)
pool_dialer = response.match(/dialer\spool\s(\d+)/)
if !pool_dialer :
    add_problem("pool_error")
    return 'warn'
else :
    pool_dialer = pool_dialer[1]
end
if pool_physical != pool_dialer :
    add_problem("pool_error")
    return 'warn'
end

return 'success'