EPON_1_QINQ 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 MAC [lindex $argv 9]
  12. set DESCRIPTION [lindex $argv 10]
  13. if {[string match "TELNET" $METHOD]} {
  14. spawn telnet $IP
  15. expect "Username:*"
  16. send "$LOGIN\r"
  17. } elseif {[string match "SSH" $METHOD]} {
  18. spawn ssh $LOGIN@$IP
  19. expect {
  20. "(yes/no" {
  21. send "yes\r"
  22. }
  23. }
  24. }
  25. expect "Password:*"
  26. send "$PASSWORD\r"
  27. expect "ZXAN#"
  28. send "configure terminal\r"
  29. expect "ZXAN(config)#"
  30. send "interface $PON_INT\r"
  31. expect "ZXAN(config-if)#"
  32. send "onu $ONU_NUM type 1GE mac $MAC\r"
  33. expect "ZXAN(config-if)#"
  34. send "exit\r"
  35. expect "ZXAN(config)#"
  36. send "interface $ONU_INT:$ONU_NUM\r"
  37. if {![string match "__empty" $DESCRIPTION]} {
  38. expect "ZXAN(config-if)#"
  39. send "property description $DESCRIPTION\r"
  40. }
  41. expect "ZXAN(config-if)#"
  42. send "switchport mode hybrid vport 1\r"
  43. expect "ZXAN(config-if)#"
  44. send "admin enable\r"
  45. expect "ZXAN(config-if)#"
  46. send "sla-profile 1G\r"
  47. expect "ZXAN(config-if)#"
  48. send "service-port 1 vport 1 user-vlan $VLAN svlan $SVLAN"
  49. expect "ZXAN(config-if)#"
  50. send "exit\r"
  51. expect "ZXAN(config)#"
  52. send "pon-onu-mng $ONU_INT:$ONU_NUM\r"
  53. expect "ZXAN(epon-onu-mng)#"
  54. sleep 2
  55. send "vlan port eth_0/1 mode tag vlan $VLAN priority 0\r"
  56. for {set i 1} { $i < 60} {incr i 1} {
  57. expect {
  58. "%Code*" {
  59. sleep 3
  60. send "vlan port eth_0/1 mode tag vlan $VLAN priority 0\r"
  61. exp_continue
  62. }
  63. "ZXAN(epon-onu-mng)#" {
  64. send "end\r"
  65. expect "*#"
  66. send "exit\r"
  67. exit
  68. }
  69. }
  70. }