Remove remote cache correctly.

pull/6206/head
Matthew Hooker 8 years ago
parent 451e3d0554
commit 97cfd60b82
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1

@ -138,6 +138,12 @@ func (d *ESX5Driver) UploadISO(localPath string, checksum string, checksumType s
return finalPath, nil
}
func (d *ESX5Driver) RemoveCache(localPath string) error {
finalPath := filepath.ToSlash(filepath.Dir(d.cachePath(localPath)))
log.Printf("Removing remote cache path %s (local %s)", finalPath, localPath)
return d.sh("rm", "-rf", finalPath)
}
func (d *ESX5Driver) ToolsIsoPath(string) string {
return ""
}
@ -569,10 +575,6 @@ func (d *ESX5Driver) mkdir(path string) error {
return d.sh("mkdir", "-p", path)
}
func (d *ESX5Driver) remove(path string) error {
return d.sh("rm", "-rf", path)
}
func (d *ESX5Driver) upload(dst, src string) error {
f, err := os.Open(src)
if err != nil {

@ -12,6 +12,9 @@ type RemoteDriver interface {
// exists.
UploadISO(string, string, string) (string, error)
// RemoveCache deletes localPath from the remote cache.
RemoveCache(localPath string) error
// Adds a VM to inventory specified by the path to the VMX given.
Register(string) error
@ -27,9 +30,6 @@ type RemoteDriver interface {
// Uploads a local file to remote side.
upload(dst, src string) error
// Forcefully remove a path from the remote side.
remove(path string) error
// Reload VM on remote side.
ReloadVM() error
}

@ -61,11 +61,11 @@ func (d *RemoteDriverMock) IsDestroyed() (bool, error) {
}
func (d *RemoteDriverMock) upload(dst, src string) error {
return nil
return d.uploadErr
}
func (d *RemoteDriverMock) remove(path string) error {
return d.uploadErr
func (d *RemoteDriverMock) RemoveCache(localPath string) error {
return nil
}
func (d *RemoteDriverMock) ReloadVM() error {

@ -56,7 +56,6 @@ func (s *stepRemoteUpload) Cleanup(state multistep.StateBag) {
}
driver := state.Get("driver").(vmwcommon.Driver)
// ui := state.Get("ui").(packer.Ui)
remote, ok := driver.(RemoteDriver)
if !ok {
@ -69,9 +68,8 @@ func (s *stepRemoteUpload) Cleanup(state multistep.StateBag) {
}
log.Printf("Cleaning up remote path: %s", path)
err := remote.remove(path)
err := remote.RemoveCache(path)
if err != nil {
log.Printf("Error cleaning up: %s", err)
}
}

Loading…
Cancel
Save