123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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 4ETH 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 "gemport 1 traffic-limit downstream unlim \r"
- expect "*(config-if)#"
- send "switchport mode hybrid vport 1\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 "loop-detect ethuni eth_0/2 enable\r"
- expect "*(gpon-onu-mng)#"
- send "loop-detect ethuni eth_0/3 enable\r"
- expect "*(gpon-onu-mng)#"
- send "loop-detect ethuni eth_0/4 enable\r"
- }
- expect "*(gpon-onu-mng)#"
- send "flow mode 1 tag-filter vid-filter untag-filter discard\r"
- expect "*(gpon-onu-mng)#"
- send "flow 1 priority 0 vid $VLAN\r"
- expect "*(gpon-onu-mng)#"
- send "gemport 1 flow 1\r"
- expect "*(gpon-onu-mng)#"
- send "switchport-bind switch_0/1 iphost 1\r"
- expect "*(gpon-onu-mng)#"
- send "ip-host 1 dhcp-enable true ping-response true traceroute-response true\r"
- expect "*(gpon-onu-mng)#"
- send "vlan-filter-mode iphost 1 tag-filter vid-filter untag-filter discard\r"
- expect "*(gpon-onu-mng)#"
- send "vlan-filter iphost 1 priority 0 vid $VLAN\r"
- expect "*(gpon-onu-mng)#"
- send "dhcp-ip ethuni eth_0/1 from-onu\r"
- expect "*(gpon-onu-mng)#"
- send "dhcp-ip ethuni eth_0/2 from-onu\r"
- expect "*(gpon-onu-mng)#"
- send "dhcp-ip ethuni eth_0/3 from-onu\r"
- expect "*(gpon-onu-mng)#"
- send "dhcp-ip ethuni eth_0/4 from-onu\r"
- expect "*(gpon-onu-mng)#"
- send "end\r"
- expect "*#"
- send "exit\r"
|