123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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 SN [lindex $argv 8]
- set DESCRIPTION [lindex $argv 9]
- set DHCPSNOOPING [lindex $argv 10]
- set LOOPDETECT [lindex $argv 11]
- 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 "*#"
- send "configure terminal\r"
- expect "*(config)#"
- send "interface $PON_INT\r"
- expect "*(config-if)#"
- send "onu $ONU_NUM type 1ETH sn $SN\r"
- expect "*(config-if)#"
- send "exit\r"
- expect "*(config)#"
- send "interface $ONU_INT:$ONU_NUM\r"
- if {![string match "__empty" $DESCRIPTION]} {
- expect "*(config-if)#"
- send "description $DESCRIPTION\r"
- }
- expect "*(config-if)#"
- send "tcont 1 name unlim profile unlim\r"
- expect "*(config-if)#"
- send "gemport 1 name unlim unicast tcont 1 dir both\r"
- expect "*(config-if)#"
- send "switchport mode hybrid vport 1\r"
- expect "*(config-if)#"
- send "service-port 1 vport 1 user-vlan $VLAN vlan $VLAN\r"
- if {![string match "__empty" $DHCPSNOOPING]} {
- expect "*(config-if)#"
- send "ip dhcp snooping enable vport 1\r"
- }
- expect "*(config-if)#"
- send "exit\r"
- expect "*(config)#"
- send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
- if {![string match "__empty" $LOOPDETECT]} {
- expect "*(gpon-onu-mng)#"
- send "loop-detect ethuni eth_0/1 enable\r"
- }
- expect "*(gpon-onu-mng)#"
- send "service HSI type internet gemport 1 cos 0 vlan $VLAN\r"
- expect "*(gpon-onu-mng)#"
- send "vlan port eth_0/1 mode tag vlan $VLAN\r"
- expect "*(gpon-onu-mng)#"
- send "end\r"
- expect "*#"
- send "exit\r"
|