mirror of
https://github.com/rancher/os.git
synced 2025-08-09 02:28:18 +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:/")
|
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)
|
services := availableService(cfg)
|
||||||
if !IsLocalOrURL(service) && !util.Contains(services, service) {
|
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)
|
log.Fatalf("%s is not a valid service", service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
init/init.go
19
init/init.go
@ -13,6 +13,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/mount"
|
"github.com/docker/docker/pkg/mount"
|
||||||
|
"github.com/rancher/os/cmd/control/service"
|
||||||
"github.com/rancher/os/config"
|
"github.com/rancher/os/config"
|
||||||
"github.com/rancher/os/dfs"
|
"github.com/rancher/os/dfs"
|
||||||
"github.com/rancher/os/log"
|
"github.com/rancher/os/log"
|
||||||
@ -304,10 +305,10 @@ func RunInit() error {
|
|||||||
if hypervisor == "vmware" {
|
if hypervisor == "vmware" {
|
||||||
// add vmware to the end - we don't want to over-ride an choices the user has made
|
// 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)
|
cfg.Rancher.CloudInit.Datasources = append(cfg.Rancher.CloudInit.Datasources, hypervisor)
|
||||||
}
|
|
||||||
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
if err := config.Set("rancher.cloud_init.datasources", cfg.Rancher.CloudInit.Datasources); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Debug("init, runCloudInitServices()")
|
log.Debug("init, runCloudInitServices()")
|
||||||
if err := runCloudInitServices(cfg); err != nil {
|
if err := runCloudInitServices(cfg); err != nil {
|
||||||
@ -412,15 +413,23 @@ func RunInit() error {
|
|||||||
|
|
||||||
func checkHypervisor(cfg *config.CloudConfig) string {
|
func checkHypervisor(cfg *config.CloudConfig) string {
|
||||||
hvtools := cpuid.CPU.HypervisorName
|
hvtools := cpuid.CPU.HypervisorName
|
||||||
if hvtools != "" {
|
if hvtools == "" {
|
||||||
log.Infof("Detected Hypervisor: %s", cpuid.CPU.HypervisorName)
|
log.Infof("ros init: No Detected Hypervisor")
|
||||||
|
} else {
|
||||||
|
log.Infof("ros init: Detected Hypervisor: %s", cpuid.CPU.HypervisorName)
|
||||||
if hvtools == "vmware" {
|
if hvtools == "vmware" {
|
||||||
hvtools = "open"
|
hvtools = "open"
|
||||||
}
|
}
|
||||||
log.Infof("Setting rancher.services_include." + hvtools + "-vm-tools=true")
|
serviceName := hvtools + "-vm-tools"
|
||||||
if err := config.Set("rancher.services_include."+hvtools+"-vm-tools", "true"); err != nil {
|
// 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)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Infof("Skipping %s, can't get %s.yml file", serviceName, serviceName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cpuid.CPU.HypervisorName
|
return cpuid.CPU.HypervisorName
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user