From 2d685795b6616e9f67a06761d2df48ae082254c9 Mon Sep 17 00:00:00 2001 From: Robert Breker Date: Tue, 22 Dec 2015 11:23:50 +0000 Subject: [PATCH] Update boot2docker download mechanism to the latest interface - This fixes "GetLatestBoot2DockerReleaseURL is undefined" - The download mechanism should cache in PreCreateCheck to align with other drivers Signed-off-by: Robert Breker --- xenserver.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) 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 }