diff --git a/cmd/control/service/service.go b/cmd/control/service/service.go index 7a37dafb..3915dd8b 100644 --- a/cmd/control/service/service.go +++ b/cmd/control/service/service.go @@ -208,7 +208,7 @@ func IsLocalOrURL(service string) bool { return isLocal(service) || strings.HasPrefix(service, "http:/") || strings.HasPrefix(service, "https:/") } -// Check to see if the service definition exists +// ValidService checks 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) { diff --git a/init/init.go b/init/init.go index 37ecf3ed..6f752bdb 100755 --- a/init/init.go +++ b/init/init.go @@ -224,19 +224,20 @@ func RunInit() error { boot2DockerEnvironment := false var shouldSwitchRoot bool + hypervisor := "" configFiles := make(map[string][]byte) initFuncs := []config.CfgFuncData{ - config.CfgFuncData{"preparefs", func(c *config.CloudConfig) (*config.CloudConfig, error) { - return c, dfs.PrepareFs(&mountConfig) + config.CfgFuncData{"preparefs", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { + return cfg, dfs.PrepareFs(&mountConfig) }}, - config.CfgFuncData{"save init cmdline", func(c *config.CloudConfig) (*config.CloudConfig, error) { + config.CfgFuncData{"save init cmdline", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { // will this be passed to cloud-init-save? cmdLineArgs := strings.Join(os.Args, " ") config.SaveInitCmdline(cmdLineArgs) - return c, nil + return cfg, nil }}, config.CfgFuncData{"mount OEM", mountOem}, config.CfgFuncData{"debug save cfg", func(_ *config.CloudConfig) (*config.CloudConfig, error) { @@ -294,6 +295,7 @@ func RunInit() error { config.CfgFuncData{"mount and bootstrap", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { var err error cfg, shouldSwitchRoot, err = tryMountAndBootstrap(cfg) + if err != nil { return nil, err } @@ -301,7 +303,7 @@ func RunInit() error { }}, config.CfgFuncData{"cloud-init", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { cfg.Rancher.CloudInit.Datasources = config.LoadConfigWithPrefix(state).Rancher.CloudInit.Datasources - hypervisor := checkHypervisor(cfg) + hypervisor = checkHypervisor(cfg) 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) @@ -368,8 +370,12 @@ func RunInit() error { return cfg, nil }}, + config.CfgFuncData{"hypervisor tools", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { + // Maybe we could set `rancher.hypervisor_service`, and defer this further? + enableHypervisorService(hypervisor) + return config.LoadConfig(), nil + }}, config.CfgFuncData{"b2d Env", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { - if boot2DockerEnvironment { if err := config.Set("rancher.state.dev", cfg.Rancher.State.Dev); err != nil { log.Errorf("Failed to update rancher.state.dev: %v", err) @@ -381,13 +387,13 @@ func RunInit() error { return config.LoadConfig(), nil }}, - config.CfgFuncData{"preparefs2", func(c *config.CloudConfig) (*config.CloudConfig, error) { - return c, dfs.PrepareFs(&mountConfig) + config.CfgFuncData{"preparefs2", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { + return cfg, dfs.PrepareFs(&mountConfig) }}, config.CfgFuncData{"load modules2", loadModules}, - config.CfgFuncData{"set proxy env", func(c *config.CloudConfig) (*config.CloudConfig, error) { - network.SetProxyEnvironmentVariables(c) - return c, nil + config.CfgFuncData{"set proxy env", func(cfg *config.CloudConfig) (*config.CloudConfig, error) { + network.SetProxyEnvironmentVariables(cfg) + return cfg, nil }}, config.CfgFuncData{"init SELinux", initializeSelinux}, config.CfgFuncData{"setupSharedRoot", setupSharedRoot}, @@ -412,24 +418,33 @@ func RunInit() error { } func checkHypervisor(cfg *config.CloudConfig) string { - hvtools := cpuid.CPU.HypervisorName - if hvtools == "" { + if cpuid.CPU.HypervisorName == "" { log.Infof("ros init: No Detected Hypervisor") } else { log.Infof("ros init: Detected Hypervisor: %s", cpuid.CPU.HypervisorName) - if hvtools == "vmware" { - hvtools = "open" - } - 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 } + +func enableHypervisorService(hypervisorName string) { + if hypervisorName == "" { + return + } + + if hypervisorName == "vmware" { + hypervisorName = "open" + } + serviceName := hypervisorName + "-vm-tools" + // check quickly to see if there is a yml file available + cfg := config.LoadConfig() + if service.ValidService(serviceName, cfg) { + log.Infof("Setting rancher.services_include. %s=true", serviceName) + log.Debugf("SVEN Setting rancher.services_include. %s=true", serviceName) + if err := config.Set("rancher.services_include."+serviceName, "true"); err != nil { + log.Error(err) + } + } else { + log.Infof("SVEN Skipping %s, can't get %s.yml file", serviceName, serviceName) + log.Debugf("SVEN Skipping %s, can't get %s.yml file", serviceName, serviceName) + } +} diff --git a/scripts/global.cfg b/scripts/global.cfg index b9db5a29..e5592660 100755 --- a/scripts/global.cfg +++ b/scripts/global.cfg @@ -1 +1 @@ -APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 rancher.autologin=ttyS1 rancher.console=ttyS1 console=ttyS0 printk.devkmsg=on ${APPEND} +APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 console=tty0 rancher.autologin=ttyS1 printk.devkmsg=on ${APPEND} diff --git a/scripts/run b/scripts/run index 94b522c8..7aef592a 100755 --- a/scripts/run +++ b/scripts/run @@ -277,7 +277,7 @@ if [ "$GUICONSOLE" == "" ]; then if [ "$NETCONSOLE" == "1" ]; then # put ttyS1 on port 4444 DISPLAY_OPTS="${DISPLAY_OPTS} -serial tcp::4444,server" - KERNEL_ARGS="rancher.console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}" + KERNEL_ARGS="console=ttyS1 rancher.autologin=ttyS1 ${KERNEL_ARGS}" fi fi diff --git a/tests/installer_test.go b/tests/installer_test.go index cd76edd7..71172ac3 100755 --- a/tests/installer_test.go +++ b/tests/installer_test.go @@ -201,7 +201,7 @@ sudo ros service start network sleep 1 ip a echo "===================" -sudo ros install --force --no-reboot --device /dev/vda -c config.yml -a "console=ttyS0 rancher.console=ttyS0 rancher.autologin=ttyS0 rancher.console=ttyS1 rancher.autologin=ttyS1 rancher.debug=true" +sudo ros install --force --no-reboot --device /dev/vda -c config.yml -a "console=ttyS0 rancher.autologin=ttyS0 console=ttyS1 rancher.autologin=ttyS1 rancher.debug=true" sync `) time.Sleep(500 * time.Millisecond) diff --git a/util/network/network.go b/util/network/network.go index 6223c339..327b14c1 100644 --- a/util/network/network.go +++ b/util/network/network.go @@ -7,7 +7,6 @@ import ( "net/http" "os" "strings" - "time" yaml "github.com/cloudfoundry-incubator/candiedyaml" @@ -89,29 +88,33 @@ func loadFromNetwork(location string) ([]byte, error) { SetProxyEnvironmentVariables(cfg) var err error - for i := 0; i < 300; i++ { - updateDNSCache() + // Sven thinks that the dhcpcd --wait we added makes this less necessary + //for i := 0; i < 300; i++ { + updateDNSCache() - var resp *http.Response - resp, err = http.Get(location) - if err == nil { - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("non-200 http response: %d", resp.StatusCode) - } - - bytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - cacheAdd(location, bytes) - return bytes, nil + var resp *http.Response + log.Infof("LoadFromNetwork(%s)", location) + resp, err = http.Get(location) + log.Debugf("LoadFromNetwork(%s) returned %v", resp) + log.Debugf("LoadFromNetwork(%s) error %v", err) + if err == nil { + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("non-200 http response: %d", resp.StatusCode) } - time.Sleep(100 * time.Millisecond) + bytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + cacheAdd(location, bytes) + return bytes, nil } + // time.Sleep(100 * time.Millisecond) + //} + return nil, err }