Add options to configure vCPU numbers for XVA builders also.
Signed-off-by: zheng chai <zheng.chai@citrix.com>
This commit is contained in:
parent
5e1f8571d6
commit
c7ac4898ed
@ -21,6 +21,8 @@ type config struct {
|
||||
xscommon.CommonConfig `mapstructure:",squash"`
|
||||
|
||||
SourcePath string `mapstructure:"source_path"`
|
||||
VCPUsMax uint `mapstructure:"vcpus_max"`
|
||||
VCPUsAtStartup uint `mapstructure:"vcpus_atstartup"`
|
||||
VMMemory uint `mapstructure:"vm_memory"`
|
||||
|
||||
PlatformArgs map[string]string `mapstructure:"platform_args"`
|
||||
@ -54,6 +56,17 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, retErr error
|
||||
errs, self.config.CommonConfig.Prepare(&self.config.ctx, &self.config.PackerConfig)...)
|
||||
|
||||
// Set default values
|
||||
if self.config.VCPUsMax == 0 {
|
||||
self.config.VCPUsMax = 1
|
||||
}
|
||||
|
||||
if self.config.VCPUsAtStartup == 0 {
|
||||
self.config.VCPUsAtStartup = 1
|
||||
}
|
||||
|
||||
if self.config.VCPUsAtStartup > self.config.VCPUsMax {
|
||||
self.config.VCPUsAtStartup = self.config.VCPUsMax
|
||||
}
|
||||
|
||||
if self.config.VMMemory == 0 {
|
||||
self.config.VMMemory = 1024
|
||||
|
@ -60,6 +60,18 @@ func (self *stepImportInstance) Run(state multistep.StateBag) multistep.StepActi
|
||||
}
|
||||
state.Put("instance_uuid", instanceId)
|
||||
|
||||
err = instance.SetVCPUsMax(config.VCPUsMax)
|
||||
if err != nil {
|
||||
ui.Error(fmt.Sprintf("Error setting VM VCPUs Max=%d: %s", config.VCPUsMax, err.Error()))
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
err = instance.SetVCPUsAtStartup(config.VCPUsAtStartup)
|
||||
if err != nil {
|
||||
ui.Error(fmt.Sprintf("Error setting VM VCPUs At Startup=%d: %s", config.VCPUsAtStartup, err.Error()))
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
instance.SetDescription(config.VMDescription)
|
||||
if err != nil {
|
||||
ui.Error(fmt.Sprintf("Error setting VM description: %s", err.Error()))
|
||||
|
Loading…
Reference in New Issue
Block a user