Skip to content

Commit

Permalink
Merge pull request #1477 from vmware/fix-vpc-ip-allocation
Browse files Browse the repository at this point in the history
Allow updating IP allocation under project or VPC
  • Loading branch information
annakhm authored Dec 5, 2024
2 parents 68e74c2 + c5b171f commit 2413c69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions nsxt/resource_nsxt_policy_project_ip_address_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func resourceNsxtPolicyProjectIpAddressAllocationUpdate(d *schema.ResourceData,
Revision: &revision,
}

elem := reflect.ValueOf(&obj).Elem()
if err := metadata.SchemaToStruct(elem, d, projectIpAddressAllocationSchema, "", nil); err != nil {
return err
}

// Only the above attributes can be updated, others force recreation
client := clientLayer.NewIpAddressAllocationsClient(connector)
_, err := client.Update(parents[0], parents[1], id, obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestAccResourceNsxtPolicyProjectIpAddressAllocation_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
),
},
/* TODO - enable when/if IP allocation update is supported on NSX
{
Config: testAccNsxtPolicyProjectIpAddressAllocationTemplate(false),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -73,7 +72,7 @@ func TestAccResourceNsxtPolicyProjectIpAddressAllocation_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(testResourceName, "revision"),
resource.TestCheckResourceAttr(testResourceName, "tag.#", "0"),
),
},*/
},
},
})
}
Expand Down Expand Up @@ -176,7 +175,7 @@ resource "nsxt_policy_project_ip_address_allocation" "test" {
data "nsxt_policy_project_ip_address_allocation" "test" {
%s
ip_allocations = nsxt_policy_project_ip_address_allocation.ip_allocations
allocation_ips = nsxt_policy_project_ip_address_allocation.test.allocation_ips
}`, os.Getenv("NSXT_VPC_PROJECT_ID"), testAccNsxtProjectContext(), attrMap["display_name"], attrMap["description"], attrMap["allocation_size"], testAccNsxtProjectContext())
}

Expand All @@ -195,6 +194,6 @@ resource "nsxt_policy_project_ip_address_allocation" "test" {
data "nsxt_policy_project_ip_address_allocation" "test" {
%s
ip_allocations = nsxt_policy_project_ip_address_allocation.ip_allocations
allocation_ips = nsxt_policy_project_ip_address_allocation.test.allocation_ips
}`, os.Getenv("NSXT_VPC_PROJECT_ID"), testAccNsxtProjectContext(), accTestProjectIpAddressAllocationUpdateAttributes["display_name"], accTestProjectIpAddressAllocationUpdateAttributes["allocation_size"], testAccNsxtProjectContext())
}
4 changes: 1 addition & 3 deletions nsxt/resource_nsxt_vpc_ip_address_allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var accTestVpcIpAddressAllocationCreateAttributes = map[string]string{
var accTestVpcIpAddressAllocationUpdateAttributes = map[string]string{
"display_name": getAccTestResourceName(),
"description": "terraform updated",
"allocation_size": "1",
"allocation_size": "2",
}

func TestAccResourceNsxtVpcIpAddressAllocation_basic(t *testing.T) {
Expand Down Expand Up @@ -48,7 +48,6 @@ func TestAccResourceNsxtVpcIpAddressAllocation_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
),
},
/* For now, UPDATE is not supported for this resource
{
Config: testAccNsxtVpcIpAddressAllocationTemplate(false),
Check: resource.ComposeTestCheckFunc(
Expand All @@ -75,7 +74,6 @@ func TestAccResourceNsxtVpcIpAddressAllocation_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "tag.#", "0"),
),
},
*/
},
})
}
Expand Down

0 comments on commit 2413c69

Please sign in to comment.