This commit is contained in:
Andrei Tonkikh 2018-02-01 15:48:30 +03:00
parent cf198539e8
commit 9c4d5c6c59
3 changed files with 3 additions and 19 deletions

View File

@ -350,7 +350,7 @@ func (vm *VirtualMachine) GetDir() (string, error) {
vmxName := fmt.Sprintf("/%s.vmx", vmInfo.Name) vmxName := fmt.Sprintf("/%s.vmx", vmInfo.Name)
for _, file := range vmInfo.LayoutEx.File { for _, file := range vmInfo.LayoutEx.File {
if strings.HasSuffix(file.Name, vmxName) { if strings.HasSuffix(file.Name, vmxName) {
return file.Name[:len(file.Name)-len(vmxName)], nil return RemoveDatastorePrefix(file.Name[:len(file.Name)-len(vmxName)]), nil
} }
} }
return "", fmt.Errorf("cannot find '%s'", vmxName) return "", fmt.Errorf("cannot find '%s'", vmxName)

View File

@ -241,14 +241,12 @@ func TestISOBuilderAcc_createFloppy(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Error creating temp file ") t.Fatalf("Error creating temp file ")
} }
content := "Hello, World!" fmt.Fprint(tmpFile, "Hello, World!")
fmt.Fprint(tmpFile, content)
tmpFile.Close() tmpFile.Close()
builderT.Test(t, builderT.TestCase{ builderT.Test(t, builderT.TestCase{
Builder: &Builder{}, Builder: &Builder{},
Template: createFloppyConfig(tmpFile.Name()), Template: createFloppyConfig(tmpFile.Name()),
Check: checkCreateFloppy(t, content),
}) })
} }
@ -257,16 +255,3 @@ func createFloppyConfig(filePath string) string {
config["floppy_files"] = []string{filePath} config["floppy_files"] = []string{filePath}
return commonT.RenderConfig(config) return commonT.RenderConfig(config)
} }
func checkCreateFloppy(t *testing.T, content string) builderT.TestCheckFunc {
return func(artifacts []packer.Artifact) error {
d := commonT.TestConn(t)
vm := commonT.GetVM(t, d, artifacts)
_, err := vm.GetDir()
if err != nil {
t.Fatalf(err.Error())
}
return nil
}
}

View File

@ -63,7 +63,6 @@ func (s *StepAddFloppy) runImpl(state multistep.StateBag) error {
if err != nil { if err != nil {
return err return err
} }
vmDir = driver.RemoveDatastorePrefix(vmDir)
uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.img", vmDir) uploadPath := fmt.Sprintf("%v/packer-tmp-created-floppy.img", vmDir)
if err := ds.UploadFile(tmpFloppy.(string), uploadPath); err != nil { if err := ds.UploadFile(tmpFloppy.(string), uploadPath); err != nil {
@ -104,5 +103,5 @@ func (s *StepAddFloppy) Cleanup(state multistep.StateBag) {
return return
} }
// TODO: remove Floppy device, or eject the img // the img will be automatically ejected
} }