EPON_1_CVLAN 1.6 KB

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