GPON_1 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 PORT [lindex $argv 5]
  8. set ONU_NUM [lindex $argv 6]
  9. set VLAN [lindex $argv 7]
  10. set SN [lindex $argv 8]
  11. set NATIVE_VLAN [lindex $argv 9]
  12. set SERVICE_PORT [lindex $argv 10]
  13. if {[string match "TELNET" $METHOD]} {
  14. spawn telnet $IP
  15. expect ">>User name:*"
  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 ">>User password:*"
  26. send "$PASSWORD\r"
  27. expect {
  28. "*>" {
  29. send "enable\r"
  30. }
  31. "#" {
  32. send "\r"
  33. }
  34. }
  35. expect "*#"
  36. send "config\r"
  37. expect "*(config)#"
  38. send "interface gpon $PON_INT\r"
  39. expect "*(config-if-gpon-$PON_INT)#"
  40. send "ont add $PORT $ONU_NUM sn-auth $SN omci ont-lineprofile-id 100 ont-srvprofile-id 100 desc ONT_NO_DESCRIPTION\r"
  41. expect "*(config-if-gpon-$PON_INT)#"
  42. send "ont port native-vlan $PORT $ONU_NUM eth 1 vlan $NATIVE_VLAN priority 0\r"
  43. expect "*(config-if-gpon-$PON_INT)#"
  44. send "quit\r"
  45. expect "*(config)#"
  46. send "service-port $SERVICE_PORT vlan $VLAN gpon $PON_INT/$PORT ont $ONU_NUM gemport 1 multi-service user-vlan $NATIVE_VLAN tag-transform translate\r"
  47. expect "{ <cr>|bundle<K>|inbound<K>|rx-cttr<K> }:"
  48. send "\r"
  49. expect "*(config)#"
  50. send "quit\r"
  51. expect "*#"
  52. send "quit\r"
  53. expect "(y/n)*"
  54. send "y\r"