provider/openstack: Support Import of OpenStack LBaaS V1 Resources (#7660)

This commit is contained in:
Joe Topjian 2016-07-15 02:49:31 -06:00 committed by Paul Stack
parent bc5a8b827f
commit f7da261294
8 changed files with 141 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package openstack
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccOpenStackLBMemberV1_importBasic(t *testing.T) {
resourceName := "openstack_lb_member_v1.member_1"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLBV1MemberDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccLBV1Member_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}

View File

@ -0,0 +1,29 @@
package openstack
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccOpenStackLBMonitorV1_importBasic(t *testing.T) {
resourceName := "openstack_lb_monitor_v1.monitor_1"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLBV1MonitorDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccLBV1Monitor_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}

View File

@ -0,0 +1,29 @@
package openstack
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccOpenStackLBPoolV1_importBasic(t *testing.T) {
resourceName := "openstack_lb_pool_v1.pool_1"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLBV1PoolDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccLBV1Pool_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}

View File

@ -0,0 +1,29 @@
package openstack
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccOpenStackLBVIPV1_importBasic(t *testing.T) {
resourceName := "openstack_lb_vip_v1.vip_1"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLBV1VIPDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccLBV1VIP_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}

View File

@ -18,6 +18,9 @@ func resourceLBMemberV1() *schema.Resource {
Read: resourceLBMemberV1Read,
Update: resourceLBMemberV1Update,
Delete: resourceLBMemberV1Delete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -128,6 +131,9 @@ func resourceLBMemberV1Read(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Retreived OpenStack LB member %s: %+v", d.Id(), m)
d.Set("address", m.Address)
d.Set("pool_id", m.PoolID)
d.Set("port", m.ProtocolPort)
d.Set("weight", m.Weight)
d.Set("admin_state_up", m.AdminStateUp)

View File

@ -19,6 +19,9 @@ func resourceLBMonitorV1() *schema.Resource {
Read: resourceLBMonitorV1Read,
Update: resourceLBMonitorV1Update,
Delete: resourceLBMonitorV1Delete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"region": &schema.Schema{

View File

@ -22,6 +22,9 @@ func resourceLBPoolV1() *schema.Resource {
Read: resourceLBPoolV1Read,
Update: resourceLBPoolV1Update,
Delete: resourceLBPoolV1Delete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"region": &schema.Schema{

View File

@ -18,6 +18,9 @@ func resourceLBVipV1() *schema.Resource {
Read: resourceLBVipV1Read,
Update: resourceLBVipV1Update,
Delete: resourceLBVipV1Delete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -182,6 +185,16 @@ func resourceLBVipV1Read(d *schema.ResourceData, meta interface{}) error {
d.Set("conn_limit", p.ConnLimit)
d.Set("admin_state_up", p.AdminStateUp)
// Set the persistence method being used
persistence := make(map[string]interface{})
if p.Persistence.Type != "" {
persistence["type"] = p.Persistence.Type
}
if p.Persistence.CookieName != "" {
persistence["cookie_name"] = p.Persistence.CookieName
}
d.Set("persistence", persistence)
return nil
}