mirror of
https://github.com/containers/podman.git
synced 2025-07-01 16:17:06 +08:00
pkg/machine/vmconfigs: simplify IsFirstBoot
This is faster and, to my best knowledge, is equivalent to the old code. Remove the error return (as we don't guarantee stable API here), and simplify callers. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@ -216,11 +216,6 @@ func StartGenericAppleVM(mc *vmconfigs.MachineConfig, cmdBinary string, bootload
|
||||
|
||||
cmd.Args = append(cmd.Args, endpointArgs...)
|
||||
|
||||
firstBoot, err := mc.IsFirstBoot()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
debugDevArgs, err := GetDebugDevicesCMDArgs()
|
||||
if err != nil {
|
||||
@ -230,7 +225,7 @@ func StartGenericAppleVM(mc *vmconfigs.MachineConfig, cmdBinary string, bootload
|
||||
cmd.Args = append(cmd.Args, "--gui") // add command line switch to pop the gui open
|
||||
}
|
||||
|
||||
if firstBoot {
|
||||
if mc.IsFirstBoot() {
|
||||
// If this is the first boot of the vm, we need to add the vsock
|
||||
// device to vfkit so we can inject the ignition file
|
||||
socketName := fmt.Sprintf("%s-%s", mc.Name, ignitionSocketName)
|
||||
|
@ -182,12 +182,7 @@ func (h HyperVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func(
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
|
||||
firstBoot, err := mc.IsFirstBoot()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if firstBoot {
|
||||
if mc.IsFirstBoot() {
|
||||
// Add ignition entries to windows registry
|
||||
// for first boot only
|
||||
if err := readAndSplitIgnition(mc, vm); err != nil {
|
||||
|
@ -578,11 +578,7 @@ func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, dirs *machineDe
|
||||
}
|
||||
}
|
||||
|
||||
isFirstBoot, err := mc.IsFirstBoot()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
if mp.VMType() == machineDefine.WSLVirt && mc.Ansible != nil && isFirstBoot {
|
||||
if mp.VMType() == machineDefine.WSLVirt && mc.Ansible != nil && mc.IsFirstBoot() {
|
||||
if err := machine.CommonSSHSilent(mc.Ansible.User, mc.SSH.IdentityPath, mc.Name, mc.SSH.Port, []string{"ansible-playbook", mc.Ansible.PlaybookPath}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
@ -303,12 +303,8 @@ func (mc *MachineConfig) LogFile() (*define.VMFile, error) {
|
||||
return rtDir.AppendToNewVMFile(mc.Name+".log", nil)
|
||||
}
|
||||
|
||||
func (mc *MachineConfig) IsFirstBoot() (bool, error) {
|
||||
never, err := time.Parse(time.RFC3339, "0001-01-01T00:00:00Z")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return mc.LastUp == never, nil
|
||||
func (mc *MachineConfig) IsFirstBoot() bool {
|
||||
return mc.LastUp.IsZero()
|
||||
}
|
||||
|
||||
func (mc *MachineConfig) ConnectionInfo(vmtype define.VMType) (*define.VMFile, *define.VMFile, error) {
|
||||
|
Reference in New Issue
Block a user