return vsphere artifact to can build template
This commit is contained in:
parent
da54bf8e73
commit
b754b71519
|
@ -27,6 +27,7 @@ func NewStepMarkAsTemplate(artifact packer.Artifact) *stepMarkAsTemplate {
|
|||
if artifact.BuilderId() == vsphere.BuilderId {
|
||||
id := strings.Split(artifact.Id(), "::")
|
||||
remoteFolder = id[1]
|
||||
vmname = id[2]
|
||||
}
|
||||
|
||||
return &stepMarkAsTemplate{
|
||||
|
@ -50,12 +51,6 @@ func (s *stepMarkAsTemplate) Run(state multistep.StateBag) multistep.StepAction
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
if err := unregisterPreviousVM(cli, folder, s.VMName); err != nil {
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
dsPath, err := datastorePath(vm)
|
||||
if err != nil {
|
||||
state.Put("error", err)
|
||||
|
@ -76,6 +71,12 @@ func (s *stepMarkAsTemplate) Run(state multistep.StateBag) multistep.StepAction
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
if err := unregisterPreviousVM(cli, folder, s.VMName); err != nil {
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
task, err := folder.RegisterVM(context.Background(), dsPath.String(), s.VMName, true, nil, host)
|
||||
if err != nil {
|
||||
state.Put("error", err)
|
||||
|
|
|
@ -140,6 +140,8 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
|||
|
||||
ui.Message(p.filterLog(out.String()))
|
||||
|
||||
artifact = NewArtifact(p.config.Datastore, p.config.VMFolder, p.config.VMName, artifact.Files())
|
||||
|
||||
return artifact, false, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue