Add support for updating the External Gateway assigned to a Neutron router.
Added a simple acceptance test, but doesn't work.
This commit is contained in:
parent
3481d1bf6e
commit
b9eaa23f60
|
@ -213,6 +213,15 @@ func resourceNetworkingRouterV2Update(d *schema.ResourceData, meta interface{})
|
|||
asu := d.Get("admin_state_up").(bool)
|
||||
updateOpts.AdminStateUp = &asu
|
||||
}
|
||||
if d.HasChange("external_gateway") {
|
||||
externalGateway := d.Get("external_gateway").(string)
|
||||
if externalGateway != "" {
|
||||
gatewayInfo := routers.GatewayInfo{
|
||||
NetworkID: externalGateway,
|
||||
}
|
||||
updateOpts.GatewayInfo = &gatewayInfo
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Updating Router %s with options: %+v", d.Id(), updateOpts)
|
||||
|
||||
|
|
|
@ -34,6 +34,30 @@ func TestAccNetworkingV2Router_basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccNetworkingV2Router_update_external_gw(t *testing.T) {
|
||||
var router routers.Router
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckNetworkingV2RouterDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccNetworkingV2Router_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckNetworkingV2RouterExists(t, "openstack_networking_router_v2.foo", &router),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccNetworkingV2Router_update_external_gw,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_networking_router_v2.foo", "external_gateway", "d730db50-0e0c-4790-9972-1f6e2b8c4915"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckNetworkingV2RouterDestroy(s *terraform.State) error {
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
|
@ -100,3 +124,11 @@ var testAccNetworkingV2Router_update = fmt.Sprintf(`
|
|||
admin_state_up = "true"
|
||||
distributed = "false"
|
||||
}`)
|
||||
|
||||
var testAccNetworkingV2Router_update_external_gw = fmt.Sprintf(`
|
||||
resource "openstack_networking_router_v2" "foo" {
|
||||
name = "router"
|
||||
admin_state_up = "true"
|
||||
distributed = "false"
|
||||
external_gateway = "d730db50-0e0c-4790-9972-1f6e2b8c4915"
|
||||
}`)
|
||||
|
|
Loading…
Reference in New Issue