diff --git a/builder/cloudstack/config.go b/builder/cloudstack/config.go index 5d6e9da0a..68fe778d4 100644 --- a/builder/cloudstack/config.go +++ b/builder/cloudstack/config.go @@ -55,9 +55,8 @@ type Config struct { TemplateScalable bool `mapstructure:"template_scalable"` TemplateTag string `mapstructure:"template_tag"` - ctx interpolate.Context - hostAddress string // The host address used by the communicators. - instanceSource string // This can be either a template ID or an ISO ID. + ctx interpolate.Context + hostAddress string // The host address used by the communicators. } // NewConfig parses and validates the given config. diff --git a/builder/cloudstack/step_create_instance.go b/builder/cloudstack/step_create_instance.go index 3b624de3c..90db2d960 100644 --- a/builder/cloudstack/step_create_instance.go +++ b/builder/cloudstack/step_create_instance.go @@ -30,13 +30,14 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) + source := state.Get("source").(string) ui.Say("Creating instance...") // Create a new parameter struct. p := client.VirtualMachine.NewDeployVirtualMachineParams( config.ServiceOffering, - config.instanceSource, + source, config.Zone, ) diff --git a/builder/cloudstack/step_prepare_config.go b/builder/cloudstack/step_prepare_config.go index de397308e..8fafc809e 100644 --- a/builder/cloudstack/step_prepare_config.go +++ b/builder/cloudstack/step_prepare_config.go @@ -101,23 +101,25 @@ func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction { if config.SourceISO != "" { if isUUID(config.SourceISO) { - config.instanceSource = config.SourceISO + state.Put("source", config.SourceISO) } else { - config.instanceSource, _, err = client.ISO.GetIsoID(config.SourceISO, "executable", config.Zone) + isoID, _, err := client.ISO.GetIsoID(config.SourceISO, "executable", config.Zone) if err != nil { errs = packer.MultiErrorAppend(errs, &retrieveErr{"ISO", config.SourceISO, err}) } + state.Put("source", isoID) } } if config.SourceTemplate != "" { if isUUID(config.SourceTemplate) { - config.instanceSource = config.SourceTemplate + state.Put("source", config.SourceTemplate) } else { - config.instanceSource, _, err = client.Template.GetTemplateID(config.SourceTemplate, "executable", config.Zone) + templateID, _, err := client.Template.GetTemplateID(config.SourceTemplate, "executable", config.Zone) if err != nil { errs = packer.MultiErrorAppend(errs, &retrieveErr{"template", config.SourceTemplate, err}) } + state.Put("source", templateID) } }