Skip to content

Commit

Permalink
Fix sending empty mac address to XO (#235)
Browse files Browse the repository at this point in the history
* Removed mac statefunc

* Fix sending empty mac to API

* Revert "Removed mac statefunc"

This reverts commit c79ff34.
  • Loading branch information
ravager-dk authored Apr 1, 2023
1 parent 3e52151 commit 60507a7
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions xoa/resource_xenorchestra_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,18 @@ func resourceVmCreate(d *schema.ResourceData, m interface{}) error {
for _, network := range networks {
netMap, _ := network.(map[string]interface{})

network_maps = append(network_maps, map[string]string{
"network": netMap["network_id"].(string),
"mac": getFormattedMac(netMap["mac_address"].(string)),
})
netID := netMap["network_id"].(string)
macAddr := netMap["mac_address"].(string)

netMapToAdd := map[string]string{
"network": netID,
}
// We only add the mac address if it contains a value.
if macAddr != "" {
netMapToAdd["mac"] = getFormattedMac(macAddr)
}

network_maps = append(network_maps, netMapToAdd)
}

ds := []client.Disk{}
Expand Down Expand Up @@ -1184,20 +1192,19 @@ type guestNetwork map[string][]string
// of maps where each element represents a network interface.
// Each map will contain the following keys: ip, ipv4 and ipv6. The values
// will be a slice of ip addresses.
// []map[string][]string{
// {
// "ip": []string{"interface 1's IPs",
// "ipv4": []string{"interface 1's IPs",
// "ipv6": []string{"ip1", "ip2"}
// },
// {
// "ip": []string{"interface 2's IPs",
// "ipv4": []string{"interface 2's IPs",
// "ipv6": []string{"ip1", "ip2"}
// },
// }
//
//
// []map[string][]string{
// {
// "ip": []string{"interface 1's IPs",
// "ipv4": []string{"interface 1's IPs",
// "ipv6": []string{"ip1", "ip2"}
// },
// {
// "ip": []string{"interface 2's IPs",
// "ipv4": []string{"interface 2's IPs",
// "ipv6": []string{"ip1", "ip2"}
// },
// }
func extractIpsFromNetworks(networks map[string]string) []guestNetwork {

if len(networks) < 1 {
Expand Down

0 comments on commit 60507a7

Please sign in to comment.