diff --git a/drivers/hyperv/hyperv_windows.go b/drivers/hyperv/hyperv_windows.go index 06a2efd757..97ca4286d4 100644 --- a/drivers/hyperv/hyperv_windows.go +++ b/drivers/hyperv/hyperv_windows.go @@ -137,17 +137,19 @@ func (d *Driver) Create() error { if d.boot2DockerLoc == "" { if d.boot2DockerURL != "" { isoURL = d.boot2DockerURL + log.Infof("Downloading boot2docker.iso from %s...", isoURL) + if err := utils.DownloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil { + return err + } } else { - isoURL, err = utils.GetLatestBoot2DockerReleaseURL() + commonIsoPath, err := utils.DownloadUpdateB2D() if err != nil { return err } - } - log.Infof("Downloading boot2docker...") - // todo: use common iso location - - if err := utils.DownloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil { - return err + isoDest := filepath.Join(d.storePath, "boot2docker.iso") + if err := utils.CopyFile(commonIsoPath, isoDest); err != nil { + return err + } } } else { if err := utils.CopyFile(d.boot2DockerLoc, filepath.Join(d.storePath, "boot2docker.iso")); err != nil { diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index b41bd95fdc..dff98b6dc0 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -101,17 +101,6 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { return nil } -func cpIso(src, dest string) error { - buf, err := ioutil.ReadFile(src) - if err != nil { - return err - } - if err := ioutil.WriteFile(dest, buf, 0600); err != nil { - return err - } - return nil -} - func (d *Driver) PreCreateCheck() error { return nil } @@ -139,38 +128,43 @@ func (d *Driver) Create() error { log.Infof("Downloading boot2docker.iso from %s...", isoURL) if err := b2dutils.DownloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil { return err + } + } else { // todo: check latest release URL, download if it's new // until then always use "latest" isoURL, err = b2dutils.GetLatestBoot2DockerReleaseURL() if err != nil { log.Warnf("Unable to check for the latest release: %s", err) - } + } // todo: use real constant for .docker rootPath := filepath.Join(utils.GetDockerDir()) imgPath := filepath.Join(rootPath, "images") commonIsoPath := filepath.Join(imgPath, "boot2docker.iso") if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) - // just in case boot2docker.iso has been manually deleted if _, err := os.Stat(imgPath); os.IsNotExist(err) { if err := os.Mkdir(imgPath, 0700); err != nil { return err - } - } + } + + } if err := b2dutils.DownloadISO(imgPath, "boot2docker.iso", isoURL); err != nil { return err + } + + } + isoDest := filepath.Join(d.storePath, "boot2docker.iso") + if err := utils.CopyFile(commonIsoPath, isoDest); err != nil { + return err + } - isoDest := filepath.Join(d.storePath, "boot2docker.iso") - if err := cpIso(commonIsoPath, isoDest); err != nil { - return err - } } log.Infof("Creating SSH key...") diff --git a/drivers/vmwarefusion/fusion.go b/drivers/vmwarefusion/fusion.go index fb8c1f72fd..1c486d79fb 100644 --- a/drivers/vmwarefusion/fusion.go +++ b/drivers/vmwarefusion/fusion.go @@ -141,43 +141,49 @@ func (d *Driver) Create() error { ) b2dutils := utils.NewB2dUtils("", "") + if d.Boot2DockerURL != "" { isoURL = d.Boot2DockerURL log.Infof("Downloading boot2docker.iso from %s...", isoURL) if err := b2dutils.DownloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil { return err + } + } else { // todo: check latest release URL, download if it's new // until then always use "latest" isoURL, err = b2dutils.GetLatestBoot2DockerReleaseURL() if err != nil { log.Warnf("Unable to check for the latest release: %s", err) - } + } // todo: use real constant for .docker rootPath := filepath.Join(utils.GetDockerDir()) imgPath := filepath.Join(rootPath, "images") commonIsoPath := filepath.Join(imgPath, "boot2docker.iso") if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) - // just in case boot2docker.iso has been manually deleted if _, err := os.Stat(imgPath); os.IsNotExist(err) { if err := os.Mkdir(imgPath, 0700); err != nil { return err - } - } + } + + } if err := b2dutils.DownloadISO(imgPath, "boot2docker.iso", isoURL); err != nil { return err - } - } + } + + } isoDest := filepath.Join(d.storePath, "boot2docker.iso") if err := utils.CopyFile(commonIsoPath, isoDest); err != nil { return err + } + } log.Infof("Creating SSH key...") diff --git a/drivers/vmwarevsphere/vsphere.go b/drivers/vmwarevsphere/vsphere.go index 85636ed052..484344a1ff 100644 --- a/drivers/vmwarevsphere/vsphere.go +++ b/drivers/vmwarevsphere/vsphere.go @@ -235,42 +235,49 @@ func (d *Driver) Create() error { ) b2dutils := utils.NewB2dUtils("", "") + if d.Boot2DockerURL != "" { isoURL = d.Boot2DockerURL log.Infof("Downloading boot2docker.iso from %s...", isoURL) if err := b2dutils.DownloadISO(d.storePath, "boot2docker.iso", isoURL); err != nil { return err + } + } else { // todo: check latest release URL, download if it's new // until then always use "latest" isoURL, err = b2dutils.GetLatestBoot2DockerReleaseURL() if err != nil { log.Warnf("Unable to check for the latest release: %s", err) - } - rootPath := utils.GetDockerDir() + } + // todo: use real constant for .docker + rootPath := filepath.Join(utils.GetDockerDir()) imgPath := filepath.Join(rootPath, "images") commonIsoPath := filepath.Join(imgPath, "boot2docker.iso") if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) - // just in case boot2docker.iso has been manually deleted if _, err := os.Stat(imgPath); os.IsNotExist(err) { if err := os.Mkdir(imgPath, 0700); err != nil { return err - } - } + } + + } if err := b2dutils.DownloadISO(imgPath, "boot2docker.iso", isoURL); err != nil { return err - } - } + } + + } isoDest := filepath.Join(d.storePath, "boot2docker.iso") if err := utils.CopyFile(commonIsoPath, isoDest); err != nil { return err + } + } log.Infof("Generating SSH Keypair...")