restart_hostd.exp 1011 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/local/bin/expect
  2. if { ! [info exists env(ESXI_ROOT_PW)] } {
  3. puts "ERROR: Please set the ESXI_ROOT_PW environment variable first!"
  4. exit 1
  5. }
  6. set pw $env(ESXI_ROOT_PW)
  7. set hosts [list \
  8. "dc1-hv-1.ciscolive.network" \
  9. "dc1-hv-2.ciscolive.network" \
  10. "dc1-hv-3.ciscolive.network" \
  11. "dc1-hv-4.ciscolive.network" \
  12. "dc1-hv-5.ciscolive.network" \
  13. "dc1-hv-6.ciscolive.network" \
  14. "dc1-hv-7.ciscolive.network" \
  15. "dc1-hv-8.ciscolive.network" \
  16. "dc2-hv-1.ciscolive.network" \
  17. "dc2-hv-2.ciscolive.network" \
  18. "dc2-hv-3.ciscolive.network" \
  19. "dc2-hv-4.ciscolive.network" \
  20. "dc2-hv-5.ciscolive.network" \
  21. "dc2-hv-6.ciscolive.network" \
  22. "dc2-hv-7.ciscolive.network" \
  23. "dc2-hv-8.ciscolive.network"]
  24. foreach host $hosts {
  25. eval spawn ssh -o StrictHostKeyChecking=no root@$host
  26. interact -o -nobuffer -re "assword:" return
  27. send "$pw\r"
  28. interact -o -nobuffer -re "\]" return
  29. send "/etc/init.d/hostd restart\r"
  30. expect -re "\]"
  31. send "exit\r"
  32. }