diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go index e0b2fcab9..be19338aa 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2.go @@ -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() diff --git a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go index 1c9d645c1..fe0a6b08a 100644 --- a/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go +++ b/builtin/providers/openstack/resource_openstack_networking_subnet_v2_test.go @@ -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" } } diff --git a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go index 896f13ed5..ec3769554 100644 --- a/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go +++ b/vendor/github.com/gophercloud/gophercloud/openstack/networking/v2/subnets/requests.go @@ -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. diff --git a/vendor/vendor.json b/vendor/vendor.json index 529d3491c..a348d09cb 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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=",