Add guest OS user login data to compute providers
This commit is contained in:
@@ -258,14 +258,12 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if len(model.OsUsers) > 0 {
|
||||
log.Debugf("flattenCompute: calling parseGuestLogins for %d logins", len(model.OsUsers))
|
||||
if err = d.Set("guest_logins", parseGuestLogins(model.OsUsers)); err != nil {
|
||||
log.Debugf("flattenCompute: calling parseOsUsers for %d logins", len(model.OsUsers))
|
||||
if err = d.Set("guest_logins", parseOsUsers(model.OsUsers)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -412,16 +410,16 @@ func dataSourceCompute() *schema.Resource {
|
||||
},
|
||||
Description: "Specification for the virtual NICs configured on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"guest_logins": {
|
||||
"os_users": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: loginsSubresourceSchemaMake(),
|
||||
Schema: osUsersSubresourceSchemaMake(),
|
||||
},
|
||||
Description: "Details about the guest OS users provisioned together with this compute instance.",
|
||||
Description: "Guest OS users provisioned on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||
)
|
||||
|
||||
func parseGuestLogins(logins []OsUserRecord) []interface{} {
|
||||
func parseOsUsers(logins []OsUserRecord) []interface{} {
|
||||
var result = make([]interface{}, len(logins))
|
||||
|
||||
elem := make(map[string]interface{})
|
||||
@@ -35,41 +35,37 @@ func parseGuestLogins(logins []OsUserRecord) []interface{} {
|
||||
elem["password"] = value.Password
|
||||
elem["public_key"] = value.PubKey
|
||||
result[index] = elem
|
||||
log.Debugf("parseGuestLogins: parsed element %d - login %q", index, value.Login)
|
||||
log.Debugf("parseOsUsers: parsed element %d - login %q", index, value.Login)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func loginsSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
func osUsersSubresourceSchemaMake() map[string]*schema.Schema {
|
||||
rets := map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Computed: true,
|
||||
Description: "GUID of this guest OS user.",
|
||||
},
|
||||
|
||||
"login": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Computed: true,
|
||||
Description: "Login name of this guest OS user.",
|
||||
},
|
||||
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Computed: true,
|
||||
Sensitive: true,
|
||||
Description: "Password of this guest OS user.",
|
||||
},
|
||||
|
||||
"public_key": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Default: "",
|
||||
Description: "SSH public key of this guest user.",
|
||||
Computed: true,
|
||||
Description: "SSH public key of this guest OS user.",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -430,6 +430,15 @@ func resourceCompute() *schema.Resource {
|
||||
Description: "This compute instance boot disk ID.",
|
||||
},
|
||||
|
||||
"os_users": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: osUsersSubresourceSchemaMake(),
|
||||
},
|
||||
Description: "Guest OS users provisioned on this compute instance.",
|
||||
},
|
||||
|
||||
/*
|
||||
"disks": {
|
||||
Type: schema.TypeList,
|
||||
@@ -449,14 +458,6 @@ func resourceCompute() *schema.Resource {
|
||||
Description: "Specification for the virtual NICs configured on this compute instance.",
|
||||
},
|
||||
|
||||
"guest_logins": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: loginsSubresourceSchemaMake(),
|
||||
},
|
||||
Description: "Specification for guest logins on this compute instance.",
|
||||
},
|
||||
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
Reference in New Issue
Block a user