Commit aa06c2b6 authored by Max Wittig's avatar Max Wittig

refactor(parallels): move timesync code to separate method

parent 6a94baf7
......@@ -153,6 +153,24 @@ func (s *executor) createVM() error {
return nil
}
func (s *executor) updateGuestTime() error {
s.Debugln("Updating VM date...")
timeServer := s.Config.Parallels.TimeServer
if timeServer == "" {
timeServer = "time.apple.com"
}
err := prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", timeServer)
if err != nil {
s.Debugln("Could not run ntpdate command. Trying the sntp command instead...")
err = prl.TryExec(s.vmName, 20, "sudo", "sntp", "-S", timeServer)
if err != nil {
return err
}
}
return nil
}
func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
err := s.AbstractExecutor.Prepare(options)
if err != nil {
......@@ -264,19 +282,10 @@ func (s *executor) Prepare(options common.ExecutorPrepareOptions) error {
// TODO: integration tests do fail on this due
// Unable to open new session in this virtual machine.
// Make sure the latest version of Parallels Tools is installed in this virtual machine and it has finished booting
s.Debugln("Updating VM date...")
timeServer := s.Config.Parallels.TimeServer
if timeServer == "" {
timeServer = "time.apple.com"
}
err = prl.TryExec(s.vmName, 20, "sudo", "ntpdate", "-u", timeServer)
err = s.updateGuestTime()
if err != nil {
s.Debugln("Could not run ntpdate command. Trying the sntp command instead...")
err = prl.TryExec(s.vmName, 20, "sudo", "sntp", "-S", timeServer)
if err != nil {
s.Println("Could not sync with timeserver!")
return err
}
s.Println("Could not sync with timeserver!")
return err
}
ipAddr, err := s.waitForIPAddress(s.vmName, 60)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment