Merge pull request #59 from makunterry/CP-19292

CP-19292: added an option for "format" to export compressed xva
This commit is contained in:
Rob Dobson 2016-10-21 11:44:17 +01:00 committed by GitHub
commit 3531171bc4
2 changed files with 11 additions and 3 deletions

View File

@ -184,7 +184,7 @@ func (c *CommonConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig
}
switch c.Format {
case "xva", "vdi_raw", "vdi_vhd", "none":
case "xva", "xva_compressed", "vdi_raw", "vdi_vhd", "none":
default:
errs = append(errs, errors.New("format must be one of 'xva', 'vdi_raw', 'vdi_vhd', 'none'"))
}

View File

@ -95,11 +95,18 @@ func (StepExport) Run(state multistep.StateBag) multistep.StepAction {
ui.Say("Step: export artifact")
compress_option_xe := "compress=false"
compress_option_url := ""
switch config.Format {
case "none":
ui.Say("Skipping export")
return multistep.ActionContinue
case "xva_compressed":
compress_option_xe = "compress=true"
compress_option_url = "use_compression=true&"
fallthrough
case "xva":
// export the VM
@ -115,7 +122,7 @@ func (StepExport) Run(state multistep.StateBag) multistep.StepAction {
"-pw", client.Password,
"vm-export",
"vm="+instance_uuid,
"compress=true",
compress_option_xe,
"filename="+export_filename,
)
@ -123,8 +130,9 @@ func (StepExport) Run(state multistep.StateBag) multistep.StepAction {
err = cmd.Run()
} else {
export_url := fmt.Sprintf("https://%s/export?uuid=%s&session_id=%s",
export_url := fmt.Sprintf("https://%s/export?%suuid=%s&session_id=%s",
client.Host,
compress_option_url,
instance_uuid,
client.Session.(string),
)