1
0
mirror of https://github.com/rancher/os.git synced 2025-04-27 11:10:56 +00:00

Rename stage to save for install cli args

This commit is contained in:
niusmallnan 2019-08-16 13:46:12 +08:00 committed by niusmallnan
parent 4841467d41
commit a8cf965b2a
2 changed files with 20 additions and 20 deletions

View File

@ -86,8 +86,8 @@ var installCommand = cli.Command{
Usage: "reboot using kexec",
},
cli.BoolFlag{
Name: "stage, s",
Usage: "stage services",
Name: "save, s",
Usage: "save services and images for next booting",
},
cli.BoolFlag{
Name: "debug",
@ -179,13 +179,13 @@ func installAction(c *cli.Context) error {
cloudConfig = uc
}
stageImages := []string{}
if c.Bool("stage") && cloudConfig != "" && installType != "upgrade" {
stageImages = install.GetCacheImageList(cloudConfig, cfg)
log.Debugf("Will cache these images: %s", stageImages)
savedImages := []string{}
if c.Bool("save") && cloudConfig != "" && installType != "upgrade" {
savedImages = install.GetCacheImageList(cloudConfig, cfg)
log.Debugf("Will cache these images: %s", savedImages)
}
if err := runInstall(image, installType, cloudConfig, device, partition, statedir, kappend, force, kexec, isoinstallerloaded, debug, stageImages); err != nil {
if err := runInstall(image, installType, cloudConfig, device, partition, statedir, kappend, force, kexec, isoinstallerloaded, debug, savedImages); err != nil {
log.WithFields(log.Fields{"err": err}).Fatal("Failed to run install")
return err
}
@ -198,7 +198,7 @@ func installAction(c *cli.Context) error {
return nil
}
func runInstall(image, installType, cloudConfig, device, partition, statedir, kappend string, force, kexec, isoinstallerloaded, debug bool, stageImages []string) error {
func runInstall(image, installType, cloudConfig, device, partition, statedir, kappend string, force, kexec, isoinstallerloaded, debug bool, savedImages []string) error {
fmt.Printf("Installing from %s\n", image)
if !force {
@ -283,8 +283,8 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka
if statedir != "" {
installerCmd = append(installerCmd, "--statedir", statedir)
}
if len(stageImages) > 0 {
installerCmd = append(installerCmd, "--stage")
if len(savedImages) > 0 {
installerCmd = append(installerCmd, "--save")
}
// TODO: mount at /mnt for shared mount?
@ -348,8 +348,8 @@ func runInstall(image, installType, cloudConfig, device, partition, statedir, ka
return err
}
if len(stageImages) > 0 {
return install.RunCacheScript(partition, stageImages)
if len(savedImages) > 0 {
return install.RunCacheScript(partition, savedImages)
}
return nil

View File

@ -18,21 +18,21 @@ type ImageConfig struct {
}
func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string {
stageImages := make([]string, 0)
savedImages := make([]string, 0)
bytes, err := readConfigFile(cloudconfig)
if err != nil {
log.WithFields(log.Fields{"err": err}).Fatal("Failed to read cloud-config")
return stageImages
return savedImages
}
r := make(map[interface{}]interface{})
if err := yaml.Unmarshal(bytes, &r); err != nil {
log.WithFields(log.Fields{"err": err}).Fatal("Failed to unmarshal cloud-config")
return stageImages
return savedImages
}
newcfg := &config.CloudConfig{}
if err := util.Convert(r, newcfg); err != nil {
log.WithFields(log.Fields{"err": err}).Fatal("Failed to convert cloud-config")
return stageImages
return savedImages
}
// services_include
@ -40,7 +40,7 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string
if value {
serviceImage := getServiceImage(key, "", oldcfg, newcfg)
if serviceImage != "" {
stageImages = append(stageImages, serviceImage)
savedImages = append(savedImages, serviceImage)
}
}
}
@ -50,7 +50,7 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string
if newConsole != "" && newConsole != "default" {
consoleImage := getServiceImage(newConsole, "console", oldcfg, newcfg)
if consoleImage != "" {
stageImages = append(stageImages, consoleImage)
savedImages = append(savedImages, consoleImage)
}
}
@ -59,12 +59,12 @@ func GetCacheImageList(cloudconfig string, oldcfg *config.CloudConfig) []string
if newEngine != "" && newEngine != oldcfg.Rancher.Docker.Engine {
engineImage := getServiceImage(newEngine, "docker", oldcfg, newcfg)
if engineImage != "" {
stageImages = append(stageImages, engineImage)
savedImages = append(savedImages, engineImage)
}
}
return stageImages
return savedImages
}
func getServiceImage(service, svctype string, oldcfg, newcfg *config.CloudConfig) string {