GPON_4_QINQ 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 SVLAN [lindex $argv 8]
  11. set SN [lindex $argv 9]
  12. set DESCRIPTION [lindex $argv 10]
  13. set DHCPSNOOPING [lindex $argv 11]
  14. set LOOPDETECT [lindex $argv 12]
  15. if {[string match "TELNET" $METHOD]} {
  16. spawn telnet $IP
  17. expect "Username:*"
  18. send "$LOGIN\r"
  19. } elseif {[string match "SSH" $METHOD]} {
  20. spawn ssh $LOGIN@$IP
  21. expect {
  22. "(yes/no" {
  23. send "yes\r"
  24. }
  25. }
  26. }
  27. expect "Password:*"
  28. send "$PASSWORD\r"
  29. expect "*#"
  30. send "configure terminal\r"
  31. expect "*(config)#"
  32. send "interface $PON_INT\r"
  33. expect "*(config-if)#"
  34. send "onu $ONU_NUM type 4ETH sn $SN\r"
  35. expect "*(config-if)#"
  36. send "exit\r"
  37. expect "*(config)#"
  38. send "interface $ONU_INT:$ONU_NUM\r"
  39. if {![string match "__empty" $DESCRIPTION]} {
  40. expect "*(config-if)#"
  41. send "description $DESCRIPTION\r"
  42. }
  43. expect "*(config-if)#"
  44. send "tcont 1 profile unlim\r"
  45. expect "*(config-if)#"
  46. send "gemport 1 name unlim tcont 1\r"
  47. expect "*(config-if)#"
  48. send "gemport 1 traffic-limit upstream unlim downstream unlim\r"
  49. expect "*(config-if)#"
  50. send "switchport mode hybrid vport 1\r"
  51. expect "*(config-if)#"
  52. send "service-port 1 vport 1 user-vlan $VLAN svlan $SVLAN\r"
  53. if {![string match "__empty" $DHCPSNOOPING]} {
  54. expect "*(config-if)#"
  55. send "ip dhcp snooping enable vport 1\r"
  56. }
  57. expect "*(config-if)#"
  58. send "exit\r"
  59. expect "*(config)#"
  60. send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
  61. if {![string match "__empty" $LOOPDETECT]} {
  62. expect "*(gpon-onu-mng *"
  63. send "loop-detect ethuni eth_0/1 enable\r"
  64. expect "*(gpon-onu-mng *"
  65. send "loop-detect ethuni eth_0/2 enable\r"
  66. expect "*(gpon-onu-mng *"
  67. send "loop-detect ethuni eth_0/3 enable\r"
  68. expect "*(gpon-onu-mng *"
  69. send "loop-detect ethuni eth_0/4 enable\r"
  70. }
  71. expect "*(gpon-onu-mng *"
  72. send "service HSI gemport 1 vlan $VLAN\r"
  73. expect "*(gpon-onu-mng *"
  74. send "vlan port eth_0/1 mode tag vlan $VLAN\r"
  75. expect "*(gpon-onu-mng *"
  76. send "vlan port eth_0/2 mode tag vlan $VLAN\r"
  77. expect "*(gpon-onu-mng *"
  78. send "vlan port eth_0/3 mode tag vlan $VLAN\r"
  79. expect "*(gpon-onu-mng *"
  80. send "vlan port eth_0/4 mode tag vlan $VLAN\r"
  81. expect "*(gpon-onu-mng *"
  82. send "end\r"
  83. expect "*#"
  84. send "exit\r"