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