add versioning to files

This commit is contained in:
Jon Perritt 2015-01-26 11:09:27 -07:00
parent 8579c8693a
commit dc99dd1f05
11 changed files with 148 additions and 142 deletions

View File

@ -59,16 +59,16 @@ func Provider() terraform.ResourceProvider {
},
ResourcesMap: map[string]*schema.Resource{
"openstack_compute_instance": resourceComputeInstance(),
"openstack_compute_keypair": resourceComputeKeypair(),
"openstack_compute_secgroup": resourceComputeSecGroup(),
"openstack_compute_secgrouprule": resourceComputeSecGroupRule(),
"openstack_lb_member": resourceLBMember(),
"openstack_lb_monitor": resourceLBMonitor(),
"openstack_lb_pool": resourceLBPool(),
"openstack_lb_vip": resourceLBVip(),
"openstack_networking_network": resourceNetworkingNetwork(),
"openstack_networking_subnet": resourceNetworkingSubnet(),
"openstack_compute_instance_v2": resourceComputeInstanceV2(),
"openstack_compute_keypair_v2": resourceComputeKeypairV2(),
"openstack_compute_secgroup_v2": resourceComputeSecGroupV2(),
"openstack_compute_secgrouprule_v2": resourceComputeSecGroupRuleV2(),
"openstack_lb_member_v1": resourceLBMemberV1(),
"openstack_lb_monitor_v1": resourceLBMonitorV1(),
"openstack_lb_pool_v1": resourceLBPoolV1(),
"openstack_lb_vip_v1": resourceLBVipV1(),
"openstack_networking_network_v2": resourceNetworkingNetworkV2(),
"openstack_networking_subnet_v2": resourceNetworkingSubnetV2(),
},
ConfigureFunc: configureProvider,

View File

