Rename root_disk_size to disk_size
CreateVdi now takes an integer size Note that disk_size is now in MB; root_disk_size was in bytes Fixed example
This commit is contained in:
parent
e308c0759f
commit
987a5ac55e
@ -26,7 +26,7 @@ type config struct {
|
|||||||
|
|
||||||
InstanceName string `mapstructure:"instance_name"`
|
InstanceName string `mapstructure:"instance_name"`
|
||||||
InstanceMemory string `mapstructure:"instance_memory"`
|
InstanceMemory string `mapstructure:"instance_memory"`
|
||||||
RootDiskSize string `mapstructure:"root_disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
CloneTemplate string `mapstructure:"clone_template"`
|
CloneTemplate string `mapstructure:"clone_template"`
|
||||||
SrName string `mapstructure:"sr_name"`
|
SrName string `mapstructure:"sr_name"`
|
||||||
FloppyFiles []string `mapstructure:"floppy_files"`
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
||||||
@ -130,6 +130,10 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, retErr error
|
|||||||
self.config.RawSSHWaitTimeout = "200m"
|
self.config.RawSSHWaitTimeout = "200m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.config.DiskSize == 0 {
|
||||||
|
self.config.DiskSize = 40000
|
||||||
|
}
|
||||||
|
|
||||||
if self.config.InstanceMemory == "" {
|
if self.config.InstanceMemory == "" {
|
||||||
self.config.InstanceMemory = "1024000000"
|
self.config.InstanceMemory = "1024000000"
|
||||||
}
|
}
|
||||||
@ -173,7 +177,6 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, retErr error
|
|||||||
"host_ip": &self.config.HostIp,
|
"host_ip": &self.config.HostIp,
|
||||||
"instance_name": &self.config.InstanceName,
|
"instance_name": &self.config.InstanceName,
|
||||||
"instance_memory": &self.config.InstanceMemory,
|
"instance_memory": &self.config.InstanceMemory,
|
||||||
"root_disk_size": &self.config.RootDiskSize,
|
|
||||||
"clone_template": &self.config.CloneTemplate,
|
"clone_template": &self.config.CloneTemplate,
|
||||||
"sr_name": &self.config.SrName,
|
"sr_name": &self.config.SrName,
|
||||||
"network_name": &self.config.NetworkName,
|
"network_name": &self.config.NetworkName,
|
||||||
@ -272,11 +275,6 @@ func (self *Builder) Prepare(raws ...interface{}) (params []string, retErr error
|
|||||||
errs, errors.New("An instance name must be specified."))
|
errs, errors.New("An instance name must be specified."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.RootDiskSize == "" {
|
|
||||||
errs = packer.MultiErrorAppend(
|
|
||||||
errs, errors.New("A root disk size must be specified."))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch self.config.ExportFormat {
|
switch self.config.ExportFormat {
|
||||||
case "xva", "vdi_raw":
|
case "xva", "vdi_raw":
|
||||||
default:
|
default:
|
||||||
|
@ -689,13 +689,13 @@ func (self *VM) SetIsATemplate(is_a_template bool) (err error) {
|
|||||||
|
|
||||||
// SR associated functions
|
// SR associated functions
|
||||||
|
|
||||||
func (self *SR) CreateVdi(name_label, size string) (vdi *VDI, err error) {
|
func (self *SR) CreateVdi(name_label string, size int64) (vdi *VDI, err error) {
|
||||||
vdi = new(VDI)
|
vdi = new(VDI)
|
||||||
|
|
||||||
vdi_rec := make(xmlrpc.Struct)
|
vdi_rec := make(xmlrpc.Struct)
|
||||||
vdi_rec["name_label"] = name_label
|
vdi_rec["name_label"] = name_label
|
||||||
vdi_rec["SR"] = self.Ref
|
vdi_rec["SR"] = self.Ref
|
||||||
vdi_rec["virtual_size"] = size
|
vdi_rec["virtual_size"] = fmt.Sprintf("%d", size)
|
||||||
vdi_rec["type"] = "user"
|
vdi_rec["type"] = "user"
|
||||||
vdi_rec["sharable"] = false
|
vdi_rec["sharable"] = false
|
||||||
vdi_rec["read_only"] = false
|
vdi_rec["read_only"] = false
|
||||||
|
@ -68,7 +68,7 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
vdi, err := sr.CreateVdi("Packer-disk", config.RootDiskSize)
|
vdi, err := sr.CreateVdi("Packer-disk", int64(config.DiskSize*1024*1024))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(fmt.Sprintf("Unable to create packer disk VDI: %s", err.Error()))
|
ui.Error(fmt.Sprintf("Unable to create packer disk VDI: %s", err.Error()))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
@ -53,7 +53,7 @@ func (self *stepUploadVdi) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
fileLength := fstat.Size()
|
fileLength := fstat.Size()
|
||||||
|
|
||||||
// Create the VDI
|
// Create the VDI
|
||||||
vdi, err := sr.CreateVdi(self.VdiName, fmt.Sprintf("%d", fileLength))
|
vdi, err := sr.CreateVdi(self.VdiName, fileLength)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(fmt.Sprintf("Unable to create VDI '%s': %s", self.VdiName, err.Error()))
|
ui.Error(fmt.Sprintf("Unable to create VDI '%s': %s", self.VdiName, err.Error()))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"host_ip": "10.81.2.105",
|
"host_ip": "10.81.2.105",
|
||||||
"instance_name": "packer-centos-6-4",
|
"instance_name": "packer-centos-6-4",
|
||||||
"instance_memory": "2048000000",
|
"instance_memory": "2048000000",
|
||||||
"root_disk_size": "40000000000",
|
"disk_size": 40000,
|
||||||
"iso_name": "CentOS-6.4-x86_64-minimal.iso",
|
"iso_name": "CentOS-6.4-x86_64-minimal.iso",
|
||||||
"http_directory": "http",
|
"http_directory": "http",
|
||||||
"local_ip": "10.80.3.223",
|
"local_ip": "10.80.3.223",
|
||||||
|
Loading…
Reference in New Issue
Block a user