add defaultFuncs; fix bug with server createOpts
This commit is contained in:
parent
e6f3a19284
commit
59b5efc25a
|
@ -39,11 +39,13 @@ func resourceComputeInstanceV2() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
|
DefaultFunc: envDefaultFunc("OS_IMAGE_ID"),
|
||||||
},
|
},
|
||||||
"flavor_ref": &schema.Schema{
|
"flavor_ref": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
|
DefaultFunc: envDefaultFunc("OS_FLAVOR_ID"),
|
||||||
},
|
},
|
||||||
"security_groups": &schema.Schema{
|
"security_groups": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
|
@ -127,7 +129,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
|
||||||
|
|
||||||
var createOpts servers.CreateOptsBuilder
|
var createOpts servers.CreateOptsBuilder
|
||||||
|
|
||||||
serverCreateOpts := &servers.CreateOpts{
|
createOpts = &servers.CreateOpts{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
ImageRef: d.Get("image_ref").(string),
|
ImageRef: d.Get("image_ref").(string),
|
||||||
FlavorRef: d.Get("flavor_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 != "" {
|
if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" {
|
||||||
createOpts = &keypairs.CreateOptsExt{
|
createOpts = &keypairs.CreateOptsExt{
|
||||||
serverCreateOpts,
|
createOpts,
|
||||||
keyName,
|
keyName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue