go fmt
This commit is contained in:
parent
d51ee3111e
commit
5d2fe153c0
|
@ -22,19 +22,19 @@ func Provider() terraform.ResourceProvider {
|
||||||
DefaultFunc: envDefaultFunc("OS_USERNAME"),
|
DefaultFunc: envDefaultFunc("OS_USERNAME"),
|
||||||
},
|
},
|
||||||
"user_id": &schema.Schema{
|
"user_id": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
"tenant_id": &schema.Schema{
|
"tenant_id": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
"tenant_name": &schema.Schema{
|
"tenant_name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
"password": &schema.Schema{
|
"password": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -42,19 +42,19 @@ func Provider() terraform.ResourceProvider {
|
||||||
DefaultFunc: envDefaultFunc("OS_PASSWORD"),
|
DefaultFunc: envDefaultFunc("OS_PASSWORD"),
|
||||||
},
|
},
|
||||||
"api_key": &schema.Schema{
|
"api_key": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
"domain_id": &schema.Schema{
|
"domain_id": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
"domain_name": &schema.Schema{
|
"domain_name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ func resourceComputeInstanceV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -125,7 +124,6 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
||||||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var createOpts servers.CreateOptsBuilder
|
var createOpts servers.CreateOptsBuilder
|
||||||
|
|
||||||
serverCreateOpts := &servers.CreateOpts{
|
serverCreateOpts := &servers.CreateOpts{
|
||||||
|
@ -228,20 +226,16 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
|
||||||
|
|
||||||
d.Set("metadata", server.Metadata)
|
d.Set("metadata", server.Metadata)
|
||||||
|
|
||||||
var currentSG []string
|
|
||||||
err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
|
err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
|
||||||
secGrpList, err := secgroups.ExtractSecurityGroups(page)
|
secGrpList, err := secgroups.ExtractSecurityGroups(page)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("Error setting security groups for OpenStack server: %s", err)
|
return false, fmt.Errorf("Error getting security groups for OpenStack server: %s", err)
|
||||||
}
|
}
|
||||||
|
for i, sg := range secGrpList {
|
||||||
for _, sg := range secGrpList {
|
d.Set(fmt.Sprintf("security_groups.%d", i), sg.Name)
|
||||||
currentSG = append(currentSG, sg.Name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
})
|
})
|
||||||
d.Set("security_groups", currentSG)
|
|
||||||
|
|
||||||
newFlavor, ok := server.Flavor["id"].(string)
|
newFlavor, ok := server.Flavor["id"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -272,11 +266,11 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
|
||||||
updateOpts.AccessIPv4 = d.Get("access_ip_v6").(string)
|
updateOpts.AccessIPv4 = d.Get("access_ip_v6").(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Updating Server %s with options: %+v", d.Id(), updateOpts)
|
if updateOpts != (servers.UpdateOpts{}) {
|
||||||
|
_, err := servers.Update(computeClient, d.Id(), updateOpts).Extract()
|
||||||
_, err = servers.Update(computeClient, d.Id(), updateOpts).Extract()
|
if err != nil {
|
||||||
if err != nil {
|
return fmt.Errorf("Error updating OpenStack server: %s", err)
|
||||||
return fmt.Errorf("Error updating OpenStack server: %s", err)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("metadata") {
|
if d.HasChange("metadata") {
|
||||||
|
|
|
@ -20,7 +20,6 @@ func resourceComputeKeypairV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
|
@ -22,7 +22,6 @@ func resourceComputeSecGroupV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -93,7 +92,7 @@ func resourceComputeSecGroupV2Update(d *schema.ResourceData, meta interface{}) e
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOpts := secgroups.UpdateOpts{
|
updateOpts := secgroups.UpdateOpts{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
Description: d.Get("description").(string),
|
Description: d.Get("description").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform/helper/hashcode"
|
"github.com/hashicorp/terraform/helper/hashcode"
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/rackspace/gophercloud"
|
"github.com/rackspace/gophercloud"
|
||||||
"github.com/rackspace/gophercloud/openstack"
|
"github.com/rackspace/gophercloud/openstack"
|
||||||
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools"
|
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools"
|
||||||
|
|
|
@ -20,10 +20,9 @@ func resourceNetworkingNetworkV2() *schema.Resource {
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"region": &schema.Schema{
|
"region": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform/helper/hashcode"
|
"github.com/hashicorp/terraform/helper/hashcode"
|
||||||
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/rackspace/gophercloud"
|
"github.com/rackspace/gophercloud"
|
||||||
"github.com/rackspace/gophercloud/openstack"
|
"github.com/rackspace/gophercloud/openstack"
|
||||||
"github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
|
"github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
|
||||||
|
@ -24,7 +24,6 @@ func resourceNetworkingSubnetV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
|
|
||||||
},
|
},
|
||||||
"network_id": &schema.Schema{
|
"network_id": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
|
Loading…
Reference in New Issue