12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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 MAC [lindex $argv 8]
- set DESCRIPTION [lindex $argv 9]
- 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 trunk vport 1\r"
- expect "ZXAN(config-if)#"
- send "switchport vlan $VLAN tag 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 "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
- }
- }
- }
|