provider/openstack: Support Import openstack_compute_keypair_v2 (#7346)

This commit is contained in:
Joe Topjian 2016-07-03 09:39:20 -06:00 committed by Paul Stack
parent 713c0daa52
commit 480542d2ab
3 changed files with 33 additions and 3 deletions

View File

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

View File

@ -13,6 +13,9 @@ func resourceComputeKeypairV2() *schema.Resource {
Create: resourceComputeKeypairV2Create,
Read: resourceComputeKeypairV2Read,
Delete: resourceComputeKeypairV2Delete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"region": &schema.Schema{

View File

@ -83,8 +83,6 @@ func testAccCheckComputeV2KeypairExists(t *testing.T, n string, kp *keypairs.Key
var testAccComputeV2Keypair_basic = fmt.Sprintf(`
resource "openstack_compute_keypair_v2" "foo" {
region = "%s"
name = "test-keypair-tf"
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAjpC1hwiOCCmKEWxJ4qzTTsJbKzndLo1BCz5PcwtUnflmU+gHJtWMZKpuEGVi29h0A/+ydKek1O18k10Ff+4tyFjiHDQAT9+OfgWf7+b1yK+qDip3X1C0UPMbwHlTfSGWLGZquwhvEFx9k3h/M+VtMvwR1lJ9LUyTAImnNjWG7TAIPmui30HvM2UiFEmqkr4ijq45MyX2+fLIePLRIFuu1p4whjHAQYufqyno3BS48icQb4p6iVEZPo4AE2o9oIyQvj2mx4dk5Y8CgSETOZTYDOR3rU2fZTRDRgPJDH9FWvQjF5tA0p3d9CoWWd2s6GKKbfoUIi8R/Db1BSPJwkqB jrp-hp-pc"
}`,
OS_REGION_NAME)
}`)