4.4.1
This commit is contained in:
@@ -49,6 +49,7 @@ func dataSourceRgAffinityGroupsListRead(ctx context.Context, d *schema.ResourceD
|
||||
|
||||
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
|
||||
d.Set("affinity_groups", flattenRgListGroups(list))
|
||||
d.Set("entry_count", list.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -59,6 +60,16 @@ func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "ID of the RG",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"affinity_groups": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -78,6 +89,10 @@ func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceRGResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
RGResourceConsumptionRec, err := utilityRGResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
flattenRGResourceConsumption(d, RGResourceConsumptionRec)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceRGResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceRGResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceRGResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceResourceLimitsSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceRGResourceConsumptionGet() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceRGResourceConsumptionGetRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceRGResourceConsumptionGetSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -78,17 +78,17 @@ func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Optional: true,
|
||||
Description: "Filter by ViNS ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceRGResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
rgResourceConsumptionList, err := utilityRGResourceConsumptionListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenRGResourceConsumptionList(rgResourceConsumptionList))
|
||||
d.Set("entry_count", rgResourceConsumptionList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceRGResourceConsumptionListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceRGResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceRGResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceResourceLimitsSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceSepsSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"sep_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"data_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size_max": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceRGResourceSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"disk_size_max": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"extips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"exttraffic": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gpu": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"seps": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceSepsSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func dataSourceResourceLimitsSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"cu_c": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_d": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_dm": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_i": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_m": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"cu_np": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
"gpu_units": {
|
||||
Type: schema.TypeFloat,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceRGResourceConsumptionList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceRGResourceConsumptionListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceRGResourceConsumptionListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
)
|
||||
|
||||
func flattenAccountSeps(seps map[string]map[string]DiskUsage) []map[string]interface{} {
|
||||
func flattenRGSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for sepKey, sepVal := range seps {
|
||||
for dataKey, dataVal := range sepVal {
|
||||
@@ -57,31 +57,31 @@ func flattenAccountSeps(seps map[string]map[string]DiskUsage) []map[string]inter
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenAccResource(r Resource) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": r.CPU,
|
||||
"disksize": r.DiskSize,
|
||||
"extips": r.ExtIPs,
|
||||
"exttraffic": r.ExtTraffic,
|
||||
"gpu": r.GPU,
|
||||
"ram": r.RAM,
|
||||
"seps": flattenAccountSeps(r.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
// func flattenAccResource(r Resource) []map[string]interface{} {
|
||||
// res := make([]map[string]interface{}, 0)
|
||||
// temp := map[string]interface{}{
|
||||
// "cpu": r.CPU,
|
||||
// "disksize": r.DiskSize,
|
||||
// "extips": r.ExtIPs,
|
||||
// "exttraffic": r.ExtTraffic,
|
||||
// "gpu": r.GPU,
|
||||
// "ram": r.RAM,
|
||||
// "seps": flattenRgSeps(r.SEPs),
|
||||
// }
|
||||
// res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
// return res
|
||||
// }
|
||||
|
||||
func flattenRgResources(r Resources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"current": flattenAccResource(r.Current),
|
||||
"reserved": flattenAccResource(r.Reserved),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
// func flattenRgResources(r Resources) []map[string]interface{} {
|
||||
// res := make([]map[string]interface{}, 0)
|
||||
// temp := map[string]interface{}{
|
||||
// "current": flattenAccResource(r.Current),
|
||||
// "reserved": flattenAccResource(r.Reserved),
|
||||
// }
|
||||
// res = append(res, temp)
|
||||
// return res
|
||||
// }
|
||||
|
||||
func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) error {
|
||||
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
|
||||
@@ -122,7 +122,7 @@ func flattenResgroup(d *schema.ResourceData, details rg.RecordResourceGroup) err
|
||||
}
|
||||
|
||||
func flattenRgSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(seps))
|
||||
for sepKey, sepVal := range seps {
|
||||
SepMap := map[string]interface{}{}
|
||||
for dataKey, dataVal := range sepVal {
|
||||
@@ -140,7 +140,6 @@ func flattenRgSeps(seps map[string]map[string]rg.DiskUsage) []map[string]interfa
|
||||
|
||||
func flattenResource(resource rg.Resource) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
|
||||
temp := map[string]interface{}{
|
||||
"cpu": resource.CPU,
|
||||
"disk_size": resource.DiskSize,
|
||||
@@ -149,7 +148,7 @@ func flattenResource(resource rg.Resource) []map[string]interface{} {
|
||||
"exttraffic": resource.ExtTraffic,
|
||||
"gpu": resource.GPU,
|
||||
"ram": resource.RAM,
|
||||
"seps": flattenRgSeps(resource.SEPs),
|
||||
"seps": flattenRGSeps(resource.SEPs),
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
@@ -191,7 +190,7 @@ func flattenRg(d *schema.ResourceData, itemRg rg.RecordResourceGroup) {
|
||||
}
|
||||
|
||||
func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(rgAudits))
|
||||
for _, rgAudit := range rgAudits {
|
||||
temp := map[string]interface{}{
|
||||
"call": rgAudit.Call,
|
||||
@@ -208,7 +207,7 @@ func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(rgl.Data))
|
||||
for _, rg := range rgl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_acl": flattenRgAcl(rg.ACL),
|
||||
@@ -249,7 +248,7 @@ func flattenRgList(rgl *rg.ListResourceGroups) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgAcl(rgAcls rg.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(rgAcls))
|
||||
for _, rgAcl := range rgAcls {
|
||||
temp := map[string]interface{}{
|
||||
"explicit": rgAcl.Explicit,
|
||||
@@ -281,7 +280,7 @@ func flattenRgResourceLimits(rl rg.ResourceLimits) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRules(list rg.ListRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list))
|
||||
for _, rule := range list {
|
||||
temp := map[string]interface{}{
|
||||
"guid": rule.GUID,
|
||||
@@ -299,7 +298,7 @@ func flattenRules(list rg.ListRules) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgListComputes(lc *rg.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(lc.Data))
|
||||
for _, compute := range lc.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": compute.AccountID,
|
||||
@@ -351,7 +350,7 @@ func flattenServerSettings(settings rg.RecordServerSettings) []map[string]interf
|
||||
}
|
||||
|
||||
func flattenListServers(list rg.ListServers) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list))
|
||||
for _, serv := range list {
|
||||
temp := map[string]interface{}{
|
||||
"address": serv.Address,
|
||||
@@ -368,7 +367,7 @@ func flattenListServers(list rg.ListServers) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenBackends(b rg.ListBackends) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(b))
|
||||
for _, item := range b {
|
||||
temp := map[string]interface{}{
|
||||
"algorithm": item.Algorithm,
|
||||
@@ -383,7 +382,7 @@ func flattenBackends(b rg.ListBackends) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenBindings(list rg.ListBindings) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list))
|
||||
for _, bind := range list {
|
||||
temp := map[string]interface{}{
|
||||
"address": bind.Address,
|
||||
@@ -398,7 +397,7 @@ func flattenBindings(list rg.ListBindings) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenFrontends(list rg.ListFrontends) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list))
|
||||
for _, front := range list {
|
||||
temp := map[string]interface{}{
|
||||
"backend": front.Backend,
|
||||
@@ -427,7 +426,7 @@ func flattenNode(node rg.RecordNode) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgListLb(listLb *rg.ListLB) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(listLb.Data))
|
||||
for _, lb := range listLb.Data {
|
||||
temp := map[string]interface{}{
|
||||
"ha_mode": lb.HAMode,
|
||||
@@ -462,7 +461,7 @@ func flattenRgListLb(listLb *rg.ListLB) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgListPfw(listPfw *rg.ListPortForwards) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (listPfw.Data))
|
||||
for _, pfw := range listPfw.Data {
|
||||
temp := map[string]interface{}{
|
||||
"public_port_end": pfw.PublicPortEnd,
|
||||
@@ -481,7 +480,7 @@ func flattenRgListPfw(listPfw *rg.ListPortForwards) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(lv.Data))
|
||||
for _, vins := range lv.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": vins.AccountID,
|
||||
@@ -509,7 +508,7 @@ func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenRgAffinityGroupComputes(list rg.ListAffinityGroupsComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list))
|
||||
|
||||
for _, item := range list {
|
||||
temp := map[string]interface{}{
|
||||
@@ -527,18 +526,18 @@ func flattenRgAffinityGroupComputes(list rg.ListAffinityGroupsComputes) []map[st
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRgAffinityGroupsGet(list []uint64) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"items": list,
|
||||
}
|
||||
res = append(res, temp)
|
||||
// func flattenRgAffinityGroupsGet(list []uint64) []map[string]interface{} {
|
||||
// res := make([]map[string]interface{}, 0)
|
||||
// temp := map[string]interface{}{
|
||||
// "items": list,
|
||||
// }
|
||||
// res = append(res, temp)
|
||||
|
||||
return res
|
||||
}
|
||||
// return res
|
||||
// }
|
||||
|
||||
func flattenRgListGroups(list *rg.ListAffinityGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list.Data))
|
||||
for groupKey, groupVal := range list.Data {
|
||||
temp := map[string]interface{}{
|
||||
"label": groupKey,
|
||||
@@ -560,3 +559,24 @@ func flattenRgUsageResource(d *schema.ResourceData, usage rg.RecordResourceUsage
|
||||
d.Set("ram", usage.RAM)
|
||||
d.Set("seps", flattenRgSeps(usage.SEPs))
|
||||
}
|
||||
|
||||
func flattenRGResourceConsumptionList(rg *rg.ListResourceConsumption) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rg.Data))
|
||||
for _, rc := range rg.Data {
|
||||
temp := map[string]interface{}{
|
||||
"consumed": flattenResource(rc.Consumed),
|
||||
"reserved": flattenResource(rc.Reserved),
|
||||
"resource_limits": flattenRgResourceLimits(rc.ResourceLimits),
|
||||
"rg_id": rc.RGID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRGResourceConsumption(d *schema.ResourceData, rg *rg.ItemResourceConsumption) {
|
||||
d.Set("consumed", flattenResource(rg.Consumed))
|
||||
d.Set("reserved", flattenResource(rg.Reserved))
|
||||
d.Set("resource_limits", flattenRgResourceLimits(rg.ResourceLimits))
|
||||
d.Set("rg_id", rg.RGID)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,14 @@ func utilityRgAffinityGroupsListCheckPresence(ctx context.Context, d *schema.Res
|
||||
RGID: uint64(d.Get("rg_id").(int)),
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
groups, err := c.CloudAPI().RG().AffinityGroupsList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityRGResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ItemResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
id := uint64(d.Get("rg_id").(int))
|
||||
|
||||
req := rg.GetResourceConsumptionRequest{
|
||||
RGID: id,
|
||||
}
|
||||
|
||||
log.Debugf("utilityRGResourceConsumptionGetCheckPresence: load")
|
||||
accountResourceConsumptionRec, err := c.CloudAPI().RG().GetResourceConsumption(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountResourceConsumptionRec, nil
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityRGResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
log.Debugf("utilityRGResourceConsumptionListCheckPresence: load")
|
||||
rgResourceConsumptionList, err := c.CloudAPI().RG().ListResourceConsumption(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rgResourceConsumptionList, nil
|
||||
}
|
||||
Reference in New Issue
Block a user