GPON_4_R 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 4ETH 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 "gemport 1 traffic-limit downstream unlim \r"
  48. expect "*(config-if)#"
  49. send "switchport mode trunk vport 1\r"
  50. expect "*(config-if)#"
  51. send "switchport vlan $VLAN tag vport 1\r"
  52. if {![string match "__empty" $DHCPSNOOPING]} {
  53. expect "*(config-if)#"
  54. send "ip dhcp snooping enable vport 1\r"
  55. }
  56. expect "*(config-if)#"
  57. send "exit\r"
  58. expect "*(config)#"
  59. send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
  60. if {![string match "__empty" $LOOPDETECT]} {
  61. expect "*(gpon-onu-mng)#"
  62. send "loop-detect ethuni eth_0/1 enable\r"
  63. expect "*(gpon-onu-mng)#"
  64. send "loop-detect ethuni eth_0/2 enable\r"
  65. expect "*(gpon-onu-mng)#"
  66. send "loop-detect ethuni eth_0/3 enable\r"
  67. expect "*(gpon-onu-mng)#"
  68. send "loop-detect ethuni eth_0/4 enable\r"
  69. }
  70. expect "*(gpon-onu-mng)#"
  71. send "flow mode 1 tag-filter vid-filter untag-filter discard\r"
  72. expect "*(gpon-onu-mng)#"
  73. send "flow 1 priority 0 vid $VLAN\r"
  74. expect "*(gpon-onu-mng)#"
  75. send "gemport 1 flow 1\r"
  76. expect "*(gpon-onu-mng)#"
  77. send "switchport-bind switch_0/1 iphost 1\r"
  78. expect "*(gpon-onu-mng)#"
  79. send "ip-host 1 dhcp-enable true ping-response true traceroute-response true\r"
  80. expect "*(gpon-onu-mng)#"
  81. send "vlan-filter-mode iphost 1 tag-filter vid-filter untag-filter discard\r"
  82. expect "*(gpon-onu-mng)#"
  83. send "vlan-filter iphost 1 priority 0 vid $VLAN\r"
  84. expect "*(gpon-onu-mng)#"
  85. send "dhcp-ip ethuni eth_0/1 from-onu\r"
  86. expect "*(gpon-onu-mng)#"
  87. send "dhcp-ip ethuni eth_0/2 from-onu\r"
  88. expect "*(gpon-onu-mng)#"
  89. send "dhcp-ip ethuni eth_0/3 from-onu\r"
  90. expect "*(gpon-onu-mng)#"
  91. send "dhcp-ip ethuni eth_0/4 from-onu\r"
  92. expect "*(gpon-onu-mng)#"
  93. send "end\r"
  94. expect "*#"
  95. send "exit\r"