Merge branch 'olakar_g-network-import' of https://github.com/skalle/terraform into skalle-olakar_g-network-import
This commit is contained in:
commit
1913d72212
|
@ -0,0 +1,65 @@
|
||||||
|
package google
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccComputeNetwork_importBasic(t *testing.T) {
|
||||||
|
resourceName := "google_compute_network.foobar"
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeNetworkDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccComputeNetwork_basic,
|
||||||
|
}, {
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
//ImportStateVerifyIgnore: []string{"ipv4_range", "name"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccComputeNetwork_importAuto_subnet(t *testing.T) {
|
||||||
|
resourceName := "google_compute_network.bar"
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeNetworkDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccComputeNetwork_auto_subnet,
|
||||||
|
}, {
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccComputeNetwork_importCustom_subnet(t *testing.T) {
|
||||||
|
resourceName := "google_compute_network.baz"
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeNetworkDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccComputeNetwork_custom_subnet,
|
||||||
|
}, {
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -14,6 +14,9 @@ func resourceComputeNetwork() *schema.Resource {
|
||||||
Create: resourceComputeNetworkCreate,
|
Create: resourceComputeNetworkCreate,
|
||||||
Read: resourceComputeNetworkRead,
|
Read: resourceComputeNetworkRead,
|
||||||
Delete: resourceComputeNetworkDelete,
|
Delete: resourceComputeNetworkDelete,
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
|
@ -142,6 +145,9 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
d.Set("gateway_ipv4", network.GatewayIPv4)
|
d.Set("gateway_ipv4", network.GatewayIPv4)
|
||||||
d.Set("self_link", network.SelfLink)
|
d.Set("self_link", network.SelfLink)
|
||||||
|
d.Set("ipv4_range", network.IPv4Range)
|
||||||
|
d.Set("name", network.Name)
|
||||||
|
d.Set("auto_create_subnetworks", network.AutoCreateSubnetworks)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue