mirror of
https://github.com/rancher/os.git
synced 2025-07-30 22:24:33 +00:00
test if the hyper-visor servce is available
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
7615c26f44
commit
33a60488cd
@ -208,9 +208,17 @@ func IsLocalOrURL(service string) bool {
|
||||
return isLocal(service) || strings.HasPrefix(service, "http:/") || strings.HasPrefix(service, "https:/")
|
||||
}
|
||||
|
||||
func validateService(service string, cfg *config.CloudConfig) {
|
||||
// Check to see if the service definition exists
|
||||
func ValidService(service string, cfg *config.CloudConfig) bool {
|
||||
services := availableService(cfg)
|
||||
if !IsLocalOrURL(service) && !util.Contains(services, service) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func validateService(service string, cfg *config.CloudConfig) {
|
||||
if !ValidService(service, cfg) {
|
||||
log.Fatalf("%s is not a valid service", service)
|
||||
}
|
||||
}
|
||||
|
25
init/init.go
25
init/init.go
@ -13,6 +13,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/rancher/os/cmd/control/service"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/dfs"
|
||||
"github.com/rancher/os/log"
|
||||
@ -304,9 +305,9 @@ func RunInit() error {
|
||||
if hypervisor == "vmware" {
|
||||
// add vmware to the end - we don't want to over-ride an choices the user has made
|
||||
cfg.Rancher.CloudInit.Datasources = append(cfg.Rancher.CloudInit.Datasources, hypervisor)
|
||||
}
|
||||
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
||||
log.Error(err)
|
||||
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("init, runCloudInitServices()")
|
||||
@ -412,14 +413,22 @@ func RunInit() error {
|
||||
|
||||
func checkHypervisor(cfg *config.CloudConfig) string {
|
||||
hvtools := cpuid.CPU.HypervisorName
|
||||
if hvtools != "" {
|
||||
log.Infof("Detected Hypervisor: %s", cpuid.CPU.HypervisorName)
|
||||
if hvtools == "" {
|
||||
log.Infof("ros init: No Detected Hypervisor")
|
||||
} else {
|
||||
log.Infof("ros init: Detected Hypervisor: %s", cpuid.CPU.HypervisorName)
|
||||
if hvtools == "vmware" {
|
||||
hvtools = "open"
|
||||
}
|
||||
log.Infof("Setting rancher.services_include." + hvtools + "-vm-tools=true")
|
||||
if err := config.Set("rancher.services_include."+hvtools+"-vm-tools", "true"); err != nil {
|
||||
log.Error(err)
|
||||
serviceName := hvtools + "-vm-tools"
|
||||
// check quickly to see if there is a yml file available
|
||||
if service.ValidService(serviceName, cfg) {
|
||||
log.Infof("Setting rancher.services_include. %s=true", serviceName)
|
||||
if err := config.Set("rancher.services_include."+serviceName, "true"); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
} else {
|
||||
log.Infof("Skipping %s, can't get %s.yml file", serviceName, serviceName)
|
||||
}
|
||||
}
|
||||
return cpuid.CPU.HypervisorName
|
||||
|
Loading…
Reference in New Issue
Block a user