Skip to content

Commit

Permalink
fix: Node, Pool, VmID are never set
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyblargon committed Nov 27, 2023
1 parent e4c6e59 commit 796c3d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (config ConfigQemu) mapToApiValues(currentConfig ConfigQemu) (rebootRequire
return
}

func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error) {
func (ConfigQemu) mapToStruct(vmr *VmRef, params map[string]interface{}) (*ConfigQemu, error) {
// vmConfig Sample: map[ cpu:host
// net0:virtio=62:DF:XX:XX:XX:XX,bridge=vmbr0
// ide2:local:iso/xxx-xx.iso,media=cdrom memory:2048
Expand All @@ -469,6 +469,12 @@ func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error

config := ConfigQemu{}

if vmr != nil {
config.Node = vmr.node
config.Pool = vmr.pool
config.VmID = vmr.vmId
}

if _, isSet := params["agent"]; isSet {
switch params["agent"].(type) {
case float64:
Expand Down Expand Up @@ -1204,7 +1210,7 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
if vmConfig["lock"] != nil {
return nil, fmt.Errorf("vm locked, could not obtain config")
}
config, err = ConfigQemu{}.mapToStruct(vmConfig)
config, err = ConfigQemu{}.mapToStruct(vmr, vmConfig)
if err != nil {
return
}
Expand Down

0 comments on commit 796c3d7

Please sign in to comment.