@ -16,12 +16,12 @@ import (
"github.com/rackspace/gophercloud/pagination"
)
func resourceComputeInstance() *schema.Resource {
func resourceComputeInstanceV2() *schema.Resource {
return &schema.Resource{
Create: resourceComputeInstanceCreate,
Read: resourceComputeInstanceRead,
Update: resourceComputeInstanceUpdate,
Delete: resourceComputeInstanceDelete,
Create: resourceComputeInstanceV2Create,
Read: resourceComputeInstanceV2Read,
Update: resourceComputeInstanceV2Update,
Delete: resourceComputeInstanceV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -116,7 +116,7 @@ func resourceComputeInstance() *schema.Resource {
}
}
func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -132,10 +132,10 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
Name: d.Get("name").(string),
ImageRef: d.Get("image_ref").(string),
FlavorRef: d.Get("flavor_ref").(string),
SecurityGroups: resourceInstanceSecGroups(d),
SecurityGroups: resourceInstanceSecGroupsV2(d),
AvailabilityZone: d.Get("availability_zone").(string),
Networks: resourceInstanceNetworks(d),
Metadata: resourceInstanceMetadata(d),
Networks: resourceInstanceNetworksV2(d),
Metadata: resourceInstanceMetadataV2(d),
ConfigDrive: d.Get("config_drive").(bool),
AdminPass: d.Get("admin_pass").(string),
}
@ -166,7 +166,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
stateConf := &resource.StateChangeConf{
Pending: []string{"BUILD"},
Target: "ACTIVE",
Refresh: ServerStateRefreshFunc(computeClient, server.ID),
Refresh: ServerV2StateRefreshFunc(computeClient, server.ID),
Timeout: 10 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
@ -179,10 +179,10 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
server.ID, err)
}
return resourceComputeInstanceRead(d, meta)
return resourceComputeInstanceV2Read(d, meta)
}
func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error {
func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -251,7 +251,7 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
return nil
}
func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -343,7 +343,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
stateConf := &resource.StateChangeConf{
Pending: []string{"RESIZE"},
Target: "VERIFY_RESIZE",
Refresh: ServerStateRefreshFunc(computeClient, d.Id()),
Refresh: ServerV2StateRefreshFunc(computeClient, d.Id()),
Timeout: 3 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
@ -364,7 +364,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
stateConf = &resource.StateChangeConf{
Pending: []string{"VERIFY_RESIZE"},
Target: "ACTIVE",
Refresh: ServerStateRefreshFunc(computeClient, d.Id()),
Refresh: ServerV2StateRefreshFunc(computeClient, d.Id()),
Timeout: 3 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
@ -376,10 +376,10 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
}
}
return resourceComputeInstanceRead(d, meta)
return resourceComputeInstanceV2Read(d, meta)
}
func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) error {
func resourceComputeInstanceV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -398,7 +398,7 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
stateConf := &resource.StateChangeConf{
Target: "",
Refresh: ServerStateRefreshFunc(computeClient, d.Id()),
Refresh: ServerV2StateRefreshFunc(computeClient, d.Id()),
Timeout: 10 * time.Minute,
Delay: 10 * time.Second,
MinTimeout: 3 * time.Second,
@ -417,7 +417,7 @@ func resourceComputeInstanceDelete(d *schema.ResourceData, meta interface{}) err
// ServerStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// an OpenStack instance.
func ServerStateRefreshFunc(client *gophercloud.ServiceClient, instanceID string) resource.StateRefreshFunc {
func ServerV2StateRefreshFunc(client *gophercloud.ServiceClient, instanceID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
s, err := servers.Get(client, instanceID).Extract()
if err != nil {
@ -428,7 +428,7 @@ func ServerStateRefreshFunc(client *gophercloud.ServiceClient, instanceID string
}
}
func resourceInstanceSecGroups(d *schema.ResourceData) []string {
func resourceInstanceSecGroupsV2(d *schema.ResourceData) []string {
rawSecGroups := d.Get("security_groups").(*schema.Set)
secgroups := make([]string, rawSecGroups.Len())
for i, raw := range rawSecGroups.List() {
@ -437,7 +437,7 @@ func resourceInstanceSecGroups(d *schema.ResourceData) []string {
return secgroups
}
func resourceInstanceNetworks(d *schema.ResourceData) []servers.Network {
func resourceInstanceNetworksV2(d *schema.ResourceData) []servers.Network {
rawNetworks := d.Get("networks").([]interface{})
networks := make([]servers.Network, len(rawNetworks))
for i, raw := range rawNetworks {
@ -451,7 +451,7 @@ func resourceInstanceNetworks(d *schema.ResourceData) []servers.Network {
return networks
}
func resourceInstanceMetadata(d *schema.ResourceData) map[string]string {
func resourceInstanceMetadataV2(d *schema.ResourceData) map[string]string {
m := make(map[string]string)
for key, val := range d.Get("metadata").(map[string]interface{}) {
m[key] = val.(string)

View File

@ -9,11 +9,11 @@ import (
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs"
)
func resourceComputeKeypair() *schema.Resource {
func resourceComputeKeypairV2() *schema.Resource {
return &schema.Resource{
Create: resourceComputeKeypairCreate,
Read: resourceComputeKeypairRead,
Delete: resourceComputeKeypairDelete,
Create: resourceComputeKeypairV2Create,
Read: resourceComputeKeypairV2Read,
Delete: resourceComputeKeypairV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -36,7 +36,7 @@ func resourceComputeKeypair() *schema.Resource {
}
}
func resourceComputeKeypairCreate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeKeypairV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -57,10 +57,10 @@ func resourceComputeKeypairCreate(d *schema.ResourceData, meta interface{}) erro
d.SetId(kp.Name)
return resourceComputeKeypairRead(d, meta)
return resourceComputeKeypairV2Read(d, meta)
}
func resourceComputeKeypairRead(d *schema.ResourceData, meta interface{}) error {
func resourceComputeKeypairV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -80,7 +80,7 @@ func resourceComputeKeypairRead(d *schema.ResourceData, meta interface{}) error
return nil
}
func resourceComputeKeypairDelete(d *schema.ResourceData, meta interface{}) error {
func resourceComputeKeypairV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -10,12 +10,12 @@ import (
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups"
)
func resourceComputeSecGroup() *schema.Resource {
func resourceComputeSecGroupV2() *schema.Resource {
return &schema.Resource{
Create: resourceComputeSecGroupCreate,
Read: resourceComputeSecGroupRead,
Update: resourceComputeSecGroupUpdate,
Delete: resourceComputeSecGroupDelete,
Create: resourceComputeSecGroupV2Create,
Read: resourceComputeSecGroupV2Read,
Update: resourceComputeSecGroupV2Update,
Delete: resourceComputeSecGroupV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -38,7 +38,7 @@ func resourceComputeSecGroup() *schema.Resource {
}
}
func resourceComputeSecGroupCreate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -59,10 +59,10 @@ func resourceComputeSecGroupCreate(d *schema.ResourceData, meta interface{}) err
d.SetId(sg.ID)
return resourceComputeSecGroupRead(d, meta)
return resourceComputeSecGroupV2Read(d, meta)
}
func resourceComputeSecGroupRead(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -82,7 +82,7 @@ func resourceComputeSecGroupRead(d *schema.ResourceData, meta interface{}) error
return nil
}
func resourceComputeSecGroupUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -106,10 +106,10 @@ func resourceComputeSecGroupUpdate(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error updating OpenStack security group (%s): %s", d.Id(), err)
}
return resourceComputeSecGroupRead(d, meta)
return resourceComputeSecGroupV2Read(d, meta)
}
func resourceComputeSecGroupDelete(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -9,11 +9,11 @@ import (
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups"
)
func resourceComputeSecGroupRule() *schema.Resource {
func resourceComputeSecGroupRuleV2() *schema.Resource {
return &schema.Resource{
Create: resourceComputeSecGroupRuleCreate,
Read: resourceComputeSecGroupRuleRead,
Delete: resourceComputeSecGroupRuleDelete,
Create: resourceComputeSecGroupRuleV2Create,
Read: resourceComputeSecGroupRuleV2Read,
Delete: resourceComputeSecGroupRuleV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -56,7 +56,7 @@ func resourceComputeSecGroupRule() *schema.Resource {
}
}
func resourceComputeSecGroupRuleCreate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupRuleV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -87,14 +87,14 @@ func resourceComputeSecGroupRuleCreate(d *schema.ResourceData, meta interface{})
d.Set("cidr", sgr.IPRange.CIDR)
d.Set("from_group_id", d.Get("from_group_id").(string))
return resourceComputeSecGroupRuleRead(d, meta)
return resourceComputeSecGroupRuleV2Read(d, meta)
}
func resourceComputeSecGroupRuleRead(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupRuleV2Read(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceComputeSecGroupRuleDelete(d *schema.ResourceData, meta interface{}) error {
func resourceComputeSecGroupRuleV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
computeClient, err := openstack.NewComputeV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -10,12 +10,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members"
)
func resourceLBMember() *schema.Resource {
func resourceLBMemberV1() *schema.Resource {
return &schema.Resource{
Create: resourceLBMemberCreate,
Read: resourceLBMemberRead,
Update: resourceLBMemberUpdate,
Delete: resourceLBMemberDelete,
Create: resourceLBMemberV1Create,
Read: resourceLBMemberV1Read,
Update: resourceLBMemberV1Update,
Delete: resourceLBMemberV1Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -53,7 +53,7 @@ func resourceLBMember() *schema.Resource {
}
}
func resourceLBMemberCreate(d *schema.ResourceData, meta interface{}) error {
func resourceLBMemberV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -78,10 +78,10 @@ func resourceLBMemberCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(p.ID)
return resourceLBMemberRead(d, meta)
return resourceLBMemberV1Read(d, meta)
}
func resourceLBMemberRead(d *schema.ResourceData, meta interface{}) error {
func resourceLBMemberV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -112,7 +112,7 @@ func resourceLBMemberRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceLBMemberUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceLBMemberV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -133,10 +133,10 @@ func resourceLBMemberUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error updating OpenStack LB Member: %s", err)
}
return resourceLBMemberRead(d, meta)
return resourceLBMemberV1Read(d, meta)
}
func resourceLBMemberDelete(d *schema.ResourceData, meta interface{}) error {
func resourceLBMemberV1Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors"
)
func resourceLBMonitor() *schema.Resource {
func resourceLBMonitorV1() *schema.Resource {
return &schema.Resource{
Create: resourceLBMonitorCreate,
Read: resourceLBMonitorRead,
Update: resourceLBMonitorUpdate,
Delete: resourceLBMonitorDelete,
Create: resourceLBMonitorV1Create,
Read: resourceLBMonitorV1Read,
Update: resourceLBMonitorV1Update,
Delete: resourceLBMonitorV1Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -74,7 +74,7 @@ func resourceLBMonitor() *schema.Resource {
}
}
func resourceLBMonitorCreate(d *schema.ResourceData, meta interface{}) error {
func resourceLBMonitorV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -112,10 +112,10 @@ func resourceLBMonitorCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(m.ID)
return resourceLBMonitorRead(d, meta)
return resourceLBMonitorV1Read(d, meta)
}
func resourceLBMonitorRead(d *schema.ResourceData, meta interface{}) error {
func resourceLBMonitorV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -179,7 +179,7 @@ func resourceLBMonitorRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceLBMonitorUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceLBMonitorV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -225,10 +225,10 @@ func resourceLBMonitorUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error updating OpenStack LB Monitor: %s", err)
}
return resourceLBMonitorRead(d, meta)
return resourceLBMonitorV1Read(d, meta)
}
func resourceLBMonitorDelete(d *schema.ResourceData, meta interface{}) error {
func resourceLBMonitorV1Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools"
)
func resourceLBPool() *schema.Resource {
func resourceLBPoolV1() *schema.Resource {
return &schema.Resource{
Create: resourceLBPoolCreate,
Read: resourceLBPoolRead,
Update: resourceLBPoolUpdate,
Delete: resourceLBPoolDelete,
Create: resourceLBPoolV1Create,
Read: resourceLBPoolV1Read,
Update: resourceLBPoolV1Update,
Delete: resourceLBPoolV1Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -64,7 +64,7 @@ func resourceLBPool() *schema.Resource {
}
}
func resourceLBPoolCreate(d *schema.ResourceData, meta interface{}) error {
func resourceLBPoolV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -90,7 +90,7 @@ func resourceLBPoolCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(p.ID)
if mIDs := resourcePoolMonitorIDs(d); mIDs != nil {
if mIDs := resourcePoolMonitorIDsV1(d); mIDs != nil {
for _, mID := range mIDs {
_, err := pools.AssociateMonitor(networkingClient, p.ID, mID).Extract()
if err != nil {
@ -99,10 +99,10 @@ func resourceLBPoolCreate(d *schema.ResourceData, meta interface{}) error {
}
}
return resourceLBPoolRead(d, meta)
return resourceLBPoolV1Read(d, meta)
}
func resourceLBPoolRead(d *schema.ResourceData, meta interface{}) error {
func resourceLBPoolV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -136,7 +136,7 @@ func resourceLBPoolRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceLBPoolUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceLBPoolV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -187,10 +187,10 @@ func resourceLBPoolUpdate(d *schema.ResourceData, meta interface{}) error {
}
}
return resourceLBPoolRead(d, meta)
return resourceLBPoolV1Read(d, meta)
}
func resourceLBPoolDelete(d *schema.ResourceData, meta interface{}) error {
func resourceLBPoolV1Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -208,7 +208,7 @@ func resourceLBPoolDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourcePoolMonitorIDs(d *schema.ResourceData) []string {
func resourcePoolMonitorIDsV1(d *schema.ResourceData) []string {
mIDsRaw := d.Get("monitor_ids").(*schema.Set)
mIDs := make([]string, mIDsRaw.Len())
for i, raw := range mIDsRaw.List() {

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips"
)
func resourceLBVip() *schema.Resource {
func resourceLBVipV1() *schema.Resource {
return &schema.Resource{
Create: resourceLBVipCreate,
Read: resourceLBVipRead,
Update: resourceLBVipUpdate,
Delete: resourceLBVipDelete,
Create: resourceLBVipV1Create,
Read: resourceLBVipV1Read,
Update: resourceLBVipV1Update,
Delete: resourceLBVipV1Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -84,7 +84,7 @@ func resourceLBVip() *schema.Resource {
}
}
func resourceLBVipCreate(d *schema.ResourceData, meta interface{}) error {
func resourceLBVipV1Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -102,7 +102,7 @@ func resourceLBVipCreate(d *schema.ResourceData, meta interface{}) error {
TenantID: d.Get("tenant_id").(string),
Address: d.Get("address").(string),
Description: d.Get("description").(string),
Persistence: resourceVipPersistence(d),
Persistence: resourceVipPersistenceV1(d),
ConnLimit: gophercloud.MaybeInt(d.Get("conn_limit").(int)),
}
@ -124,10 +124,10 @@ func resourceLBVipCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(p.ID)
return resourceLBVipRead(d, meta)
return resourceLBVipV1Read(d, meta)
}
func resourceLBVipRead(d *schema.ResourceData, meta interface{}) error {
func resourceLBVipV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -198,7 +198,7 @@ func resourceLBVipRead(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceLBVipUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceLBVipV1Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -218,7 +218,7 @@ func resourceLBVipUpdate(d *schema.ResourceData, meta interface{}) error {
updateOpts.Description = d.Get("description").(string)
}
if d.HasChange("persistence") {
updateOpts.Persistence = resourceVipPersistence(d)
updateOpts.Persistence = resourceVipPersistenceV1(d)
}
if d.HasChange("conn_limit") {
updateOpts.ConnLimit = gophercloud.MaybeInt(d.Get("conn_limit").(int))
@ -241,10 +241,10 @@ func resourceLBVipUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error updating OpenStack LB VIP: %s", err)
}
return resourceLBVipRead(d, meta)
return resourceLBVipV1Read(d, meta)
}
func resourceLBVipDelete(d *schema.ResourceData, meta interface{}) error {
func resourceLBVipV1Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -262,12 +262,18 @@ func resourceLBVipDelete(d *schema.ResourceData, meta interface{}) error {
return nil
}
func resourceVipPersistence(d *schema.ResourceData) *vips.SessionPersistence {
func resourceVipPersistenceV1(d *schema.ResourceData) *vips.SessionPersistence {
rawP := d.Get("persistence").(interface{})
rawMap := rawP.(map[string]interface{})
p := vips.SessionPersistence{
Type: rawMap["type"].(string),
CookieName: rawMap["cookie_name"].(string),
if rawMap != nil {
p := vips.SessionPersistence{}
if t, ok := rawMap["type"]; ok {
p.Type = t.(string)
}
if c, ok := rawMap["cookie_name"]; ok {
p.CookieName = c.(string)
}
return &p
}
return &p
return nil
}

View File

@ -11,12 +11,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
)
func resourceNetworkingNetwork() *schema.Resource {
func resourceNetworkingNetworkV2() *schema.Resource {
return &schema.Resource{
Create: resourceNetworkingNetworkCreate,
Read: resourceNetworkingNetworkRead,
Update: resourceNetworkingNetworkUpdate,
Delete: resourceNetworkingNetworkDelete,
Create: resourceNetworkingNetworkV2Create,
Read: resourceNetworkingNetworkV2Read,
Update: resourceNetworkingNetworkV2Update,
Delete: resourceNetworkingNetworkV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -49,7 +49,7 @@ func resourceNetworkingNetwork() *schema.Resource {
}
}
func resourceNetworkingNetworkCreate(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingNetworkV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -90,10 +90,10 @@ func resourceNetworkingNetworkCreate(d *schema.ResourceData, meta interface{}) e
d.SetId(n.ID)
return resourceNetworkingNetworkRead(d, meta)
return resourceNetworkingNetworkV2Read(d, meta)
}
func resourceNetworkingNetworkRead(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -144,7 +144,7 @@ func resourceNetworkingNetworkRead(d *schema.ResourceData, meta interface{}) err
return nil
}
func resourceNetworkingNetworkUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingNetworkV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -185,10 +185,10 @@ func resourceNetworkingNetworkUpdate(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error updating OpenStack Neutron Network: %s", err)
}
return resourceNetworkingNetworkRead(d, meta)
return resourceNetworkingNetworkV2Read(d, meta)
}
func resourceNetworkingNetworkDelete(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingNetworkV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),

View File

@ -12,12 +12,12 @@ import (
"github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
)
func resourceNetworkingSubnet() *schema.Resource {
func resourceNetworkingSubnetV2() *schema.Resource {
return &schema.Resource{
Create: resourceNetworkingSubnetCreate,
Read: resourceNetworkingSubnetRead,
Update: resourceNetworkingSubnetUpdate,
Delete: resourceNetworkingSubnetDelete,
Create: resourceNetworkingSubnetV2Create,
Read: resourceNetworkingSubnetV2Read,
Update: resourceNetworkingSubnetV2Update,
Delete: resourceNetworkingSubnetV2Delete,
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
@ -108,7 +108,7 @@ func resourceNetworkingSubnet() *schema.Resource {
}
}
func resourceNetworkingSubnetCreate(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingSubnetV2Create(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -122,11 +122,11 @@ func resourceNetworkingSubnetCreate(d *schema.ResourceData, meta interface{}) er
CIDR: d.Get("cidr").(string),
Name: d.Get("name").(string),
TenantID: d.Get("tenant_id").(string),
AllocationPools: resourceSubnetAllocationPools(d),
AllocationPools: resourceSubnetAllocationPoolsV2(d),
GatewayIP: d.Get("gateway_ip").(string),
IPVersion: d.Get("ip_version").(int),
DNSNameservers: resourceSubnetDNSNameservers(d),
HostRoutes: resourceSubnetHostRoutes(d),
DNSNameservers: resourceSubnetDNSNameserversV2(d),
HostRoutes: resourceSubnetHostRoutesV2(d),
}
edRaw := d.Get("enable_dhcp").(string)
@ -147,10 +147,10 @@ func resourceNetworkingSubnetCreate(d *schema.ResourceData, meta interface{}) er
d.SetId(s.ID)
return resourceNetworkingSubnetRead(d, meta)
return resourceNetworkingSubnetV2Read(d, meta)
}
func resourceNetworkingSubnetRead(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -217,7 +217,7 @@ func resourceNetworkingSubnetRead(d *schema.ResourceData, meta interface{}) erro
return nil
}
func resourceNetworkingSubnetUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingSubnetV2Update(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -237,11 +237,11 @@ func resourceNetworkingSubnetUpdate(d *schema.ResourceData, meta interface{}) er
}
if d.HasChange("dns_nameservers") {
updateOpts.DNSNameservers = resourceSubnetDNSNameservers(d)
updateOpts.DNSNameservers = resourceSubnetDNSNameserversV2(d)
}
if d.HasChange("host_routes") {
updateOpts.HostRoutes = resourceSubnetHostRoutes(d)
updateOpts.HostRoutes = resourceSubnetHostRoutesV2(d)
}
if d.HasChange("enable_dhcp") {
@ -262,10 +262,10 @@ func resourceNetworkingSubnetUpdate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error updating OpenStack Neutron Subnet: %s", err)
}
return resourceNetworkingSubnetRead(d, meta)
return resourceNetworkingSubnetV2Read(d, meta)
}
func resourceNetworkingSubnetDelete(d *schema.ResourceData, meta interface{}) error {
func resourceNetworkingSubnetV2Delete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := openstack.NewNetworkV2(config.osClient, gophercloud.EndpointOpts{
Region: d.Get("region").(string),
@ -283,7 +283,7 @@ func resourceNetworkingSubnetDelete(d *schema.ResourceData, meta interface{}) er
return nil
}
func resourceSubnetAllocationPools(d *schema.ResourceData) []subnets.AllocationPool {
func resourceSubnetAllocationPoolsV2(d *schema.ResourceData) []subnets.AllocationPool {
rawAPs := d.Get("allocation_pools").([]interface{})
aps := make([]subnets.AllocationPool, len(rawAPs))
for i, raw := range rawAPs {
@ -296,7 +296,7 @@ func resourceSubnetAllocationPools(d *schema.ResourceData) []subnets.AllocationP
return aps
}
func resourceSubnetDNSNameservers(d *schema.ResourceData) []string {
func resourceSubnetDNSNameserversV2(d *schema.ResourceData) []string {
rawDNSN := d.Get("dns_nameservers").(*schema.Set)
dnsn := make([]string, rawDNSN.Len())
for i, raw := range rawDNSN.List() {
@ -305,7 +305,7 @@ func resourceSubnetDNSNameservers(d *schema.ResourceData) []string {
return dnsn
}
func resourceSubnetHostRoutes(d *schema.ResourceData) []subnets.HostRoute {
func resourceSubnetHostRoutesV2(d *schema.ResourceData) []subnets.HostRoute {
rawHR := d.Get("host_routes").([]interface{})
hr := make([]subnets.HostRoute, len(rawHR))
for i, raw := range rawHR {