commit
cdd99564fd
|
@ -11,6 +11,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -47,12 +48,11 @@ func (d *ESX5Driver) Clone(dst, src string, linked bool) error {
|
||||||
|
|
||||||
func (d *ESX5Driver) CompactDisk(diskPathLocal string) error {
|
func (d *ESX5Driver) CompactDisk(diskPathLocal string) error {
|
||||||
diskPath := d.datastorePath(diskPathLocal)
|
diskPath := d.datastorePath(diskPathLocal)
|
||||||
return d.sh("vmkfstools", "--punchzero", diskPath)
|
return d.sh("vmkfstools", "--punchzero", strconv.Quote(diskPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) CreateDisk(diskPathLocal string, size string, adapter_type string, typeId string) error {
|
func (d *ESX5Driver) CreateDisk(diskPathLocal string, size string, adapter_type string, typeId string) error {
|
||||||
diskPath := d.datastorePath(diskPathLocal)
|
diskPath := strconv.Quote(d.datastorePath(diskPathLocal))
|
||||||
diskPath = strings.Replace(diskPath, " ", `\ `, -1)
|
|
||||||
return d.sh("vmkfstools", "-c", size, "-d", typeId, "-a", adapter_type, diskPath)
|
return d.sh("vmkfstools", "-c", size, "-d", typeId, "-a", adapter_type, diskPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ func (d *ESX5Driver) Register(vmxPathLocal string) error {
|
||||||
if err := d.upload(vmxPath, vmxPathLocal); err != nil {
|
if err := d.upload(vmxPath, vmxPathLocal); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r, err := d.run(nil, "vim-cmd", "solo/registervm", vmxPath)
|
r, err := d.run(nil, "vim-cmd", "solo/registervm", strconv.Quote(vmxPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ func (d *ESX5Driver) Destroy() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) IsDestroyed() (bool, error) {
|
func (d *ESX5Driver) IsDestroyed() (bool, error) {
|
||||||
err := d.sh("test", "!", "-e", d.outputDir)
|
err := d.sh("test", "!", "-e", strconv.Quote(d.outputDir))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ func (d *ESX5Driver) UploadISO(localPath string, checksum string, checksumType s
|
||||||
func (d *ESX5Driver) RemoveCache(localPath string) error {
|
func (d *ESX5Driver) RemoveCache(localPath string) error {
|
||||||
finalPath := d.cachePath(localPath)
|
finalPath := d.cachePath(localPath)
|
||||||
log.Printf("Removing remote cache path %s (local %s)", finalPath, localPath)
|
log.Printf("Removing remote cache path %s (local %s)", finalPath, localPath)
|
||||||
return d.sh("rm", "-f", finalPath)
|
return d.sh("rm", "-f", strconv.Quote(finalPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) ToolsIsoPath(string) string {
|
func (d *ESX5Driver) ToolsIsoPath(string) string {
|
||||||
|
@ -451,7 +451,7 @@ func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error) {
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
func (d *ESX5Driver) DirExists() (bool, error) {
|
func (d *ESX5Driver) DirExists() (bool, error) {
|
||||||
err := d.sh("test", "-e", d.outputDir)
|
err := d.sh("test", "-e", strconv.Quote(d.outputDir))
|
||||||
return err == nil, nil
|
return err == nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,11 +483,11 @@ func (d *ESX5Driver) MkdirAll() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) Remove(path string) error {
|
func (d *ESX5Driver) Remove(path string) error {
|
||||||
return d.sh("rm", path)
|
return d.sh("rm", strconv.Quote(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) RemoveAll() error {
|
func (d *ESX5Driver) RemoveAll() error {
|
||||||
return d.sh("rm", "-rf", d.outputDir)
|
return d.sh("rm", "-rf", strconv.Quote(d.outputDir))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) SetOutputDir(path string) {
|
func (d *ESX5Driver) SetOutputDir(path string) {
|
||||||
|
@ -580,7 +580,7 @@ func (d *ESX5Driver) checkGuestIPHackEnabled() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) mkdir(path string) error {
|
func (d *ESX5Driver) mkdir(path string) error {
|
||||||
return d.sh("mkdir", "-p", path)
|
return d.sh("mkdir", "-p", strconv.Quote(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *ESX5Driver) upload(dst, src string) error {
|
func (d *ESX5Driver) upload(dst, src string) error {
|
||||||
|
@ -594,7 +594,7 @@ func (d *ESX5Driver) upload(dst, src string) error {
|
||||||
|
|
||||||
func (d *ESX5Driver) verifyChecksum(ctype string, hash string, file string) bool {
|
func (d *ESX5Driver) verifyChecksum(ctype string, hash string, file string) bool {
|
||||||
if ctype == "none" {
|
if ctype == "none" {
|
||||||
if err := d.sh("stat", file); err != nil {
|
if err := d.sh("stat", strconv.Quote(file)); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -569,6 +569,9 @@ func (c *comm) scpUploadSession(path string, input io.Reader, fi *os.FileInfo) e
|
||||||
// which works for unix and windows
|
// which works for unix and windows
|
||||||
target_dir = filepath.ToSlash(target_dir)
|
target_dir = filepath.ToSlash(target_dir)
|
||||||
|
|
||||||
|
// Escape spaces in remote directory
|
||||||
|
target_dir = strings.Replace(target_dir, " ", "\\ ", -1)
|
||||||
|
|
||||||
scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error {
|
scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error {
|
||||||
return scpUploadFile(target_file, input, w, stdoutR, fi)
|
return scpUploadFile(target_file, input, w, stdoutR, fi)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue