Skip to content

Commit

Permalink
CLOUD-724: copy_out_guest_install_log + Big Sur support/default resou…
Browse files Browse the repository at this point in the history
…rce changes for create
  • Loading branch information
NorseGaud committed Jan 18, 2021
1 parent f9853dc commit 423669a
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ _testmain.go
*.prof

.DS_Store
install-anka-packer*.log
3 changes: 2 additions & 1 deletion builder/anka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/mitchellh/mapstructure"
)

const DEFAULT_BOOT_DELAY = "10s"
const DEFAULT_BOOT_DELAY = "20s"

type Config struct {
common.PackerConfig `mapstructure:",squash"`
Expand All @@ -39,6 +39,7 @@ type Config struct {
BootDelay string `mapstructure:"boot_delay"`
EnableHtt bool `mapstructure:"enable_htt"`
DisableHtt bool `mapstructure:"disable_htt"`
CopyOutGuestInstallLog bool `mapstructure:"copy_out_guest_install_log"`

ctx interpolate.Context
}
Expand Down
35 changes: 19 additions & 16 deletions builder/anka/step_create_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func init() {
type StepCreateVM struct {
client *client.Client
vmName string
config *Config
}

const (
DEFAULT_DISK_SIZE = "25G"
DEFAULT_RAM_SIZE = "2G"
DEFAULT_DISK_SIZE = "35G"
DEFAULT_RAM_SIZE = "4G"
DEFAULT_CPU_COUNT = "2"
)

Expand Down Expand Up @@ -154,11 +155,14 @@ func (s *StepCreateVM) modifyVMProperties(describeResponse client.DescribeRespon

func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(*Config)

ui := state.Get("ui").(packer.Ui)

s.client = state.Get("client").(*client.Client)
sourceVMName := config.SourceVMName

s.config = config

onError := func(err error) multistep.StepAction {
return stepError(ui, state, err)
}
Expand Down Expand Up @@ -296,20 +300,6 @@ func (s *StepCreateVM) Cleanup(state multistep.StateBag) {
return
}

dir, dir_err := os.Getwd()
if dir_err == nil {
err = s.client.Copy(client.CopyParams{
Src: s.vmName + ":/var/log/install.log",
Dst: dir + "/install-" + s.vmName + ".log",
})

if err != nil {
log.Println("Error downloading install log from VM")
}

ui.Say(fmt.Sprintf("Saved install.log from %s to ./install-%s.log", s.vmName, s.vmName))
}

_, halted := state.GetOk(multistep.StateHalted)
_, canceled := state.GetOk(multistep.StateCancelled)
errorObj := state.Get("error")
Expand All @@ -319,6 +309,19 @@ func (s *StepCreateVM) Cleanup(state multistep.StateBag) {
case *common.VMNotFoundException:
return
default:
if s.config.CopyOutGuestInstallLog {
dir, dir_err := os.Getwd()
if dir_err == nil {
err = s.client.Copy(client.CopyParams{
Src: s.vmName + ":/var/log/install.log",
Dst: dir + "/install-" + s.vmName + ".log",
})
if err != nil {
log.Println("Error downloading install log from VM")
}
ui.Say(fmt.Sprintf("Saved install.log from %s to ./install-%s.log", s.vmName, s.vmName))
}
}
if halted || canceled {
ui.Say(fmt.Sprintf("Deleting VM %s", s.vmName))
err = s.client.Delete(client.DeleteParams{VMName: s.vmName})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
],
"builders": [{
"type": "veertu-anka",
"installer_app": "/Applications/Install macOS Sierra.app/",
"disk_size": "25G",
"copy_out_guest_install_log": true,
"source_vm_name": "{{user `source_vm_name`}}"
}]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"builders": [{
"type": "veertu-anka",
"installer_app": "/Applications/Install macOS Catalina.app",
"installer_app": "/Applications/Install macOS Big Sur.app",
"vm_name": "Testing"
}]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
]
}
],
"builders": [{
"type": "veertu-anka",
"cpu_count": 8,
"ram_size": "10G",
"disk_size": "150G",
"source_vm_name": "{{user `source_vm_name`}}"
}]
"builders": [{
"type": "veertu-anka",
"cpu_count": 8,
"ram_size": "10G",
"disk_size": "150G",
"source_vm_name": "{{user `source_vm_name`}}"
}]
}
File renamed without changes.
8 changes: 0 additions & 8 deletions examples/macos-catalina.json

This file was deleted.

0 comments on commit 423669a

Please sign in to comment.