Merge pull request #27 from kongslund/vm-description

Added VM description field
This commit is contained in:
Rob Dobson 2015-05-18 15:19:20 +01:00
commit db43b42ef7
5 changed files with 24 additions and 6 deletions

View File

@ -18,10 +18,11 @@ type CommonConfig struct {
Password string `mapstructure:"remote_password"`
HostIp string `mapstructure:"remote_host"`
VMName string `mapstructure:"vm_name"`
SrName string `mapstructure:"sr_name"`
FloppyFiles []string `mapstructure:"floppy_files"`
NetworkName string `mapstructure:"network_name"`
VMName string `mapstructure:"vm_name"`
VMDescription string `mapstructure:"vm_description"`
SrName string `mapstructure:"sr_name"`
FloppyFiles []string `mapstructure:"floppy_files"`
NetworkName string `mapstructure:"network_name"`
HostPortMin uint `mapstructure:"host_port_min"`
HostPortMax uint `mapstructure:"host_port_max"`
@ -135,6 +136,7 @@ func (c *CommonConfig) Prepare(t *packer.ConfigTemplate, pc *common.PackerConfig
"remote_password": &c.Password,
"remote_host": &c.HostIp,
"vm_name": &c.VMName,
"vm_description": &c.VMDescription,
"sr_name": &c.SrName,
"shutdown_command": &c.ShutdownCommand,
"boot_wait": &c.RawBootWait,

View File

@ -62,6 +62,12 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi
return multistep.ActionHalt
}
instance.SetDescription(config.VMDescription)
if err != nil {
ui.Error(fmt.Sprintf("Error setting VM description: %s", err.Error()))
return multistep.ActionHalt
}
// Create VDI for the instance
sr, err := config.GetSR(client)

View File

@ -140,8 +140,14 @@ func (self *stepImportInstance) Run(state multistep.StateBag) multistep.StepActi
ui.Error(fmt.Sprintf("Unable to get VM UUID: %s", err.Error()))
return multistep.ActionHalt
}
state.Put("instance_uuid", instanceId)
instance.SetDescription(config.VMDescription)
if err != nil {
ui.Error(fmt.Sprintf("Error setting VM description: %s", err.Error()))
return multistep.ActionHalt
}
ui.Say(fmt.Sprintf("Imported instance '%s'", instanceId))
return multistep.ActionContinue

View File

@ -204,6 +204,9 @@ each category, the available options are alphabetized and described.
* `tools_iso_name` (string) - The name of the XenServer Tools ISO. Defaults to
"xs-tools.iso".
* `vm_description` (string) - The description of the new virtual
machine. By default this is the empty string.
* `vm_name` (string) - This is the name of the new virtual
machine, without the file extension. By default this is
"packer-BUILDNAME-TIMESTAMP", where "BUILDNAME" is the name of the build.

View File

@ -20,7 +20,8 @@
"ssh_username": "root",
"ssh_password": "vmpassword",
"ssh_wait_timeout": "10000s",
"vm_name": "packer-centos-6.6-x86_64"
"vm_name": "packer-centos-6.6-x86_64",
"vm_description": "Build time: {{isotime}}"
}
],