add defaultFuncs; fix bug with server createOpts

This commit is contained in:
Jon Perritt 2015-01-26 22:35:18 -07:00
parent e6f3a19284
commit 59b5efc25a
1 changed files with 4 additions and 2 deletions

View File

@ -39,11 +39,13 @@ func resourceComputeInstanceV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: false,
DefaultFunc: envDefaultFunc("OS_IMAGE_ID"),
},
"flavor_ref": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: false,
DefaultFunc: envDefaultFunc("OS_FLAVOR_ID"),
},
"security_groups": &schema.Schema{
Type: schema.TypeSet,
@ -127,7 +129,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
var createOpts servers.CreateOptsBuilder
serverCreateOpts := &servers.CreateOpts{
createOpts = &servers.CreateOpts{
Name: d.Get("name").(string),
ImageRef: d.Get("image_ref").(string),
FlavorRef: d.Get("flavor_ref").(string),
@ -141,7 +143,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" {
createOpts = &keypairs.CreateOptsExt{
serverCreateOpts,
createOpts,
keyName,
}
}