provider/openstack: Add support for updating Subnet Allocation Pools (#14782)

* vendor: Updating Gophercloud for OpenStack Provider

* provider/openstack: Add support for updating Subnet Allocation Pools

This commit adds the ability to update a subnet's allocation pool.
This commit is contained in:
Joe Topjian 2017-05-24 04:38:05 -06:00 committed by Paul Stack
parent e5dcaf7f79
commit da8f71d4c2
4 changed files with 18 additions and 10 deletions

View File

@ -58,7 +58,6 @@ func resourceNetworkingSubnetV2() *schema.Resource {
"allocation_pools": &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
@ -293,6 +292,10 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{})
updateOpts.EnableDHCP = &v
}
if d.HasChange("allocation_pools") {
updateOpts.AllocationPools = resourceSubnetAllocationPoolsV2(d)
}
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)
_, err = subnets.Update(networkingClient, d.Id(), updateOpts).Extract()

View File

@ -22,6 +22,8 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) {
Config: testAccNetworkingV2Subnet_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
resource.TestCheckResourceAttr(
"openstack_networking_subnet_v2.subnet_1", "allocation_pools.0.start", "192.168.199.100"),
),
},
resource.TestStep{
@ -33,6 +35,8 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) {
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
resource.TestCheckResourceAttr(
"openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
resource.TestCheckResourceAttr(
"openstack_networking_subnet_v2.subnet_1", "allocation_pools.0.start", "192.168.199.150"),
),
},
},
@ -220,7 +224,7 @@ resource "openstack_networking_subnet_v2" "subnet_1" {
network_id = "${openstack_networking_network_v2.network_1.id}"
allocation_pools {
start = "192.168.199.100"
start = "192.168.199.150"
end = "192.168.199.200"
}
}

View File

@ -120,11 +120,12 @@ type UpdateOptsBuilder interface {
// UpdateOpts represents the attributes used when updating an existing subnet.
type UpdateOpts struct {
Name string `json:"name,omitempty"`
GatewayIP *string `json:"gateway_ip,omitempty"`
DNSNameservers []string `json:"dns_nameservers,omitempty"`
HostRoutes []HostRoute `json:"host_routes,omitempty"`
EnableDHCP *bool `json:"enable_dhcp,omitempty"`
Name string `json:"name,omitempty"`
AllocationPools []AllocationPool `json:"allocation_pools,omitempty"`
GatewayIP *string `json:"gateway_ip,omitempty"`
DNSNameservers []string `json:"dns_nameservers,omitempty"`
HostRoutes []HostRoute `json:"host_routes,omitempty"`
EnableDHCP *bool `json:"enable_dhcp,omitempty"`
}
// ToSubnetUpdateMap casts an UpdateOpts struct to a map.

6
vendor/vendor.json vendored
View File

@ -1853,10 +1853,10 @@
"revisionTime": "2017-03-10T01:59:53Z"
},
{
"checksumSHA1": "wY0MY7RpX0Z2Y0rMmrAuYS6cHYA=",
"checksumSHA1": "mNRf4F3OjUIivhWTPZD/FjJNuCk=",
"path": "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets",
"revision": "0f64da0e36de86a0ca1a8f2fc1b0570a0d3f7504",
"revisionTime": "2017-03-10T01:59:53Z"
"revision": "4f943e86d0a2c2e1c5c040e00a1358079c0881a1",
"revisionTime": "2017-05-24T02:11:01Z"
},
{
"checksumSHA1": "LtdQKIKKRKe6FOGdBvrBz/bg1Gc=",