Skip to content

Commit

Permalink
SYSENG-1670: ignore network ip order
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Schäfer authored and anx-mschaefer committed Jan 5, 2024
1 parent 6848bf6 commit 057bbb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ If the change isn't user-facing but still relevant enough for a changelog entry,
* (internal)? scope: short description (#pr, @author)
-->

### Fixed
* resource/anxcloud_virtual_server now ignores changes in the order of IP addresses returned by the engine (within a network) (#149, @anx-mschaefer)

## [0.5.4] - 2023-12-18

### Changed
Expand Down
4 changes: 2 additions & 2 deletions anxcloud/schema_virtual_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ func schemaVirtualServer() map[string]*schema.Schema {
Description: "Network interface card type.",
},
"ips": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Description: "Requested list of IPs and IPs identifiers. IPs are ignored when using template_type 'from_scratch'. " +
Description: "Requested set of IPs and IPs identifiers. IPs are ignored when using template_type 'from_scratch'. " +
"Defaults to free IPs from IP pool attached to VLAN.",
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down
5 changes: 3 additions & 2 deletions anxcloud/struct_virtual_server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package anxcloud

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"go.anx.io/go-anxcloud/pkg/vsphere/info"
"go.anx.io/go-anxcloud/pkg/vsphere/provisioning/vm"
)
Expand All @@ -24,8 +25,8 @@ func expandVirtualServerNetworks(p []interface{}) []vm.Network {
network.NICType = v.(string)
}
if v, ok := in["ips"]; ok {
ips := v.([]interface{})
for _, ip := range ips {
ips := v.(*schema.Set)
for _, ip := range ips.List() {
network.IPs = append(network.IPs, ip.(string))
}
}
Expand Down
9 changes: 5 additions & 4 deletions anxcloud/struct_virtual_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"go.anx.io/go-anxcloud/pkg/vsphere/info"
"go.anx.io/go-anxcloud/pkg/vsphere/provisioning/vm"
)
Expand All @@ -20,23 +21,23 @@ func TestExpanderVirtualServerNetworks(t *testing.T) {
map[string]interface{}{
"vlan_id": "38f8561acfe34qc49c336d2af31a5cc3",
"nic_type": "vmxnet3",
"ips": []interface{}{
"ips": schema.NewSet(schema.HashSchema(&schema.Schema{Type: schema.TypeString}), []interface{}{
"identifier1",
"identifier2",
"10.11.12.13",
"1.0.0.1",
},
}),
},
},
[]vm.Network{
{
VLAN: "38f8561acfe34qc49c336d2af31a5cc3",
NICType: "vmxnet3",
IPs: []string{
"identifier1",
"identifier2",
"10.11.12.13",
"1.0.0.1",
"identifier1",
"identifier2",
},
},
},
Expand Down

0 comments on commit 057bbb1

Please sign in to comment.