From 8bf2609a7f0d979dd319bb29e373d18772145ac0 Mon Sep 17 00:00:00 2001 From: Rob Dobson Date: Fri, 21 Nov 2014 13:48:57 +0000 Subject: [PATCH] Adding static memory config to the template. Signed-off-by: Rob Dobson --- builder/xenserver/builder.go | 6 ++++++ builder/xenserver/step_create_instance.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/xenserver/builder.go b/builder/xenserver/builder.go index 8b59a70..221a616 100644 --- a/builder/xenserver/builder.go +++ b/builder/xenserver/builder.go @@ -26,6 +26,7 @@ type config struct { IsoUrl string `mapstructure:"iso_url"` InstanceName string `mapstructure:"instance_name"` + InstanceMemory string `mapstructure:"instance_memory"` RootDiskSize string `mapstructure:"root_disk_size"` CloneTemplate string `mapstructure:"clone_template"` IsoName string `mapstructure:"iso_name"` @@ -125,6 +126,7 @@ func (self *Builder) Prepare (raws ...interface{}) (params []string, retErr erro "host_ip": &self.config.HostIp, "iso_url": &self.config.IsoUrl, "instance_name": &self.config.InstanceName, + "instance_memory": &self.config.InstanceMemory, "root_disk_size": &self.config.RootDiskSize, "clone_template": &self.config.CloneTemplate, "iso_name": &self.config.IsoName, @@ -212,6 +214,10 @@ func (self *Builder) Prepare (raws ...interface{}) (params []string, retErr erro errs, errors.New("An insatnce name must be specified.")) } + if self.config.InstanceMemory == "" { + self.config.InstanceMemory = "1024000000" + } + if self.config.RootDiskSize == "" { errs = packer.MultiErrorAppend( errs, errors.New("A root disk size must be specified.")) diff --git a/builder/xenserver/step_create_instance.go b/builder/xenserver/step_create_instance.go index a07bc5c..ce3c51b 100644 --- a/builder/xenserver/step_create_instance.go +++ b/builder/xenserver/step_create_instance.go @@ -39,7 +39,7 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi // Clone that VM template instance, _ := template.Clone(config.InstanceName) instance.SetIsATemplate(false) - instance.SetStaticMemoryRange("1024000000", "1024000000") + instance.SetStaticMemoryRange(config.InstanceMemory, config.InstanceMemory) instance.SetPlatform(config.PlatformArgs) // Create VDI for the instance