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:
parent
e5dcaf7f79
commit
da8f71d4c2
|
@ -58,7 +58,6 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
||||||
"allocation_pools": &schema.Schema{
|
"allocation_pools": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
@ -293,6 +292,10 @@ func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{})
|
||||||
updateOpts.EnableDHCP = &v
|
updateOpts.EnableDHCP = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.HasChange("allocation_pools") {
|
||||||
|
updateOpts.AllocationPools = resourceSubnetAllocationPoolsV2(d)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)
|
log.Printf("[DEBUG] Updating Subnet %s with options: %+v", d.Id(), updateOpts)
|
||||||
|
|
||||||
_, err = subnets.Update(networkingClient, d.Id(), updateOpts).Extract()
|
_, err = subnets.Update(networkingClient, d.Id(), updateOpts).Extract()
|
||||||
|
|
|
@ -22,6 +22,8 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) {
|
||||||
Config: testAccNetworkingV2Subnet_basic,
|
Config: testAccNetworkingV2Subnet_basic,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckNetworkingV2SubnetExists("openstack_networking_subnet_v2.subnet_1", &subnet),
|
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{
|
resource.TestStep{
|
||||||
|
@ -33,6 +35,8 @@ func TestAccNetworkingV2Subnet_basic(t *testing.T) {
|
||||||
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
"openstack_networking_subnet_v2.subnet_1", "gateway_ip", "192.168.199.1"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"openstack_networking_subnet_v2.subnet_1", "enable_dhcp", "true"),
|
"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}"
|
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||||
|
|
||||||
allocation_pools {
|
allocation_pools {
|
||||||
start = "192.168.199.100"
|
start = "192.168.199.150"
|
||||||
end = "192.168.199.200"
|
end = "192.168.199.200"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ type UpdateOptsBuilder interface {
|
||||||
// UpdateOpts represents the attributes used when updating an existing subnet.
|
// UpdateOpts represents the attributes used when updating an existing subnet.
|
||||||
type UpdateOpts struct {
|
type UpdateOpts struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
AllocationPools []AllocationPool `json:"allocation_pools,omitempty"`
|
||||||
GatewayIP *string `json:"gateway_ip,omitempty"`
|
GatewayIP *string `json:"gateway_ip,omitempty"`
|
||||||
DNSNameservers []string `json:"dns_nameservers,omitempty"`
|
DNSNameservers []string `json:"dns_nameservers,omitempty"`
|
||||||
HostRoutes []HostRoute `json:"host_routes,omitempty"`
|
HostRoutes []HostRoute `json:"host_routes,omitempty"`
|
||||||
|
|
|
@ -1853,10 +1853,10 @@
|
||||||
"revisionTime": "2017-03-10T01:59:53Z"
|
"revisionTime": "2017-03-10T01:59:53Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "wY0MY7RpX0Z2Y0rMmrAuYS6cHYA=",
|
"checksumSHA1": "mNRf4F3OjUIivhWTPZD/FjJNuCk=",
|
||||||
"path": "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets",
|
"path": "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets",
|
||||||
"revision": "0f64da0e36de86a0ca1a8f2fc1b0570a0d3f7504",
|
"revision": "4f943e86d0a2c2e1c5c040e00a1358079c0881a1",
|
||||||
"revisionTime": "2017-03-10T01:59:53Z"
|
"revisionTime": "2017-05-24T02:11:01Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "LtdQKIKKRKe6FOGdBvrBz/bg1Gc=",
|
"checksumSHA1": "LtdQKIKKRKe6FOGdBvrBz/bg1Gc=",
|
||||||
|
|
Loading…
Reference in New Issue