diff --git a/xenserver.go b/xenserver.go index d75d841..7299d61 100644 --- a/xenserver.go +++ b/xenserver.go @@ -288,6 +288,13 @@ func (d *Driver) GetState() (state.State, error) { } func (d *Driver) PreCreateCheck() error { + // Downloading boot2docker to cache should be done here to make sure + // that a download failure will not leave a machine half created. + b2dutils := mcnutils.NewB2dUtils(d.StorePath) + if err := b2dutils.UpdateISOCache(d.Boot2DockerURL); err != nil { + return err + } + return nil } @@ -296,21 +303,8 @@ func (d *Driver) Create() error { d.setMachineNameIfNotSet() - // Download boot2docker ISO from Internet - var isoURL string b2dutils := mcnutils.NewB2dUtils(d.StorePath) - - if d.Boot2DockerURL != "" { - isoURL = d.Boot2DockerURL - } else { - isoURL, err = b2dutils.GetLatestBoot2DockerReleaseURL("") - if err != nil { - log.Errorf("Unable to check for the latest release: %s", err) - return err - } - } - log.Infof("Downloading %s from %s...", isoFilename, isoURL) - if err := b2dutils.DownloadISO(d.StorePath, isoFilename, isoURL); err != nil { + if err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil { return err }