File upload to DRS-enabled clusters (fix #202)
This commit is contained in:
parent
fd2d78c73b
commit
3c005a9291
|
@ -5,3 +5,4 @@ bin/
|
|||
.env
|
||||
test*.json
|
||||
crash.log
|
||||
packer_cache/
|
||||
|
|
|
@ -83,11 +83,16 @@ func (ds *Datastore) ResolvePath(path string) string {
|
|||
|
||||
func (ds *Datastore) UploadFile(src, dst string, host string) error {
|
||||
p := soap.DefaultUpload
|
||||
ctx := ds.driver.ctx
|
||||
|
||||
if host != "" {
|
||||
h, err := ds.driver.FindHost(host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx := ds.ds.HostContext(ds.driver.ctx, h.host)
|
||||
ctx = ds.ds.HostContext(ctx, h.host)
|
||||
}
|
||||
|
||||
return ds.ds.UploadFile(ctx, src, dst, &p)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package driver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDatastoreAcc(t *testing.T) {
|
||||
|
@ -18,3 +21,73 @@ func TestDatastoreAcc(t *testing.T) {
|
|||
t.Errorf("Wrong datastore. expected: 'datastore1', got: '%v'", info.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileUpload(t *testing.T) {
|
||||
dsName := "datastore1"
|
||||
hostName := "esxi-1.vsphere65.test"
|
||||
|
||||
fileName := fmt.Sprintf("test-%v", time.Now().Unix())
|
||||
tmpFile, err := ioutil.TempFile("", fileName)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temp file")
|
||||
}
|
||||
err = tmpFile.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temp file")
|
||||
}
|
||||
|
||||
d := newTestDriver(t)
|
||||
ds, err := d.FindDatastore(dsName, hostName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot find datastore '%v': %v", dsName, err)
|
||||
}
|
||||
|
||||
err = ds.UploadFile(tmpFile.Name(), fileName, hostName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot upload file: %v", err)
|
||||
}
|
||||
|
||||
if ds.FileExists(fileName) != true {
|
||||
t.Fatalf("Cannot find file")
|
||||
}
|
||||
|
||||
err = ds.Delete(fileName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot delete file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileUploadDRS(t *testing.T) {
|
||||
dsName := "datastore3"
|
||||
hostName := ""
|
||||
|
||||
fileName := fmt.Sprintf("test-%v", time.Now().Unix())
|
||||
tmpFile, err := ioutil.TempFile("", fileName)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temp file")
|
||||
}
|
||||
err = tmpFile.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating temp file")
|
||||
}
|
||||
|
||||
d := newTestDriver(t)
|
||||
ds, err := d.FindDatastore(dsName, hostName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot find datastore '%v': %v", dsName, err)
|
||||
}
|
||||
|
||||
err = ds.UploadFile(tmpFile.Name(), fileName, hostName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot upload file: %v", err)
|
||||
}
|
||||
|
||||
if ds.FileExists(fileName) != true {
|
||||
t.Fatalf("Cannot find file")
|
||||
}
|
||||
|
||||
err = ds.Delete(fileName)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot delete file: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
d-i passwd/user-fullname string jetbrains
|
||||
d-i passwd/username string jetbrains
|
||||
d-i passwd/user-password password jetbrains
|
||||
d-i passwd/user-password-again password jetbrains
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
|
||||
d-i partman-auto/disk string /dev/sda
|
||||
d-i partman-auto/method string regular
|
||||
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
|
||||
d-i pkgsel/include string open-vm-tools openssh-server
|
||||
|
||||
d-i finish-install/reboot_in_progress note
|
Loading…
Reference in New Issue