1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- set timeout 20
- set IP [lindex $argv 0]
- set LOGIN [lindex $argv 1]
- set PASSWORD [lindex $argv 2]
- set METHOD [lindex $argv 3]
- set PON_INT [lindex $argv 4]
- set ONU_INT [lindex $argv 5]
- set ONU_NUM [lindex $argv 6]
- set VLAN [lindex $argv 7]
- set SVLAN [lindex $argv 8]
- set MAC [lindex $argv 9]
- set DESCRIPTION [lindex $argv 10]
- if {[string match "TELNET" $METHOD]} {
- spawn telnet $IP
- expect "Username:*"
- send "$LOGIN\r"
- } elseif {[string match "SSH" $METHOD]} {
- spawn ssh $LOGIN@$IP
- expect {
- "(yes/no" {
- send "yes\r"
- }
- }
- }
- expect "Password:*"
- send "$PASSWORD\r"
- expect "ZXAN#"
- send "configure terminal\r"
- expect "ZXAN(config)#"
- send "interface $PON_INT\r"
- expect "ZXAN(config-if)#"
- send "onu $ONU_NUM type 1GE mac $MAC\r"
- expect "ZXAN(config-if)#"
- send "exit\r"
- expect "ZXAN(config)#"
- send "interface $ONU_INT:$ONU_NUM\r"
- if {![string match "__empty" $DESCRIPTION]} {
- expect "ZXAN(config-if)#"
- send "property description $DESCRIPTION\r"
- }
- expect "ZXAN(config-if)#"
- send "switchport mode hybrid vport 1\r"
- expect "ZXAN(config-if)#"
- send "admin enable\r"
- expect "ZXAN(config-if)#"
- send "sla-profile 1G\r"
- expect "ZXAN(config-if)#"
- send "service-port 1 vport 1 user-vlan $VLAN svlan $SVLAN"
- expect "ZXAN(config-if)#"
- send "exit\r"
- expect "ZXAN(config)#"
- send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
- expect "ZXAN(epon-onu-mng)#"
- sleep 2
- send "vlan port eth_0/1 mode tag vlan $VLAN priority 0\r"
- for {set i 1} { $i < 60} {incr i 1} {
- expect {
- "%Code*" {
- sleep 3
- send "vlan port eth_0/1 mode tag vlan $VLAN priority 0\r"
- exp_continue
- }
- "ZXAN(epon-onu-mng)#" {
- send "end\r"
- expect "*#"
- send "exit\r"
- exit
- }
- }
- }
|