GPON_1_CVLAN 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. set timeout 20
  2. set IP [lindex $argv 0]
  3. set LOGIN [lindex $argv 1]
  4. set PASSWORD [lindex $argv 2]
  5. set METHOD [lindex $argv 3]
  6. set PON_INT [lindex $argv 4]
  7. set ONU_INT [lindex $argv 5]
  8. set ONU_NUM [lindex $argv 6]
  9. set VLAN [lindex $argv 7]
  10. set SN [lindex $argv 8]
  11. set DESCRIPTION [lindex $argv 9]
  12. set DHCPSNOOPING [lindex $argv 10]
  13. set LOOPDETECT [lindex $argv 11]
  14. if {[string match "TELNET" $METHOD]} {
  15. spawn telnet $IP
  16. expect "Username:*"
  17. send "$LOGIN\r"
  18. } elseif {[string match "SSH" $METHOD]} {
  19. spawn ssh $LOGIN@$IP
  20. expect {
  21. "(yes/no" {
  22. send "yes\r"
  23. }
  24. }
  25. }
  26. expect "Password:*"
  27. send "$PASSWORD\r"
  28. expect "*#"
  29. send "configure terminal\r"
  30. expect "*(config)#"
  31. send "interface $PON_INT\r"
  32. expect "*(config-if)#"
  33. send "onu $ONU_NUM type 1ETH sn $SN\r"
  34. expect "*(config-if)#"
  35. send "exit\r"
  36. expect "*(config)#"
  37. send "interface $ONU_INT:$ONU_NUM\r"
  38. if {![string match "__empty" $DESCRIPTION]} {
  39. expect "*(config-if)#"
  40. send "description $DESCRIPTION\r"
  41. }
  42. expect "*(config-if)#"
  43. send "tcont 1 name unlim profile unlim\r"
  44. expect "*(config-if)#"
  45. send "gemport 1 name unlim unicast tcont 1 dir both\r"
  46. expect "*(config-if)#"
  47. send "switchport mode hybrid vport 1\r"
  48. if {![string match "__empty" $DHCPSNOOPING]} {
  49. expect "*(config-if)#"
  50. send "ip dhcp snooping enable vport 1\r"
  51. }
  52. expect "*(config-if)#"
  53. send "exit\r"
  54. expect "*(config)#"
  55. send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
  56. if {![string match "__empty" $LOOPDETECT]} {
  57. expect "*(gpon-onu-mng)#"
  58. send "loop-detect ethuni eth_0/1 enable\r"
  59. }
  60. expect "*(gpon-onu-mng)#"
  61. send "service HSI type internet gemport 1 cos 0 vlan $VLAN\r"
  62. expect "*(gpon-onu-mng)#"
  63. send "vlan port eth_0/1 mode tag vlan $VLAN\r"
  64. expect "*(gpon-onu-mng)#"
  65. send "end\r"
  66. expect "*#"
  67. send "exit\r"