This commit is contained in:
Jon Perritt 2015-01-26 15:45:05 -07:00
parent d51ee3111e
commit 5d2fe153c0
7 changed files with 32 additions and 42 deletions

View File

@ -22,19 +22,19 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: envDefaultFunc("OS_USERNAME"),
},
"user_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"tenant_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"tenant_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"password": &schema.Schema{
Type: schema.TypeString,
@ -42,19 +42,19 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: envDefaultFunc("OS_PASSWORD"),
},
"api_key": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"domain_id": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"domain_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "",
Type: schema.TypeString,
Optional: true,
Default: "",
},
},

View File

@ -28,7 +28,6 @@ func resourceComputeInstanceV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
},
"name": &schema.Schema{
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)
}
var createOpts servers.CreateOptsBuilder
serverCreateOpts := &servers.CreateOpts{
@ -228,20 +226,16 @@ func resourceComputeInstanceV2Read(d *schema.ResourceData, meta interface{}) err
d.Set("metadata", server.Metadata)
var currentSG []string
err = secgroups.ListByServer(computeClient, d.Id()).EachPage(func(page pagination.Page) (bool, error) {
secGrpList, err := secgroups.ExtractSecurityGroups(page)
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 _, sg := range secGrpList {
currentSG = append(currentSG, sg.Name)
for i, sg := range secGrpList {
d.Set(fmt.Sprintf("security_groups.%d", i), sg.Name)
}
return true, nil
})
d.Set("security_groups", currentSG)
newFlavor, ok := server.Flavor["id"].(string)
if !ok {
@ -272,11 +266,11 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e
updateOpts.AccessIPv4 = d.Get("access_ip_v6").(string)
}
log.Printf("[DEBUG] Updating Server %s with options: %+v", d.Id(), updateOpts)
_, err = servers.Update(computeClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack server: %s", err)
if updateOpts != (servers.UpdateOpts{}) {
_, err := servers.Update(computeClient, d.Id(), updateOpts).Extract()
if err != nil {
return fmt.Errorf("Error updating OpenStack server: %s", err)
}
}
if d.HasChange("metadata") {

View File

@ -20,7 +20,6 @@ func resourceComputeKeypairV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -22,7 +22,6 @@ func resourceComputeSecGroupV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,
@ -93,7 +92,7 @@ func resourceComputeSecGroupV2Update(d *schema.ResourceData, meta interface{}) e
}
updateOpts := secgroups.UpdateOpts{
Name: d.Get("name").(string),
Name: d.Get("name").(string),
Description: d.Get("description").(string),
}

View File

@ -4,8 +4,8 @@ import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools"

View File

@ -20,10 +20,9 @@ func resourceNetworkingNetworkV2() *schema.Resource {
Schema: map[string]*schema.Schema{
"region": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -5,8 +5,8 @@ import (
"log"
"strconv"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
"github.com/rackspace/gophercloud/openstack/networking/v2/subnets"
@ -24,7 +24,6 @@ func resourceNetworkingSubnetV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
},
"network_id": &schema.Schema{
Type: schema.TypeString,