This commit is contained in:
2023-12-18 18:55:52 +03:00
parent e2ee45ee14
commit 20050bc169
213 changed files with 37547 additions and 2873 deletions

View File

@@ -0,0 +1,70 @@
/*
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 {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
flattenRGResourceConsumption(d, RGResourceConsumptionRec)
return nil
}
func DataSourceRGResourceConsumptionGet() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRGResourceConsumptionGetRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRGResourceConsumptionGetSchemaMake(),
}
}

View File

@@ -0,0 +1,72 @@
/*
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 dataSourceRgListComputesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listComputes, err := utilityRgListComputesCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenRgListComputes(listComputes))
d.Set("entry_count", listComputes.EntryCount)
return nil
}
func DataSourceRgListComputes() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgListComputesRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgListComputesSchemaMake(),
}
}

View File

@@ -0,0 +1,72 @@
/*
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 dataSourceRgListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
rgList, err := utilityRgListDeletedCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenRgList(rgList))
d.Set("entry_count", rgList.EntryCount)
return nil
}
func DataSourceRgListDeleted() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgListDeletedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgListDeletedSchemaMake(),
}
}

View File

@@ -0,0 +1,71 @@
/*
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"
"strconv"
"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 dataSourceRgListLbRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listLb, err := utilityRgListLbCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
d.Set("items", flattenRgListLb(listLb))
d.Set("entry_count", listLb.EntryCount)
return nil
}
func DataSourceRgListLb() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgListLbRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgListLbSchemaMake(),
}
}

View File

@@ -0,0 +1,71 @@
/*
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"
"strconv"
"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 dataSourceRgListPfwRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listPfw, err := utilityRgListPfwCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
d.Set("items", flattenRgListPfw(listPfw))
d.Set("entry_count", listPfw.EntryCount)
return nil
}
func DataSourceRgListPfw() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgListPfwRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgListPfwSchemaMake(),
}
}

View File

@@ -0,0 +1,71 @@
/*
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"
"strconv"
"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 dataSourceRgListVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
listVins, err := utilityRgListVinsCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
d.Set("items", flattenRgListVins(listVins))
d.Set("entry_count", listVins.EntryCount)
return nil
}
func DataSourceRgListVins() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgListVinsRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgListVinsSchemaMake(),
}
}

View File

@@ -0,0 +1,71 @@
/*
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 {
d.SetId("")
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 DataSourceRGResourceConsumptionList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRGResourceConsumptionListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRGResourceConsumptionListSchemaMake(),
}
}

View File

@@ -0,0 +1,69 @@
/*
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"
"strconv"
"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 dataSourceRgUsageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
usage, err := utilityDataRgUsageCheckPresence(ctx, d, m)
if err != nil {
d.SetId("")
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("rg_id").(int)))
flattenRgUsageResource(d, *usage)
return nil
}
func DataSourceRgUsage() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceRgUsageRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceRgUsageSchemaMake(),
}
}

View File

@@ -0,0 +1,498 @@
package rg
import (
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
)
func flattenResgroup(d *schema.ResourceData, rgData *rg.RecordRG) {
log.Debugf("flattenResgroup: decoded RG name %q / ID %d, account ID %d",
rgData.Name, rgData.ID, rgData.AccountID)
d.Set("account_id", rgData.AccountID)
d.Set("account_name", rgData.AccountName)
d.Set("acl", flattenRgAcl(rgData.ACL))
d.Set("cpu_allocation_parameter", rgData.CPUAllocationParameter)
d.Set("cpu_allocation_ratio", rgData.CPUAllocationRatio)
d.Set("created_by", rgData.CreatedBy)
d.Set("created_time", rgData.CreatedTime)
d.Set("def_net_id", rgData.DefNetID)
d.Set("def_net_type", rgData.DefNetType)
d.Set("deleted_by", rgData.DeletedBy)
d.Set("deleted_time", rgData.DeletedTime)
d.Set("desc", rgData.Description)
d.Set("dirty", rgData.Dirty)
d.Set("gid", rgData.GID)
d.Set("guid", rgData.GUID)
d.Set("rg_id", rgData.ID)
d.Set("lock_status", rgData.LockStatus)
d.Set("milestones", rgData.Milestones)
d.Set("name", rgData.Name)
d.Set("register_computes", rgData.RegisterComputes)
d.Set("resource_limits", flattenRgResourceLimits(rgData.ResourceLimits))
d.Set("resource_types", rgData.ResTypes)
d.Set("secret", rgData.Secret)
d.Set("status", rgData.Status)
d.Set("uniq_pools", rgData.UniqPools)
d.Set("updated_by", rgData.UpdatedBy)
d.Set("updated_time", rgData.UpdatedTime)
d.Set("vins", rgData.VINS)
d.Set("computes", rgData.VMs)
}
func flattenRgAcl(rgACLs rg.ListACL) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rgACLs))
for _, acl := range rgACLs {
temp := map[string]interface{}{
"explicit": acl.Explicit,
"guid": acl.GUID,
"right": acl.Right,
"status": acl.Status,
"type": acl.Type,
"user_group_id": acl.UserGroupID,
}
res = append(res, temp)
}
return res
}
func flattenRgResourceLimits(rl rg.ResourceLimits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cu_c": rl.CUC,
"cu_d": rl.CuD,
"cu_dm": rl.CUDM,
"cu_i": rl.CUI,
"cu_m": rl.CUM,
"cu_np": rl.CUNP,
"gpu_units": rl.GPUUnits,
}
res = append(res, temp)
return res
}
func flattenRgAudits(rgAudits rg.ListAudits) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rgAudits))
for _, rgAudit := range rgAudits {
temp := map[string]interface{}{
"call": rgAudit.Call,
"responsetime": rgAudit.ResponseTime,
"statuscode": rgAudit.StatusCode,
"timestamp": rgAudit.Timestamp,
"user": rgAudit.User,
}
res = append(res, temp)
}
return res
}
func flattenRgListGroups(list *rg.ListAffinityGroup) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list.Data))
for _, item := range list.Data {
for key, vals := range item {
for _, v := range vals {
temp := map[string]interface{}{
"label": key,
"id": v.ID,
"node_id": v.NodeID,
}
res = append(res, temp)
}
}
}
return res
}
func flattenRgAffinityGroupComputes(list rg.ListAffinityGroupCompute) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, item := range list {
temp := map[string]interface{}{
"compute_id": item.ComputeID,
"other_node": item.OtherNode,
"other_node_indirect": item.OtherNodeIndirect,
"other_node_indirect_soft": item.OtherNodeIndirectSoft,
"other_node_soft": item.OtherNodeSoft,
"same_node": item.SameNode,
"same_node_soft": item.SameNodeSoft,
}
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)
}
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 flattenRgUsageResource(d *schema.ResourceData, usage rg.Reservation) {
d.Set("cpu", usage.CPU)
d.Set("disk_size", usage.DiskSize)
d.Set("disk_size_max", usage.DiskSizeMax)
d.Set("extips", usage.ExtIPs)
d.Set("exttraffic", usage.ExtTraffic)
d.Set("gpu", usage.GPU)
d.Set("ram", usage.RAM)
d.Set("seps", flattenRGSeps(usage.SEPs))
}
func flattenResource(resource rg.Reservation) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cpu": resource.CPU,
"disk_size": resource.DiskSize,
"disk_size_max": resource.DiskSizeMax,
"extips": resource.ExtIPs,
"exttraffic": resource.ExtTraffic,
"gpu": resource.GPU,
"ram": resource.RAM,
"seps": flattenRGSeps(resource.SEPs),
}
res = append(res, temp)
return res
}
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 {
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
}
func flattenRgListComputes(lc *rg.ListComputes) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lc.Data))
for _, compute := range lc.Data {
temp := map[string]interface{}{
"account_id": compute.AccountID,
"account_name": compute.AccountName,
"affinity_label": compute.AffinityLabel,
"affinity_rules": flattenRules(compute.AffinityRules),
"affinity_weight": compute.AffinityWeight,
"antiaffinity_rules": flattenRules(compute.AntiAffinityRules),
"cpus": compute.CPUs,
"created_by": compute.CreatedBy,
"created_time": compute.CreatedTime,
"deleted_by": compute.DeletedBy,
"deleted_time": compute.DeletedTime,
"id": compute.ID,
"name": compute.Name,
"ram": compute.RAM,
"registered": compute.Registered,
"rg_id": compute.RGID,
"rg_name": compute.RGName,
"status": compute.Status,
"tech_status": compute.TechStatus,
"total_disks_size": compute.TotalDisksSize,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vins_connected": compute.VINSConnected,
}
res = append(res, temp)
}
return res
}
func flattenRules(list rg.ListRules) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, rule := range list {
temp := map[string]interface{}{
"guid": rule.GUID,
"key": rule.Key,
"mode": rule.Mode,
"policy": rule.Policy,
"topology": rule.Topology,
"value": rule.Value,
}
res = append(res, temp)
}
return res
}
func flattenRgListLb(listLb *rg.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(listLb.Data))
for _, lb := range listLb.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"acl": lb.ACL,
"backends": flattenBackends(lb.Backends),
"created_by": lb.CreatedBy,
"created_time": lb.CreatedTime,
"deleted_by": lb.DeletedBy,
"deleted_time": lb.DeletedTime,
"desc": lb.Description,
"dp_api_user": lb.DPAPIUser,
"extnet_id": lb.ExtNetID,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"id": lb.ID,
"image_id": lb.ImageID,
"milestones": lb.Milestones,
"name": lb.Name,
"primary_node": flattenNode(lb.PrimaryNode),
"rg_name": lb.RGName,
"secondary_node": flattenNode(lb.SecondaryNode),
"status": lb.Status,
"tech_status": lb.TechStatus,
"updated_by": lb.UpdatedBy,
"updated_time": lb.UpdatedTime,
"vins_id": lb.VINSID,
}
res = append(res, temp)
}
return res
}
func flattenNode(node rg.RecordNode) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"backend_ip": node.BackendIP,
"compute_id": node.ComputeID,
"frontend_ip": node.FrontendIP,
"guid": node.GUID,
"mgmt_ip": node.MGMTIP,
"network_id": node.NetworkID,
}
res = append(res, temp)
return res
}
func flattenFrontends(list rg.ListFrontends) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, front := range list {
temp := map[string]interface{}{
"backend": front.Backend,
"bindings": flattenBindings(front.Bindings),
"guid": front.GUID,
"name": front.Name,
}
res = append(res, temp)
}
return res
}
func flattenBindings(list rg.ListBindings) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, bind := range list {
temp := map[string]interface{}{
"address": bind.Address,
"guid": bind.GUID,
"name": bind.Name,
"port": bind.Port,
}
res = append(res, temp)
}
return res
}
func flattenBackends(b rg.ListBackends) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(b))
for _, item := range b {
temp := map[string]interface{}{
"algorithm": item.Algorithm,
"guid": item.GUID,
"name": item.Name,
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
"servers": flattenListServers(item.Servers),
}
res = append(res, temp)
}
return res
}
func flattenListServers(list rg.ListServers) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(list))
for _, serv := range list {
temp := map[string]interface{}{
"address": serv.Address,
"check": serv.Check,
"guid": serv.GUID,
"name": serv.Name,
"port": serv.Port,
"server_settings": flattenServerSettings(serv.ServerSettings),
}
res = append(res, temp)
}
return res
}
func flattenServerSettings(settings rg.ServerSettings) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"inter": settings.Inter,
"guid": settings.GUID,
"down_inter": settings.DownInter,
"rise": settings.Rise,
"fall": settings.Fall,
"slow_start": settings.SlowStart,
"max_conn": settings.MaxConn,
"max_queue": settings.MaxQueue,
"weight": settings.Weight,
}
res = append(res, temp)
return res
}
func flattenRgList(rgl *rg.ListRG) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(rgl.Data))
for _, rg := range rgl.Data {
temp := map[string]interface{}{
"account_id": rg.AccountID,
"account_name": rg.AccountName,
"acl": flattenRgAcl(rg.ACL),
"cpu_allocation_parameter": rg.CPUAllocationParameter,
"cpu_allocation_ratio": rg.CPUAllocationRatio,
"created_by": rg.CreatedBy,
"created_time": rg.CreatedTime,
"def_net_id": rg.DefNetID,
"def_net_type": rg.DefNetType,
"deleted_by": rg.DeletedBy,
"deleted_time": rg.DeletedTime,
"desc": rg.Description,
"dirty": rg.Dirty,
"gid": rg.GID,
"guid": rg.GUID,
"rg_id": rg.ID,
"lock_status": rg.LockStatus,
"milestones": rg.Milestones,
"name": rg.Name,
"register_computes": rg.RegisterComputes,
"resource_limits": flattenRgResourceLimits(rg.ResourceLimits),
"secret": rg.Secret,
"status": rg.Status,
"updated_by": rg.UpdatedBy,
"updated_time": rg.UpdatedTime,
"vins": rg.VINS,
"vms": rg.VMs,
}
res = append(res, temp)
}
return res
}
func flattenRgListVins(lv *rg.ListVINS) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lv.Data))
for _, vins := range lv.Data {
temp := map[string]interface{}{
"account_id": vins.AccountID,
"account_name": vins.AccountName,
"computes": vins.Computes,
"created_by": vins.CreatedBy,
"created_time": vins.CreatedTime,
"deleted_by": vins.DeletedBy,
"deleted_time": vins.DeletedTime,
"external_ip": vins.ExternalIP,
"id": vins.ID,
"name": vins.Name,
"network": vins.Network,
"pri_vnf_dev_id": vins.PriVNFDevID,
"rg_id": vins.RGID,
"rg_name": vins.RGName,
"status": vins.Status,
"updated_by": vins.UpdatedBy,
"updated_time": vins.UpdatedTime,
}
res = append(res, temp)
}
return res
}
func flattenRgListPfw(listPfw *rg.ListPFW) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(listPfw.Data))
for _, pfw := range listPfw.Data {
temp := map[string]interface{}{
"public_port_end": pfw.PublicPortEnd,
"public_port_start": pfw.PublicPortStart,
"vm_id": pfw.VMID,
"vm_ip": pfw.VMIP,
"vm_name": pfw.VMName,
"vm_port": pfw.VMPort,
"vins_id": pfw.VINSID,
"vins_name": pfw.VINSName,
}
res = append(res, temp)
}
return res
}
func flattenResourceRG(d *schema.ResourceData, rgData *rg.RecordRG) {
d.Set("account_id", rgData.AccountID)
d.Set("gid", rgData.GID)
d.Set("rg_name", rgData.Name)
d.Set("resource_limits", flattenRgResourceLimits(rgData.ResourceLimits))
d.Set("def_net_type", rgData.DefNetType)
d.Set("description", rgData.Description)
d.Set("register_computes", rgData.RegisterComputes)
d.Set("uniq_pools", rgData.UniqPools)
d.Set("cpu_allocation_parameter", rgData.CPUAllocationParameter)
d.Set("cpu_allocation_ratio", rgData.CPUAllocationRatio)
d.Set("acl", flattenRgAcl(rgData.ACL))
d.Set("account_name", rgData.AccountName)
d.Set("created_by", rgData.CreatedBy)
d.Set("created_time", rgData.CreatedTime)
d.Set("def_net_id", rgData.DefNetID)
d.Set("deleted_by", rgData.DeletedBy)
d.Set("deleted_time", rgData.DeletedTime)
d.Set("guid", rgData.GUID)
d.Set("rg_id", rgData.ID)
d.Set("lock_status", rgData.LockStatus)
d.Set("milestones", rgData.Milestones)
d.Set("resource_types", rgData.ResTypes)
d.Set("secret", rgData.Secret)
d.Set("status", rgData.Status)
d.Set("updated_by", rgData.UpdatedBy)
d.Set("updated_time", rgData.UpdatedTime)
d.Set("vins", rgData.VINS)
d.Set("vms", rgData.VMs)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
/*
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/cloudbroker/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)
req := rg.GetResourceConsumptionRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
log.Debugf("utilityRGResourceConsumptionGetCheckPresence: load")
accountResourceConsumptionRec, err := c.CloudBroker().RG().GetResourceConsumption(ctx, req)
if err != nil {
return nil, err
}
return accountResourceConsumptionRec, nil
}

View File

@@ -0,0 +1,95 @@
/*
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/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityRgListComputesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListComputes, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListComputesRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
if compute_id, ok := d.GetOk("compute_id"); ok {
req.ComputeID = uint64(compute_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if ip_address, ok := d.GetOk("ip_address"); ok {
req.IPAddress = ip_address.(string)
}
if extnet_name, ok := d.GetOk("extnet_name"); ok {
req.ExtNetName = extnet_name.(string)
}
if extnet_id, ok := d.GetOk("extnet_id"); ok {
req.ExtNetID = uint64(extnet_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))
}
listComputes, err := c.CloudBroker().RG().ListComputes(ctx, req)
if err != nil {
return nil, err
}
return listComputes, nil
}

View File

@@ -0,0 +1,88 @@
/*
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/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityRgListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListRG, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListDeletedRequest{}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if account_name, ok := d.GetOk("account_name"); ok {
req.AccountName = account_name.(string)
}
if created_after, ok := d.GetOk("created_after"); ok {
req.CreatedAfter = uint64(created_after.(int))
}
if created_before, ok := d.GetOk("created_before"); ok {
req.CreatedBefore = uint64(created_before.(int))
}
if lock_status, ok := d.GetOk("lock_status"); ok {
req.LockStatus = lock_status.(string)
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
rgList, err := c.CloudBroker().RG().ListDeleted(ctx, req)
if err != nil {
return nil, err
}
return rgList, nil
}

View File

@@ -0,0 +1,91 @@
/*
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/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityRgListLbCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListLB, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListLBRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
if by_id, ok := d.GetOk("by_id"); ok {
req.ByID = uint64(by_id.(int))
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if tech_status, ok := d.GetOk("tech_status"); ok {
req.TechStatus = tech_status.(string)
}
if status, ok := d.GetOk("status"); ok {
req.Status = status.(string)
}
if front_ip, ok := d.GetOk("front_ip"); ok {
req.FrontIP = front_ip.(string)
}
if back_ip, ok := d.GetOk("back_ip"); ok {
req.BackIP = back_ip.(string)
}
if page, ok := d.GetOk("page"); ok {
req.Page = uint64(page.(int))
}
if size, ok := d.GetOk("size"); ok {
req.Size = uint64(size.(int))
}
listLb, err := c.CloudBroker().RG().ListLB(ctx, req)
if err != nil {
return nil, err
}
return listLb, nil
}

View File

@@ -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"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityRgListPfwCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListPFW, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListPFWRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
listPfw, err := c.CloudBroker().RG().ListPFW(ctx, req)
if err != nil {
return nil, err
}
return listPfw, nil
}

View File

@@ -0,0 +1,79 @@
/*
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/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityRgListVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.ListVINS, error) {
c := m.(*controller.ControllerCfg)
req := rg.ListVINSRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
if name, ok := d.GetOk("name"); ok {
req.Name = name.(string)
}
if account_id, ok := d.GetOk("account_id"); ok {
req.AccountID = uint64(account_id.(int))
}
if ext_ip, ok := d.GetOk("ext_ip"); ok {
req.ExtIP = ext_ip.(string)
}
if vins_id, ok := d.GetOk("vins_id"); ok {
req.VINSID = uint64(vins_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))
}
listVins, err := c.CloudBroker().RG().ListVINS(ctx, req)
if err != nil {
return nil, err
}
return listVins, nil
}

View File

@@ -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/cloudbroker/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.CloudBroker().RG().ListResourceConsumption(ctx)
if err != nil {
return nil, err
}
return rgResourceConsumptionList, nil
}

View File

@@ -0,0 +1,59 @@
/*
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/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func utilityDataRgUsageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*rg.Reservation, error) {
c := m.(*controller.ControllerCfg)
req := rg.UsageRequest{
RGID: uint64(d.Get("rg_id").(int)),
}
if reason, ok := d.GetOk("reason"); ok {
req.Reason = reason.(string)
}
usage, err := c.CloudBroker().RG().Usage(ctx, req)
if err != nil {
return nil, err
}
return usage, nil
}