@@ -94,17 +94,18 @@ type StepCreateVM struct {
9494func (s * StepCreateVM ) Run (_ context.Context , state multistep.StateBag ) multistep.StepAction {
9595 ui := state .Get ("ui" ).(packer.Ui )
9696 d := state .Get ("driver" ).(* driver.Driver )
97+ vmPath := fmt .Sprintf ("%s/%s" , s .Location .Folder , s .Location .VMName )
9798
98- vm , err := d .FindVM (s . Location . VMName )
99+ vm , err := d .FindVM (vmPath )
99100
100101 if s .Force == false && err == nil {
101- state .Put ("error" , fmt .Errorf ("%s already exists, you can use -force flag to destroy it: %v" , s . Location . VMName , err ))
102+ state .Put ("error" , fmt .Errorf ("%s already exists, you can use -force flag to destroy it: %v" , vmPath , err ))
102103 return multistep .ActionHalt
103104 } else if s .Force == true && err == nil {
104- ui .Say (fmt .Sprintf ("the vm/template %s already exists, but deleting it due to -force flag" , s . Location . VMName ))
105+ ui .Say (fmt .Sprintf ("the vm/template %s already exists, but deleting it due to -force flag" , vmPath ))
105106 err := vm .Destroy ()
106107 if err != nil {
107- state .Put ("error" , fmt .Errorf ("error destroying %s: %v" , s . Location . VMName , err ))
108+ state .Put ("error" , fmt .Errorf ("error destroying %s: %v" , vmPath , err ))
108109 }
109110 }
110111
0 commit comments