Skip to content

Commit

Permalink
Enable extra ISO as ide3 on VM creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmreyes committed Apr 4, 2020
1 parent a295664 commit 345f660
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ConfigQemu struct {
QemuNuma bool `json:"numa"`
Hotplug string `json:"hotplug"`
QemuIso string `json:"iso"`
QemuIsoExtra string `json:"isoextra,omitempty"`
FullClone *int `json:"fullclone"`
Boot string `json:"boot"`
BootDisk string `json:"bootdisk,omitempty"`
Expand Down Expand Up @@ -107,11 +108,11 @@ func (config ConfigQemu) CreateVm(vmr *VmRef, client *Client) (err error) {
if config.Balloon >= 1 {
params["balloon"] = config.Balloon
}

if config.QemuVcpus >= 1 {
params["vcpus"] = config.QemuVcpus
}

if vmr.pool != "" {
params["pool"] = vmr.pool
}
Expand All @@ -124,6 +125,10 @@ func (config ConfigQemu) CreateVm(vmr *VmRef, client *Client) (err error) {
params["scsihw"] = config.Scsihw
}

if config.QemuIsoExtra != "" {
params["ide3"] = config.QemuIsoExtra + ",media=cdrom"
}

// Create disks config.
config.CreateQemuDisksParams(vmr.vmId, params, false)

Expand Down Expand Up @@ -231,13 +236,13 @@ func (config ConfigQemu) UpdateConfig(vmr *VmRef, client *Client) (err error) {
} else {
deleteParams = append(deleteParams, "balloon")
}

if config.QemuVcpus >= 1 {
configParams["vcpus"] = config.QemuVcpus
} else {
deleteParams = append(deleteParams, "vcpus")
}

if config.BootDisk != "" {
configParams["bootdisk"] = config.BootDisk
}
Expand Down Expand Up @@ -307,11 +312,11 @@ func (config ConfigQemu) UpdateConfig(vmr *VmRef, client *Client) (err error) {
if config.Ipconfig2 != "" {
configParams["ipconfig2"] = config.Ipconfig2
}

if len(deleteParams) > 0 {
configParams["delete"] = strings.Join(deleteParams, ", ")
}

_, err = client.SetVmConfig(vmr, configParams)
if err != nil {
log.Print(err)
Expand Down Expand Up @@ -481,19 +486,24 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
QemuNetworks: QemuDevices{},
QemuSerials: QemuDevices{},
}

if balloon >= 1 {
config.Balloon = int(balloon);
config.Balloon = int(balloon)
}
if vcpus >= 1 {
config.QemuVcpus = int(vcpus);
config.QemuVcpus = int(vcpus)
}

if vmConfig["ide2"] != nil {
isoMatch := rxIso.FindStringSubmatch(vmConfig["ide2"].(string))
config.QemuIso = isoMatch[1]
}

if vmConfig["ide3"] != nil {
isoMatch := rxIso.FindStringSubmatch(vmConfig["ide3"].(string))
config.QemuIsoExtra = isoMatch[1]
}

if _, isSet := vmConfig["ciuser"]; isSet {
config.CIuser = vmConfig["ciuser"].(string)
}
Expand Down

0 comments on commit 345f660

Please sign in to comment.