hypervisor.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package hypervisor
  2. import (
  3. "github.com/rancher/os/config"
  4. "github.com/rancher/os/pkg/log"
  5. "github.com/rancher/os/pkg/util"
  6. )
  7. func Tools(cfg *config.CloudConfig) (*config.CloudConfig, error) {
  8. enableHypervisorService(cfg, util.GetHypervisor())
  9. return config.LoadConfig(), nil
  10. }
  11. func enableHypervisorService(cfg *config.CloudConfig, hypervisorName string) {
  12. if hypervisorName == "" {
  13. return
  14. }
  15. // enable open-vm-tools and hyperv-vm-tools
  16. // these services(xenhvm-vm-tools, kvm-vm-tools, and bhyve-vm-tools) don't exist yet
  17. serviceName := ""
  18. switch hypervisorName {
  19. case "vmware":
  20. serviceName = "open-vm-tools"
  21. case "hyperv":
  22. serviceName = "hyperv-vm-tools"
  23. default:
  24. log.Infof("no hypervisor matched")
  25. }
  26. if serviceName != "" {
  27. if !cfg.Rancher.HypervisorService {
  28. log.Infof("Skipping %s as `rancher.hypervisor_service` is set to false", serviceName)
  29. return
  30. }
  31. // Check removed - there's an x509 cert failure on first boot of an installed system
  32. // check quickly to see if there is a yml file available
  33. // if service.ValidService(serviceName, cfg) {
  34. log.Infof("Setting rancher.services_include. %s=true", serviceName)
  35. if err := config.Set("rancher.services_include."+serviceName, "true"); err != nil {
  36. log.Error(err)
  37. }
  38. }
  39. }