Chris Buben 2015-03-20 18:55:42 -04:00 committed by Jon Perritt
parent 2e37784065
commit 0092946f74
1 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package openstack
import (
"bytes"
"crypto/sha1"
"encoding/hex"
"fmt"
"log"
"time"
@ -75,6 +77,21 @@ func resourceComputeInstanceV2() *schema.Resource {
Optional: true,
ForceNew: false,
},
"user_data": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
// just stash the hash for state & diff comparisons
StateFunc: func(v interface{}) string {
switch v.(type) {
case string:
hash := sha1.Sum([]byte(v.(string)))
return hex.EncodeToString(hash[:])
default:
return ""
}
},
},
"security_groups": &schema.Schema{
Type: schema.TypeList,
Optional: true,
@ -224,6 +241,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e
Metadata: resourceInstanceMetadataV2(d),
ConfigDrive: d.Get("config_drive").(bool),
AdminPass: d.Get("admin_pass").(string),
UserData: []byte(d.Get("user_data").(string)),
}
if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" {