CP-18646: Make packer-build-xenserver support other-config for vm packing
Signed-off-by: kunm <kun.ma@citrix.com>
This commit is contained in:
parent
c64f6973c4
commit
b1f0013d8c
@ -25,6 +25,7 @@ type config struct {
|
|||||||
VMMemory uint `mapstructure:"vm_memory"`
|
VMMemory uint `mapstructure:"vm_memory"`
|
||||||
DiskSize uint `mapstructure:"disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
CloneTemplate string `mapstructure:"clone_template"`
|
CloneTemplate string `mapstructure:"clone_template"`
|
||||||
|
VMOtherConfig map[string]string `mapstructure:"vm_other_config"`
|
||||||
|
|
||||||
ISOChecksum string `mapstructure:"iso_checksum"`
|
ISOChecksum string `mapstructure:"iso_checksum"`
|
||||||
ISOChecksumType string `mapstructure:"iso_checksum_type"`
|
ISOChecksumType string `mapstructure:"iso_checksum_type"`
|
||||||
|
@ -56,18 +56,34 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.SetPlatform(config.PlatformArgs)
|
err = instance.SetPlatform(config.PlatformArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(fmt.Sprintf("Error setting VM platform: %s", err.Error()))
|
ui.Error(fmt.Sprintf("Error setting VM platform: %s", err.Error()))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.SetDescription(config.VMDescription)
|
err = instance.SetDescription(config.VMDescription)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Error(fmt.Sprintf("Error setting VM description: %s", err.Error()))
|
ui.Error(fmt.Sprintf("Error setting VM description: %s", err.Error()))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(config.VMOtherConfig) != 0 {
|
||||||
|
vm_other_config, err := instance.GetOtherConfig()
|
||||||
|
if err != nil {
|
||||||
|
ui.Error(fmt.Sprintf("Error getting VM other-config: %s", err.Error()))
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
for key, value := range config.VMOtherConfig {
|
||||||
|
vm_other_config[key] = value
|
||||||
|
}
|
||||||
|
err = instance.SetOtherConfig(vm_other_config)
|
||||||
|
if err != nil {
|
||||||
|
ui.Error(fmt.Sprintf("Error setting VM other-config: %s", err.Error()))
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create VDI for the instance
|
// Create VDI for the instance
|
||||||
|
|
||||||
sr, err := config.GetSR(client)
|
sr, err := config.GetSR(client)
|
||||||
|
15
vendor/github.com/xenserver/go-xenserver-client/vm.go
generated
vendored
15
vendor/github.com/xenserver/go-xenserver-client/vm.go
generated
vendored
@ -521,6 +521,21 @@ func (self *VM) SetIsATemplate(is_a_template bool) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *VM) GetOtherConfig() (other_config map[string]string, err error) {
|
||||||
|
result := APIResult{}
|
||||||
|
other_config = make(map[string]string)
|
||||||
|
err = self.Client.APICall(&result, "VM.get_other_config", self.Ref)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for key, value := range result.Value.(xmlrpc.Struct) {
|
||||||
|
if valueStr, ok := value.(string); ok {
|
||||||
|
other_config[key] = valueStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (self *VM) SetOtherConfig(other_config map[string]string) (err error) {
|
func (self *VM) SetOtherConfig(other_config map[string]string) (err error) {
|
||||||
result := APIResult{}
|
result := APIResult{}
|
||||||
other_config_rec := make(xmlrpc.Struct)
|
other_config_rec := make(xmlrpc.Struct)
|
||||||
|
Loading…
Reference in New Issue
Block a user