Skip to content

Commit

Permalink
Address issues with affinity_host on update and mac_address on VIF cr…
Browse files Browse the repository at this point in the history
…eation

(cherry picked from commit 07c7e10f3cba8f7a1fd12ecececd4c656dc9ae32)
  • Loading branch information
ddelnano committed Aug 15, 2023
1 parent 48f40ed commit 495a771
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/vif.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (c *Client) CreateVIF(vm *Vm, vif *VIF) (*VIF, error) {
params := map[string]interface{}{
"network": vif.Network,
"vm": vm.Id,
"mac": vif.MacAddress,
}
if vif.MacAddress != "" {
params["mac"] = vif.MacAddress
}
err := c.Call("vm.createInterface", params, &id)

Expand Down
10 changes: 9 additions & 1 deletion client/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ func createVdiMap(disk Disk) map[string]interface{} {
func (c *Client) UpdateVm(vmReq Vm) (*Vm, error) {
params := map[string]interface{}{
"id": vmReq.Id,
"affinityHost": vmReq.AffinityHost,
"name_label": vmReq.NameLabel,
"name_description": vmReq.NameDescription,
"auto_poweron": vmReq.AutoPoweron,
Expand All @@ -343,6 +342,15 @@ func (c *Client) UpdateVm(vmReq Vm) (*Vm, error) {
// coresPerSocket is null or a number of cores per socket. Putting an invalid value doesn't seem to cause an error :(
}

affinityHost := vmReq.AffinityHost
if affinityHost != nil {
if *affinityHost == "" {
params["affinityHost"] = nil
} else {
params["affinityHost"] = *affinityHost
}
}

videoram := vmReq.Videoram.Value
if videoram != 0 {
params["videoram"] = videoram
Expand Down
2 changes: 1 addition & 1 deletion xoa/resource_xenorchestra_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ func resourceVmUpdate(d *schema.ResourceData, m interface{}) error {
},
}

if d.HasChange("affinity_host") && affinityHost != "" {
if d.HasChange("affinity_host") {
vmReq.AffinityHost = &affinityHost
}

Expand Down

0 comments on commit 495a771

Please sign in to comment.