Exclude unused attributes from compute and RG schemas
This commit is contained in:
@@ -35,6 +35,8 @@ import (
|
||||
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||
)
|
||||
|
||||
// Parse list of all disks from API compute/get into a list of "extra disks" attached to this compute
|
||||
// Extra disks are all compute disks but a boot disk.
|
||||
func parseComputeDisksToExtraDisks(disks []DiskRecord) []interface{} {
|
||||
// this return value will be used to d.Set("extra_disks",) item of dataSourceCompute schema,
|
||||
// which is a simple list of integer disk IDs excluding boot disk ID
|
||||
@@ -68,7 +70,9 @@ func parseComputeDisksToExtraDisks(disks []DiskRecord) []interface{} {
|
||||
}
|
||||
|
||||
func parseComputeDisks(disks []DiskRecord) []interface{} {
|
||||
// return value was designed to d.Set("disks",) item of dataSourceCompute schema
|
||||
// Return value was designed to d.Set("disks",) item of dataSourceCompute schema
|
||||
// However, this item was excluded from the schema as it is not directly
|
||||
// managed through Terraform
|
||||
length := len(disks)
|
||||
log.Debugf("parseComputeDisks: called for %d disks", length)
|
||||
|
||||
@@ -132,6 +136,8 @@ func parseBootDiskSize(disks []DiskRecord) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Parse the list of interfaces from compute/get response into a list of networks
|
||||
// attached to this compute
|
||||
func parseComputeInterfacesToNetworks(ifaces []InterfaceRecord) []interface{} {
|
||||
// return value will be used to d.Set("networks",) item of dataSourceCompute schema
|
||||
length := len(ifaces)
|
||||
@@ -160,6 +166,8 @@ func parseComputeInterfacesToNetworks(ifaces []InterfaceRecord) []interface{} {
|
||||
|
||||
func parseComputeInterfaces(ifaces []InterfaceRecord) []interface{} {
|
||||
// return value was designed to d.Set("interfaces",) item of dataSourceCompute schema
|
||||
// However, this item was excluded from the schema as it is not directly
|
||||
// managed through Terraform
|
||||
length := len(ifaces)
|
||||
log.Debugf("parseComputeInterfaces: called for %d ifaces", length)
|
||||
|
||||
@@ -231,25 +239,27 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
|
||||
d.Set("tech_status", model.TechStatus)
|
||||
|
||||
if len(model.Disks) > 0 {
|
||||
log.Debugf("flattenCompute: calling parseComputeDisks for %d disks", len(model.Disks))
|
||||
log.Debugf("flattenCompute: calling parseComputeDisksToExtraDisks for %d disks", len(model.Disks))
|
||||
if err = d.Set("extra_disks", parseComputeDisksToExtraDisks(model.Disks)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(model.Interfaces) > 0 {
|
||||
log.Debugf("flattenCompute: calling parseComputeInterfaces for %d interfaces", len(model.Interfaces))
|
||||
log.Debugf("flattenCompute: calling parseComputeInterfacesToNetworks for %d interfaces", len(model.Interfaces))
|
||||
if err = d.Set("networks", parseComputeInterfacesToNetworks(model.Interfaces)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -390,7 +400,6 @@ func dataSourceCompute() *schema.Resource {
|
||||
},
|
||||
Description: "Specification for the virtual NICs configured on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"guest_logins": {
|
||||
Type: schema.TypeList,
|
||||
@@ -400,6 +409,7 @@ func dataSourceCompute() *schema.Resource {
|
||||
},
|
||||
Description: "Details about the guest OS users provisioned together with this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -60,8 +60,10 @@ func flattenResgroup(d *schema.ResourceData, rg_facts string) error {
|
||||
d.Set("status", details.Status)
|
||||
d.Set("def_net_type", details.DefaultNetType)
|
||||
d.Set("def_net_id", details.DefaultNetID)
|
||||
/*
|
||||
d.Set("vins", details.Vins)
|
||||
d.Set("computes", details.Computes)
|
||||
*/
|
||||
|
||||
log.Debugf("flattenResgroup: calling flattenQuota()")
|
||||
if err = d.Set("quota", parseQuota(details.Quota)); err != nil {
|
||||
@@ -159,6 +161,7 @@ func dataSourceResgroup() *schema.Resource {
|
||||
Description: "ID of the default network for this resource group (if any).",
|
||||
},
|
||||
|
||||
/*
|
||||
"vins": {
|
||||
Type: schema.TypeList, // this is a list of ints
|
||||
Computed: true,
|
||||
@@ -177,6 +180,7 @@ func dataSourceResgroup() *schema.Resource {
|
||||
},
|
||||
Description: "List of computes deployed in this resource group.",
|
||||
},
|
||||
*/
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +359,6 @@ func resourceCompute() *schema.Resource {
|
||||
},
|
||||
Description: "Specification for the virtual NICs configured on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"guest_logins": {
|
||||
Type: schema.TypeList,
|
||||
@@ -369,6 +368,7 @@ func resourceCompute() *schema.Resource {
|
||||
},
|
||||
Description: "Specification for guest logins on this compute instance.",
|
||||
},
|
||||
*/
|
||||
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -82,7 +82,7 @@ func resourceResgroupCreate(d *schema.ResourceData, m interface{}) error {
|
||||
if set_quota {
|
||||
url_values.Add("maxCPUCapacity", fmt.Sprintf("%d", quota_record.Cpu))
|
||||
url_values.Add("maxVDiskCapacity", fmt.Sprintf("%d", quota_record.Disk))
|
||||
url_values.Add("maxMemoryCapacity", fmt.Sprintf("%d", quota_record.Ram))
|
||||
url_values.Add("maxMemoryCapacity", fmt.Sprintf("%f", quota_record.Ram)) // RAM quota is float; this may change in the future
|
||||
url_values.Add("maxNetworkPeerTransfer", fmt.Sprintf("%d", quota_record.ExtTraffic))
|
||||
url_values.Add("maxNumPublicIP", fmt.Sprintf("%d", quota_record.ExtIPs))
|
||||
// url_values.Add("???", fmt.Sprintf("%d", quota_record.GpuUnits))
|
||||
@@ -353,6 +353,7 @@ func resourceResgroup() *schema.Resource {
|
||||
Description: "Current status of this resource group.",
|
||||
},
|
||||
|
||||
/*
|
||||
"vins": {
|
||||
Type: schema.TypeList, // this is a list of ints
|
||||
Computed: true,
|
||||
@@ -371,6 +372,7 @@ func resourceResgroup() *schema.Resource {
|
||||
},
|
||||
Description: "List of computes deployed in this resource group.",
|
||||
},
|
||||
*/
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user