Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/cleaning-format #26

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/nutanix/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ func (a *Artifact) State(name string) interface{} {
func (a *Artifact) Destroy() error {
return nil
//return a.VM.Destroy()
}
}
2 changes: 1 addition & 1 deletion builder/nutanix/pointers.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,4 @@ func TimeValueMap(src map[string]*time.Time) map[string]time.Time {
}

return dst
}
}
21 changes: 11 additions & 10 deletions builder/nutanix/step_build_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nutanix
import (
"context"
"log"

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
)
Expand All @@ -19,12 +20,12 @@ func (s *stepBuildVM) Run(ctx context.Context, state multistep.StateBag) multist
ui.Say("Creating Packer Builder VM on Nutanix Cluster.")
d := state.Get("driver").(Driver)
config := state.Get("config").(*Config)

// Determine if we even have a cd_files disk to attach
log.Println("Check for temporary iso-disks to attach")
if cdPathRaw, ok := state.GetOk("cd_path"); ok {
cdFilesPath := cdPathRaw.(string)
log.Println("temporary iso found, "+cdFilesPath)
log.Println("temporary iso found, " + cdFilesPath)
cdfilesImage, err := d.UploadImage(cdFilesPath, config.VmConfig)
if err != nil {
ui.Error("Error uploading temporary image:")
Expand All @@ -33,22 +34,22 @@ func (s *stepBuildVM) Run(ctx context.Context, state multistep.StateBag) multist
}
ui.Say("Temporary ISO uploaded")
state.Put("imageUUID", *cdfilesImage.image.Metadata.UUID)
temp_cd:= VmDisk{
ImageType: "ISO_IMAGE",
temp_cd := VmDisk{
ImageType: "ISO_IMAGE",
SourceImageUUID: *cdfilesImage.image.Metadata.UUID,
}
config.VmConfig.VmDisks=append(config.VmConfig.VmDisks,temp_cd)
config.VmConfig.VmDisks = append(config.VmConfig.VmDisks, temp_cd)
} else {
log.Println("No temporary iso, not attaching.")
}

//CreateRequest()
vmRequest, err := d.CreateRequest(config.VmConfig)
if err != nil {
ui.Error("Error creating Request: "+ err.Error())
ui.Error("Error creating Request: " + err.Error())
return multistep.ActionHalt
}
vmInstance, err:= d.Create(vmRequest)
vmInstance, err := d.Create(vmRequest)

if err != nil {
ui.Error("Unable to create Nutanix VM request: " + err.Error())
Expand All @@ -59,7 +60,7 @@ func (s *stepBuildVM) Run(ctx context.Context, state multistep.StateBag) multist
state.Put("vmUUID", *vmInstance.nutanix.Metadata.UUID)
state.Put("ip", vmInstance.Addresses()[0])
ui.Say("IP for Nutanix device: " + vmInstance.Addresses()[0])

return multistep.ActionContinue
}

Expand All @@ -77,6 +78,6 @@ func (s *stepBuildVM) Cleanup(state multistep.StateBag) {
if vmUUID != "" {
ui.Say("Cleaning up Nutanix VM.")

}
}
}
}
}
12 changes: 6 additions & 6 deletions builder/nutanix/step_destroy_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package nutanix
import (
"context"
//"log"

"github.com/hashicorp/packer-plugin-sdk/multistep"
"github.com/hashicorp/packer-plugin-sdk/packer"
)
Expand All @@ -22,20 +22,20 @@ func (s *stepDestroyVM) Run(ctx context.Context, state multistep.StateBag) multi
if err != nil {
ui.Error("An error occurred while deleting temporary image")
return multistep.ActionHalt
} else {
} else {
ui.Say("Temporary Image successfully deleted.")
}
}
}

err := d.Delete(vmUUID)
if err != nil {
ui.Error("An error occurred destroying the VM.")
return multistep.ActionHalt
} else {
} else {
ui.Say("Nutanix VM has been successfully deleted.")
}
}
return multistep.ActionContinue
}

func (s *stepDestroyVM) Cleanup(state multistep.StateBag) {
}
}