4.5.0-alpha
This commit is contained in:
@@ -15,9 +15,10 @@ func flattenGrid(d *schema.ResourceData, grid *grid.RecordGrid) {
|
||||
}
|
||||
|
||||
func flattenGridList(gl *grid.ListGrids) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(gl.Data))
|
||||
for _, item := range gl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"resources": flattenGridResources(item.Resources),
|
||||
"name": item.Name,
|
||||
"flag": item.Flag,
|
||||
"gid": item.GID,
|
||||
@@ -25,8 +26,62 @@ func flattenGridList(gl *grid.ListGrids) []map[string]interface{} {
|
||||
"location_code": item.LocationCode,
|
||||
"id": item.ID,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridListConsumption(gl *grid.ListResourceConsumption) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(gl.Data))
|
||||
for _, item := range gl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"consumed": flattenGridRecordResource(item.Consumed),
|
||||
"reserved": flattenGridRecordResource(item.Reserved),
|
||||
"id": item.GID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridResources(r grid.Resources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"current": flattenGridRecordResource(r.Current),
|
||||
"reserved": flattenGridRecordResource(r.Reserved),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridRecordResource(rr grid.RecordResource) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": rr.CPU,
|
||||
"disk_size": rr.DiskSize,
|
||||
"disk_size_max": rr.DiskSizeMax,
|
||||
"ext_ips": rr.ExtIPs,
|
||||
"ext_traffic": rr.ExtTraffic,
|
||||
"gpu": rr.GPU,
|
||||
"ram": rr.RAM,
|
||||
"seps": flattenGridSeps(rr.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenGridSeps(seps map[string]map[string]grid.DiskUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for sepKey, sepVal := range seps {
|
||||
for dataKey, dataVal := range sepVal {
|
||||
temp := map[string]interface{}{
|
||||
"sep_id": sepKey,
|
||||
"data_name": dataKey,
|
||||
"disk_size": dataVal.DiskSize,
|
||||
"disk_size_max": dataVal.DiskSizeMax,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user