Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2453a32d01 | ||
|
|
0602a4b693 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,11 +1,8 @@
|
||||
## Version 4.4.0
|
||||
## Version 4.4.2
|
||||
|
||||
### Feature
|
||||
- Added state upgrade from schema version 2 to schema version 3
|
||||
|
||||
### Bugfix
|
||||
- Fixed bug with restore and new create resources at plan and refresh
|
||||
|
||||
## Feature
|
||||
- Add in cloudapi in stack data_source_stack_list and data_source_stack
|
||||
- Add in cloudapi in vins data_source_route, data_source_route_list, resource_static_route
|
||||
- Cloudapi/lb/resource_lb extnet_id and vins_id can be equal to 0, but not together. If the value is 0, the api assigns it itself. Add Highly Available schema for LB deploy (parameter ha_mode). Cloudapi/lb/data_source_lb add parametr backend_haip, frontend_haip, part_k8s, data_source_lb_list, data_source_lb_list_deleted add parametr backend_haip, frontend_haip
|
||||
- Cloudapi/bservice/resource_bservice_group added the ability to create a resource with the following sep_id, sep_pool and cloud_init
|
||||
- Cloudapi/k8s/resource_k8s and resource_k8s_cp added the ability to create a resource with config (parameters cluster_config, kubelet_config, kube_proxy_config, join_config, cloud_init, init_config). Added the ability to create a resource with Highly Available schema for LB deploy (parameter ha_mode). Added the ability to create a resource with additional_sans. Added the ability to create a resource in extnet_only mode
|
||||
- Fixed incorrect work data_source_static_route
|
||||
- Fixed bug with old field "with_default_vins" in state
|
||||
|
||||
2
Makefile
2
Makefile
@@ -7,7 +7,7 @@ ZIPDIR = ./zip
|
||||
BINARY=${NAME}
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=4.4.0
|
||||
VERSION=4.4.2
|
||||
OS_ARCH=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
||||
|
||||
FILES = ${BINARY}_${VERSION}_darwin_amd64\
|
||||
|
||||
2
go.mod
2
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
golang.org/x/net v0.15.0
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.2
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
4
go.sum
4
go.sum
@@ -339,5 +339,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.2 h1:wi2iK7fblgejdylNsW/44fTbBaSoVld0PPcgKErSKyQ=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.2/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5 h1:37OLNiSgF3SXjj0ZMRikVrBiNlNdS9NY8QxD9YFfHBY=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.6.5/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
|
||||
@@ -50,85 +50,93 @@ import (
|
||||
|
||||
func newDataSourcesMap() map[string]*schema.Resource {
|
||||
return map[string]*schema.Resource{
|
||||
"decort_account": account.DataSourceAccount(),
|
||||
"decort_resgroup": rg.DataSourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||
"decort_k8s": k8s.DataSourceK8s(),
|
||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||
"decort_vins": vins.DataSourceVins(),
|
||||
"decort_vins_list": vins.DataSourceVinsList(),
|
||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||
"decort_disk": disks.DataSourceDisk(),
|
||||
"decort_disk_list": disks.DataSourceDiskList(),
|
||||
"decort_rg_list": rg.DataSourceRgList(),
|
||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||
"decort_account_list": account.DataSourceAccountList(),
|
||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||
"decort_bservice": bservice.DataSourceBasicService(),
|
||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||
"decort_extnet": extnet.DataSourceExtnet(),
|
||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||
"decort_image_list": image.DataSourceImageList(),
|
||||
"decort_image": image.DataSourceImage(),
|
||||
"decort_lb": lb.DataSourceLB(),
|
||||
"decort_lb_list": lb.DataSourceLBList(),
|
||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||
"decort_stack": stack.DataSourceStack(),
|
||||
"decort_stack_list": stack.DataSourceStackList(),
|
||||
"decort_account": account.DataSourceAccount(),
|
||||
"decort_account_resource_consumption_list": account.DataSourceAccountResourceConsumptionList(),
|
||||
"decort_account_resource_consumption_get": account.DataSourceAccountResourceConsumptionGet(),
|
||||
"decort_resgroup": rg.DataSourceResgroup(),
|
||||
"decort_kvmvm": kvmvm.DataSourceCompute(),
|
||||
"decort_kvmvm_list": kvmvm.DataSourceComputeList(),
|
||||
"decort_kvmvm_list_deleted": kvmvm.DataSourceComputeListDeleted(),
|
||||
"decort_kvmvm_audits": kvmvm.DataSourceComputeAudits(),
|
||||
"decort_kvmvm_get_audits": kvmvm.DataSourceComputeGetAudits(),
|
||||
"decort_kvmvm_get_console_url": kvmvm.DataSourceComputeGetConsoleUrl(),
|
||||
"decort_kvmvm_get_log": kvmvm.DataSourceComputeGetLog(),
|
||||
"decort_kvmvm_pfw_list": kvmvm.DataSourceComputePfwList(),
|
||||
"decort_kvmvm_user_list": kvmvm.DataSourceComputeUserList(),
|
||||
"decort_kvmvm_snapshot_usage": kvmvm.DataSourceComputeSnapshotUsage(),
|
||||
"decort_kvmvm_vgpu_list": kvmvm.DataSourceComputeVGPUList(),
|
||||
"decort_kvmvm_pci_device_list": kvmvm.DataSourceComputePCIDeviceList(),
|
||||
"decort_k8s": k8s.DataSourceK8s(),
|
||||
"decort_k8s_list": k8s.DataSourceK8sList(),
|
||||
"decort_k8s_list_deleted": k8s.DataSourceK8sListDeleted(),
|
||||
"decort_k8s_wg": k8s.DataSourceK8sWg(),
|
||||
"decort_k8s_wg_list": k8s.DataSourceK8sWgList(),
|
||||
"decort_k8s_computes": k8s.DataSourceK8sComputes(),
|
||||
"decort_k8s_wg_cloud_init": k8s.DataSourceK8sWgCloudInit(),
|
||||
"decort_k8ci_list": k8s.DataSourceK8CIList(),
|
||||
"decort_vins": vins.DataSourceVins(),
|
||||
"decort_vins_list": vins.DataSourceVinsList(),
|
||||
"decort_vins_audits": vins.DataSourceVinsAudits(),
|
||||
"decort_vins_ip_list": vins.DataSourceVinsIpList(),
|
||||
"decort_vins_list_deleted": vins.DataSourceVinsListDeleted(),
|
||||
"decort_vins_ext_net_list": vins.DataSourceVinsExtNetList(),
|
||||
"decort_vins_nat_rule_list": vins.DataSourceVinsNatRuleList(),
|
||||
"decort_vins_static_route_list": vins.DataSourceStaticRouteList(),
|
||||
"decort_vins_static_route": vins.DataSourceStaticRoute(),
|
||||
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
|
||||
"decort_disk": disks.DataSourceDisk(),
|
||||
"decort_disk_list": disks.DataSourceDiskList(),
|
||||
"decort_rg_list": rg.DataSourceRgList(),
|
||||
"decort_rg_affinity_group_computes": rg.DataSourceRgAffinityGroupComputes(),
|
||||
"decort_rg_affinity_groups_list": rg.DataSourceRgAffinityGroupsList(),
|
||||
"decort_rg_affinity_groups_get": rg.DataSourceRgAffinityGroupsGet(),
|
||||
"decort_rg_audits": rg.DataSourceRgAudits(),
|
||||
"decort_rg_list_computes": rg.DataSourceRgListComputes(),
|
||||
"decort_rg_list_deleted": rg.DataSourceRgListDeleted(),
|
||||
"decort_rg_list_lb": rg.DataSourceRgListLb(),
|
||||
"decort_rg_list_pfw": rg.DataSourceRgListPfw(),
|
||||
"decort_rg_list_vins": rg.DataSourceRgListVins(),
|
||||
"decort_rg_resource_consumption_list": rg.DataSourceRGResourceConsumptionList(),
|
||||
"decort_rg_resource_consumption_get": rg.DataSourceRGResourceConsumptionGet(),
|
||||
"decort_rg_usage": rg.DataSourceRgUsage(),
|
||||
"decort_disk_list_types_detailed": disks.DataSourceDiskListTypesDetailed(),
|
||||
"decort_disk_list_types": disks.DataSourceDiskListTypes(),
|
||||
"decort_disk_list_deleted": disks.DataSourceDiskListDeleted(),
|
||||
"decort_disk_list_unattached": disks.DataSourceDiskListUnattached(),
|
||||
"decort_disk_snapshot": disks.DataSourceDiskSnapshot(),
|
||||
"decort_disk_snapshot_list": disks.DataSourceDiskSnapshotList(),
|
||||
"decort_account_list": account.DataSourceAccountList(),
|
||||
"decort_account_computes_list": account.DataSourceAccountComputesList(),
|
||||
"decort_account_disks_list": account.DataSourceAccountDisksList(),
|
||||
"decort_account_vins_list": account.DataSourceAccountVinsList(),
|
||||
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
|
||||
"decort_account_rg_list": account.DataSourceAccountRGList(),
|
||||
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
|
||||
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
|
||||
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
|
||||
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
|
||||
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
|
||||
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
|
||||
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
|
||||
"decort_bservice": bservice.DataSourceBasicService(),
|
||||
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
|
||||
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
|
||||
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
|
||||
"decort_extnet_list": extnet.DataSourceExtnetList(),
|
||||
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
|
||||
"decort_extnet": extnet.DataSourceExtnet(),
|
||||
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
|
||||
"decort_locations_list": locations.DataSourceLocationsList(),
|
||||
"decort_location_url": locations.DataSourceLocationUrl(),
|
||||
"decort_image_list": image.DataSourceImageList(),
|
||||
"decort_image": image.DataSourceImage(),
|
||||
"decort_lb": lb.DataSourceLB(),
|
||||
"decort_lb_list": lb.DataSourceLBList(),
|
||||
"decort_lb_list_deleted": lb.DataSourceLBListDeleted(),
|
||||
"decort_flipgroup": flipgroup.DataSourceFlipgroup(),
|
||||
"decort_flipgroup_list": flipgroup.DataSourceFlipGroupList(),
|
||||
"decort_stack": stack.DataSourceStack(),
|
||||
"decort_stack_list": stack.DataSourceStackList(),
|
||||
|
||||
"decort_cb_account": cb_account.DataSourceAccount(),
|
||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
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 account
|
||||
|
||||
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 dataSourceAccountResourceConsumptionGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
accountResourceConsumptionRec, err := utilityAccountResourceConsumptionGetCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
flattenResourceConsumption(d, accountResourceConsumptionRec)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountResourceConsumptionGetSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"resource_limits": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceResourceLimitsSchemaMake(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
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 DataSourceAccountResourceConsumptionGet() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceAccountResourceConsumptionGetRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAccountResourceConsumptionGetSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
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 account
|
||||
|
||||
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 dataSourceAccountResourceConsumptionListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
accountResourceConsumptionList, err := utilityAccountResourceConsumptionListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccResourceConsumption(accountResourceConsumptionList))
|
||||
d.Set("entry_count", accountResourceConsumptionList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceAccountResourceConsumptionListSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"consumed": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
"reserved": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: dataSourceAccResourceSchemaMake(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"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 dataSourceAccResourceSchemaMake() 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,
|
||||
},
|
||||
"ext_ips": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ext_traffic": {
|
||||
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 DataSourceAccountResourceConsumptionList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceAccountResourceConsumptionListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceAccountResourceConsumptionListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ import (
|
||||
)
|
||||
|
||||
func flattenAccountTemplatesList(atl *account.ListTemplates) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(atl.Data))
|
||||
for _, at := range atl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"unc_path": at.UNCPath,
|
||||
@@ -72,7 +72,7 @@ func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceD
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenAccountTemplatesList(accountTemplatesList))
|
||||
|
||||
d.Set("entry_count", accountTemplatesList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -87,6 +87,31 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by image id",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Filter by type",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -136,6 +161,10 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func flattenAccount(d *schema.ResourceData, acc account.RecordAccount) error {
|
||||
d.Set("guid", acc.GUID)
|
||||
d.Set("account_id", acc.ID)
|
||||
d.Set("account_name", acc.Name)
|
||||
d.Set("resource_limits", flattenRgResourceLimits(acc.ResourceLimits))
|
||||
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||
d.Set("send_access_emails", acc.SendAccessEmails)
|
||||
d.Set("status", acc.Status)
|
||||
d.Set("updated_time", acc.UpdatedTime)
|
||||
@@ -79,11 +79,19 @@ func flattenAccAcl(acls []account.RecordACL) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRgResourceLimits(rl account.ResourceLimits) []map[string]interface{} {
|
||||
func flattenResourceConsumption(d *schema.ResourceData, acc *account.RecordResourceConsumption) {
|
||||
d.Set("account_id", acc.AccountID)
|
||||
d.Set("consumed", flattenAccResource(acc.Consumed))
|
||||
d.Set("reserved", flattenAccResource(acc.Reserved))
|
||||
d.Set("resource_limits", flattenAccResourceLimits(acc.ResourceLimits))
|
||||
}
|
||||
|
||||
func flattenAccResourceLimits(rl account.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,
|
||||
@@ -124,14 +132,28 @@ func flattenAccountSeps(seps map[string]map[string]account.DiskUsage) []map[stri
|
||||
func flattenAccResource(r account.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),
|
||||
"cpu": r.CPU,
|
||||
"disk_size": r.DiskSize,
|
||||
"disk_size_max": r.DiskSizeMax,
|
||||
"ext_ips": r.ExtIPs,
|
||||
"ext_traffic": r.ExtTraffic,
|
||||
"gpu": r.GPU,
|
||||
"ram": r.RAM,
|
||||
"seps": flattenAccountSeps(r.SEPs),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenAccResourceConsumption(lrc *account.ListResourceConsumption) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(lrc.Data))
|
||||
for _, rc := range lrc.Data {
|
||||
temp := map[string]interface{}{
|
||||
"consumed": flattenAccResource(rc.Consumed),
|
||||
"reserved": flattenAccResource(rc.Reserved),
|
||||
"account_id": rc.AccountID,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -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 account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountResourceConsumptionGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.RecordResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
id := uint64(d.Get("account_id").(int))
|
||||
|
||||
req:= account.GetResourceConsumptionRequest {
|
||||
AccountID: id,
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountResourceConsumptionGetCheckPresence: load")
|
||||
accountResourceConsumptionRec, err := c.CloudAPI().Account().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 account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityAccountResourceConsumptionListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListResourceConsumption, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
log.Debugf("utilityAccountResourceConsumptionListCheckPresence: load")
|
||||
accountResourceConsumptionList, err := c.CloudAPI().Account().ListResourceConsumption(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return accountResourceConsumptionList, nil
|
||||
}
|
||||
@@ -44,9 +44,8 @@ import (
|
||||
|
||||
func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*account.ListTemplates, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
var id uint64
|
||||
|
||||
id = uint64(d.Get("account_id").(int))
|
||||
id := uint64(d.Get("account_id").(int))
|
||||
|
||||
req := account.ListTemplatesRequest{
|
||||
AccountID: id,
|
||||
@@ -55,6 +54,21 @@ func utilityAccountTemplatesListCheckPresence(ctx context.Context, d *schema.Res
|
||||
if include_deleted, ok := d.GetOk("include_deleted"); ok {
|
||||
req.IncludeDeleted = include_deleted.(bool)
|
||||
}
|
||||
if imageId, ok := d.GetOk("image_id"); ok {
|
||||
req.ImageID = uint64(imageId.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if typeTemplates, ok := d.GetOk("type"); ok {
|
||||
req.Type = typeTemplates.(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))
|
||||
}
|
||||
|
||||
log.Debugf("utilityAccountTemplatesListCheckPresence: load")
|
||||
accountTemplatesList, err := c.CloudAPI().Account().ListTemplates(ctx, req)
|
||||
|
||||
@@ -146,7 +146,7 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"disk_total": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
@@ -185,13 +185,13 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"groups_name": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
// "groups_name": {
|
||||
// Type: schema.TypeList,
|
||||
// Computed: true,
|
||||
// Elem: &schema.Schema{
|
||||
// Type: schema.TypeString,
|
||||
// },
|
||||
// },
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -93,6 +93,16 @@ func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m i
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
if d.Get("start").(bool) && d.Get("enable").(bool) {
|
||||
log.Debugf("trying to start bservice %v", serviceId)
|
||||
_, err := c.CloudAPI().BService().Enable(ctx, bservice.EnableRequest{
|
||||
ServiceID: serviceId,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceBasicServiceRead(ctx, d, m)
|
||||
}
|
||||
@@ -552,7 +562,7 @@ func resourceBasicServiceSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
},
|
||||
"disk_total": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
|
||||
@@ -107,6 +107,20 @@ func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData
|
||||
d.SetId(strconv.FormatUint(compgroupId, 10))
|
||||
d.Set("compgroup_id", compgroupId)
|
||||
|
||||
serviceId:= uint64(d.Get("service_id").(int))
|
||||
|
||||
if d.Get("start").(bool) {
|
||||
log.Debugf("trying to start bservice group %v", compgroupId)
|
||||
_, err := c.CloudAPI().BService().GroupStart(ctx, bservice.GroupStartRequest{
|
||||
ServiceID: serviceId,
|
||||
CompGroupID: compgroupId,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return resourceBasicServiceGroupRead(ctx, d, m)
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,16 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "type of the disks",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by sep ID",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by pool name",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
||||
@@ -49,12 +49,23 @@ func dataSourceDiskListTypesRead(ctx context.Context, d *schema.ResourceData, m
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("types", listTypes)
|
||||
d.Set("types", listTypes.Data)
|
||||
d.Set("entry_count", listTypes.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -63,6 +74,10 @@ func dataSourceDiskListTypesSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "The types of disk in terms of its role in compute: 'B=Boot, D=Data, T=Temp'",
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ func flattenDiskListTypesDetailed(tld *disks.ListTypes) []map[string]interface{}
|
||||
temp := map[string]interface{}{
|
||||
"pools": flattenListTypesDetailedPools(toMap["pools"].([]interface{})),
|
||||
"sep_id": toMap["sepId"].(float64),
|
||||
"sep_name": toMap["sepName"].(string),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
@@ -61,6 +62,7 @@ func flattenListTypesDetailedPools(pools []interface{}) []interface{} {
|
||||
toMap := pool.(map[string]interface{})
|
||||
temp := map[string]interface{}{
|
||||
"name": toMap["name"].(string),
|
||||
"system": toMap["system"].(string),
|
||||
"types": toMap["types"].([]interface{}),
|
||||
}
|
||||
res = append(res, temp)
|
||||
@@ -78,11 +80,22 @@ func dataSourceDiskListTypesDetailedRead(ctx context.Context, d *schema.Resource
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenDiskListTypesDetailed(listTypesDetailed))
|
||||
d.Set("entry_count", listTypesDetailed.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -98,6 +111,10 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Pool name",
|
||||
},
|
||||
"system": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"types": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -114,9 +131,17 @@ func dataSourceDiskListTypesDetailedSchemaMake() map[string]*schema.Schema {
|
||||
Computed: true,
|
||||
Description: "Storage endpoint provider ID to create disk",
|
||||
},
|
||||
"sep_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -97,6 +97,16 @@ func dataSourceDiskListUnattachedSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "ID of the account the disks belong to",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "find by sep ID",
|
||||
},
|
||||
"pool_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by pool name",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
|
||||
@@ -17,7 +17,7 @@ func flattenDiskSnapshot(d *schema.ResourceData, snapshot disks.ItemSnapshot) {
|
||||
}
|
||||
|
||||
func flattenDiskListUnattached(ul *disks.ListDisksUnattached) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ul.Data))
|
||||
for _, unattachedDisk := range ul.Data {
|
||||
unattachedDiskAcl, _ := json.Marshal(unattachedDisk.ACL)
|
||||
tmp := map[string]interface{}{
|
||||
@@ -120,7 +120,7 @@ func flattenDisk(d *schema.ResourceData, disk *disks.RecordDisk) {
|
||||
}
|
||||
|
||||
func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||
res := make([]interface{}, 0)
|
||||
res := make([]interface{}, 0, len(sl))
|
||||
for _, snapshot := range sl {
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
@@ -137,7 +137,7 @@ func flattenDiskSnapshotList(sl disks.ListSnapshots) []interface{} {
|
||||
}
|
||||
|
||||
func flattenDiskList(dl *disks.ListDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(dl.Data))
|
||||
for _, disk := range dl.Data {
|
||||
diskAcl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
|
||||
@@ -47,18 +47,6 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListRequest{}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = strings.ToUpper(diskType.(string))
|
||||
}
|
||||
if accountId, ok := d.GetOk("accountId"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
@@ -77,6 +65,24 @@ func utilityDiskListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
if shared, ok := d.GetOk("shared"); ok {
|
||||
req.Shared = shared.(bool)
|
||||
}
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = strings.ToUpper(diskType.(string))
|
||||
}
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
req.AccountID = uint64(sepId.(int))
|
||||
}
|
||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||
req.Pool = pool_name.(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))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListCheckPresence: load disk list")
|
||||
diskList, err := c.CloudAPI().Disks().List(ctx, req)
|
||||
|
||||
@@ -13,15 +13,6 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := disks.ListUnattachedRequest{}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if accountId, ok := d.GetOk("accountId"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if by_id, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(by_id.(int))
|
||||
}
|
||||
@@ -34,6 +25,24 @@ func utilityDiskListUnattachedCheckPresence(ctx context.Context, d *schema.Resou
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if diskType, ok := d.GetOk("type"); ok {
|
||||
req.Type = diskType.(string)
|
||||
}
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||
req.AccountID = uint64(sepId.(int))
|
||||
}
|
||||
if pool_name, ok := d.GetOk("pool_name"); ok {
|
||||
req.Pool = pool_name.(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))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListUnattachedCheckPresence: load disk Unattached list")
|
||||
unattachedList, err := c.CloudAPI().Disks().ListUnattached(ctx, req)
|
||||
|
||||
@@ -46,6 +46,13 @@ func utilityDiskListTypesDetailedCheckPresence(ctx context.Context, d *schema.Re
|
||||
req := disks.ListTypesRequest{
|
||||
Detailed: true,
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListTypesDetailedCheckPresence: load disk list Types Detailed")
|
||||
listTypesDetailed, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||
|
||||
@@ -47,6 +47,13 @@ func utilityDiskListTypesCheckPresence(ctx context.Context, d *schema.ResourceDa
|
||||
Detailed: false,
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
log.Debugf("utilityDiskListTypesCheckPresence: load disk list Types Detailed")
|
||||
typesList, err := c.CloudAPI().Disks().ListTypes(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -50,7 +50,7 @@ func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceDat
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenExtnetComputesList(extnetComputesList))
|
||||
|
||||
d.Set("entry_count", extnetComputesList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,6 +61,26 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "filter by account ID",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by RG ID",
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Filter by compute ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -117,6 +137,10 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
|
||||
}
|
||||
|
||||
func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ex))
|
||||
for _, item := range ex {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": item.ClientType,
|
||||
@@ -51,7 +51,7 @@ func flattenExcluded(ex []extnet.Excluded) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenExtnetReservations(ers extnet.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ers))
|
||||
for _, er := range ers {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": er.ClientType,
|
||||
@@ -92,7 +92,7 @@ func flattenExtnetVNFS(evnfs extnet.VNFs) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (ecs))
|
||||
for _, ec := range ecs {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": ec.ID,
|
||||
@@ -106,7 +106,7 @@ func flattenExtnetsComputes(ecs extnet.ListExtNetExtends) []map[string]interface
|
||||
}
|
||||
|
||||
func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ecl.Data))
|
||||
for _, ec := range ecl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": ec.AccountID,
|
||||
@@ -123,7 +123,7 @@ func flattenExtnetComputesList(ecl *extnet.ListExtNetComputes) []map[string]inte
|
||||
}
|
||||
|
||||
func flattenExtnetList(el *extnet.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(el.Data))
|
||||
for _, e := range el.Data {
|
||||
temp := map[string]interface{}{
|
||||
"net_id": e.ID,
|
||||
|
||||
@@ -48,6 +48,20 @@ func utilityExtnetComputesListCheckPresence(ctx context.Context, d *schema.Resou
|
||||
AccountID: uint64(d.Get("account_id").(int)),
|
||||
}
|
||||
|
||||
if rg_id, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rg_id.(int))
|
||||
}
|
||||
if compute_id, ok := d.GetOk("compute_id"); ok {
|
||||
req.ComputeID = uint64(compute_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))
|
||||
}
|
||||
|
||||
|
||||
log.Debugf("utilityExtnetComputesListCheckPresence")
|
||||
extnetComputesList, err := c.CloudAPI().ExtNet().ListComputes(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -50,7 +50,7 @@ func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m i
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := image.CreateVirtualRequest{
|
||||
Name: d.Get("name").(string),
|
||||
TargetID: uint64(d.Get("target_id").(int)),
|
||||
TargetID: uint64(d.Get("link_to").(int)),
|
||||
}
|
||||
|
||||
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
|
||||
|
||||
@@ -58,6 +58,7 @@ func dataSourceK8sListDeletedRead(ctx context.Context, d *schema.ResourceData, m
|
||||
func dataSourceK8sListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
k8sListDeleted := createK8sListSchema()
|
||||
delete(k8sListDeleted, "includedeleted")
|
||||
delete(k8sListDeleted, "status")
|
||||
return k8sListDeleted
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
)
|
||||
|
||||
func dataSourceK8sWgCloudInitRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("dataSourceK8sWgCloudInitRead: called with k8s id %d and wg id %d", d.Get("k8s_id").(int), d.Get("wg_id").(int))
|
||||
|
||||
metaData, err := utilityK8sWgCloudInitCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("cloud_init", metaData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceK8sWgCloudInitSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"k8s_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Kubernetes cluster ID",
|
||||
},
|
||||
"wg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the workers compute group",
|
||||
},
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Worker group Cloud init",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceK8sWgCloudInit() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceK8sWgCloudInitRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceK8sWgCloudInitSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ import (
|
||||
)
|
||||
|
||||
func flattenK8CIItems(list *k8ci.ListK8CI) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(list.Data))
|
||||
for _, item := range list.Data {
|
||||
temp := map[string]interface{}{
|
||||
"k8ci_id": item.ID,
|
||||
@@ -72,7 +72,7 @@ func flattenK8sDataComputes(d *schema.ResourceData, cluster *k8s.RecordK8S) {
|
||||
}
|
||||
|
||||
func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Masters.DetailedInfo))
|
||||
for _, comp := range cluster.K8SGroups.Masters.DetailedInfo {
|
||||
temp := map[string]interface{}{
|
||||
"id": comp.ID,
|
||||
@@ -88,7 +88,7 @@ func flattenMasterComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(cluster.K8SGroups.Workers))
|
||||
for _, wg := range cluster.K8SGroups.Workers {
|
||||
for _, comp := range wg.DetailedInfo {
|
||||
temp := map[string]interface{}{
|
||||
@@ -106,7 +106,7 @@ func flattenWorkerComputes(cluster *k8s.RecordK8S) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenAclList(aclList k8s.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (aclList))
|
||||
for _, acl := range aclList {
|
||||
temp := map[string]interface{}{
|
||||
"explicit": acl.Explicit,
|
||||
@@ -134,7 +134,7 @@ func flattenAcl(acl k8s.RecordACL) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (interfaces))
|
||||
for _, interfaceCompute := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"def_gw": interfaceCompute.DefGW,
|
||||
@@ -147,7 +147,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
||||
}
|
||||
|
||||
func flattenDetailedInfo(detailedInfoList k8s.ListDetailedInfo, computes []compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (detailedInfoList))
|
||||
if computes != nil {
|
||||
for i, detailedInfo := range detailedInfoList {
|
||||
temp := map[string]interface{}{
|
||||
@@ -193,7 +193,7 @@ func flattenMasterGroup(mastersGroup k8s.MasterGroup, masters []compute.RecordCo
|
||||
}
|
||||
|
||||
func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(k8SGroupList))
|
||||
for _, k8sGroup := range k8SGroupList {
|
||||
labels := make([]string, 0)
|
||||
for _, label := range k8sGroup.Labels {
|
||||
@@ -267,7 +267,7 @@ func flattenServiceAccount(serviceAccount k8s.RecordServiceAccount) []map[string
|
||||
}
|
||||
|
||||
func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (workersGroups))
|
||||
for _, worker := range workersGroups {
|
||||
temp := map[string]interface{}{
|
||||
"annotations": worker.Annotations,
|
||||
@@ -288,7 +288,7 @@ func flattenWorkersGroup(workersGroups k8s.ListK8SGroups) []map[string]interface
|
||||
}
|
||||
|
||||
func flattenK8sItems(k8sItems *k8s.ListK8SClusters) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len (k8sItems.Data))
|
||||
for _, item := range k8sItems.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": item.AccountID,
|
||||
@@ -396,7 +396,7 @@ func flattenResourceK8s(d *schema.ResourceData, k8s k8s.RecordK8S, masters []com
|
||||
}
|
||||
|
||||
func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.RecordCompute) {
|
||||
labels := make([]string, 0)
|
||||
labels := make([]string, 0, len(wg.Labels))
|
||||
for _, label := range wg.Labels {
|
||||
if strings.HasPrefix(label, "workersGroupName") {
|
||||
continue
|
||||
@@ -418,7 +418,7 @@ func flattenWg(d *schema.ResourceData, wg k8s.ItemK8SGroup, computes []compute.R
|
||||
}
|
||||
|
||||
func flattenWgList(wgList k8s.ListK8SGroups, computesMap map[uint64][]compute.RecordCompute) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(wgList))
|
||||
for _, wg := range wgList {
|
||||
computes := computesMap[wg.ID]
|
||||
temp := map[string]interface{}{
|
||||
|
||||
@@ -92,6 +92,10 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
req.WorkerDisk = uint64(d.Get("disk").(int))
|
||||
}
|
||||
|
||||
if cloudInit, ok := d.GetOk("cloud_init"); ok {
|
||||
req.UserData = cloudInit.(string)
|
||||
}
|
||||
|
||||
resp, err := c.CloudAPI().K8S().WorkersGroupAdd(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -184,6 +188,19 @@ func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("cloud_init") {
|
||||
req := k8s.UpdateWorkerNodesMetaDataRequest{
|
||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||
WorkersGroupID: wgId,
|
||||
UserData: d.Get("cloud_init").(string),
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().K8S().UpdateWorkerNodesMetaData(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -286,6 +303,11 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
DiffSuppressFunc: cloudInitDiffSupperss,
|
||||
},
|
||||
"wg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -261,6 +261,19 @@ func utilityK8sListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
req.TechStatus = tech_status.(string)
|
||||
}
|
||||
|
||||
if includedeleted, ok := d.GetOk("includedeleted"); ok {
|
||||
req.IncludeDeleted = includedeleted.(bool)
|
||||
}
|
||||
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
|
||||
k8sList, err := c.CloudAPI().K8S().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -297,14 +310,18 @@ func utilityK8sListDeletedCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
req.BasicServiceID = uint64(bservice_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 page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
k8sList, err := c.CloudAPI().K8S().ListDeleted(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
@@ -137,3 +138,27 @@ func utilityK8sWgListCheckPresence(ctx context.Context, d *schema.ResourceData,
|
||||
|
||||
return cluster.K8SGroups.Workers, nil
|
||||
}
|
||||
|
||||
func utilityK8sWgCloudInitCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := k8s.GetWorkerNodesMetaDataRequest{
|
||||
K8SID: uint64(d.Get("k8s_id").(int)),
|
||||
WorkersGroupID: uint64(d.Get("wg_id").(int)),
|
||||
}
|
||||
|
||||
cloudInit, err := c.CloudAPI().K8S().GetWorkerNodesMetaData(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return cloudInit, nil
|
||||
}
|
||||
|
||||
func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
|
||||
if newVal != "" && newVal != oldVal {
|
||||
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=FALSE", key, oldVal, newVal)
|
||||
return false
|
||||
}
|
||||
log.Debugf("networkSubresIPAddreDiffSupperss: key=%s, oldVal=%q, newVal=%q -> suppress=TRUE", key, oldVal, newVal)
|
||||
return true // suppress difference
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
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 dataSourceComputeListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computeList, err := utilityDataComputeListDeletedCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
result := computeList
|
||||
if d.Get("ignore_k8s").(bool) {
|
||||
// matches automatically generated names like "s234-g2134-c1" etc
|
||||
result = matchComputes(computeList)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenComputeList(result))
|
||||
d.Set("entry_count", computeList.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeListDeletedSchemaMake() map[string]*schema.Schema {
|
||||
res := map[string]*schema.Schema{
|
||||
"by_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by AccountID",
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by resgroup name",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by RGID",
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by tech status",
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by IP address",
|
||||
},
|
||||
"extnet_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet name",
|
||||
},
|
||||
"extnet_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by Extnet ID",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
"ignore_k8s": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "If set to true, ignores any VMs associated with any k8s cluster",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: itemComputeSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func DataSourceComputeListDeleted() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeListDeletedRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeListDeletedSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
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 dataSourceComputePCIDeviceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computePCIDeviceList, err := utilityComputePCIDeviceListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenPCIDevice(computePCIDeviceList.Data))
|
||||
d.Set("entry_count", computePCIDeviceList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputePCIDeviceListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by RG id",
|
||||
},
|
||||
"device_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by device id",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by name",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputePCIDeviceList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputePCIDeviceListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputePCIDeviceListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenPfwList(computePfwList))
|
||||
d.Set("entry_count", computePfwList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -94,6 +95,10 @@ func dataSourceComputePfwListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
120
internal/service/cloudapi/kvmvm/data_source_compute_vgpu_list.go
Normal file
120
internal/service/cloudapi/kvmvm/data_source_compute_vgpu_list.go
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
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 dataSourceComputeVGPUListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
computeVGPUList, err := utilityComputeVGPUListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVGPU(computeVGPUList.Data))
|
||||
d.Set("entry_count", computeVGPUList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceComputeVGPUListSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"gpu_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Find by GPU id",
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by type",
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Find by status",
|
||||
},
|
||||
"includedeleted": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Description: "Include deleted computes. If using field 'status', then includedeleted will be ignored",
|
||||
},
|
||||
"page": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page number",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
"items": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceComputeVGPUList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceComputeVGPUListRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout30s,
|
||||
Default: &constants.Timeout60s,
|
||||
},
|
||||
|
||||
Schema: dataSourceComputeVGPUListSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -66,7 +66,7 @@ func flattenQOS(qos compute.QOS) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, interfaceItem := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"conn_id": interfaceItem.ConnID,
|
||||
@@ -92,7 +92,7 @@ func flattenInterfaces(interfaces compute.ListInterfaces) []map[string]interface
|
||||
return res
|
||||
}
|
||||
func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(snapSets))
|
||||
for _, snapSet := range snapSets {
|
||||
temp := map[string]interface{}{
|
||||
"disks": snapSet.Disks,
|
||||
@@ -105,7 +105,7 @@ func flattenSnapSets(snapSets compute.ListSnapSets) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenTags(tags map[string]string) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(tags))
|
||||
for key, val := range tags {
|
||||
temp := map[string]interface{}{
|
||||
"key": key,
|
||||
@@ -117,7 +117,7 @@ func flattenTags(tags map[string]string) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(listRules))
|
||||
for _, rule := range listRules {
|
||||
temp := map[string]interface{}{
|
||||
"guid": rule.GUID,
|
||||
@@ -132,7 +132,7 @@ func flattenListRules(listRules compute.ListRules) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(listAcl))
|
||||
for _, acl := range listAcl {
|
||||
temp := map[string]interface{}{
|
||||
"explicit": acl.Explicit,
|
||||
@@ -148,7 +148,7 @@ func flattenListACL(listAcl compute.ListACL) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenComputeList(computes *compute.ListComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computes.Data))
|
||||
for _, compute := range computes.Data {
|
||||
customFields, _ := json.Marshal(compute.CustomFields)
|
||||
devices, _ := json.Marshal(compute.Devices)
|
||||
@@ -398,7 +398,7 @@ func flattenACL(acl compute.RecordACL) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenAffinityRules(affinityRules compute.ListRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(affinityRules))
|
||||
for _, affinityRule := range affinityRules {
|
||||
temp := map[string]interface{}{
|
||||
"guid": affinityRule.GUID,
|
||||
@@ -437,7 +437,7 @@ func flattenIotune(iotune compute.IOTune) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(snapshots))
|
||||
for _, snapshot := range snapshots {
|
||||
temp := map[string]interface{}{
|
||||
"guid": snapshot.GUID,
|
||||
@@ -455,7 +455,7 @@ func flattenSnapshots(snapshots compute.SnapshotExtendList) []map[string]interfa
|
||||
}
|
||||
|
||||
func flattenListComputeDisks(disks compute.ListComputeDisks) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(disks))
|
||||
for _, disk := range disks {
|
||||
acl, _ := json.Marshal(disk.ACL)
|
||||
temp := map[string]interface{}{
|
||||
@@ -511,7 +511,7 @@ func flattenCustomFields(customFields map[string]interface{}) string {
|
||||
}
|
||||
|
||||
func flattenOsUsers(osUsers compute.ListOSUser) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(osUsers))
|
||||
for _, user := range osUsers {
|
||||
temp := map[string]interface{}{
|
||||
"guid": user.GUID,
|
||||
@@ -590,7 +590,7 @@ func flattenDataCompute(d *schema.ResourceData, computeRec compute.RecordCompute
|
||||
}
|
||||
|
||||
func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeAudits))
|
||||
for _, computeAudit := range computeAudits {
|
||||
temp := map[string]interface{}{
|
||||
"call": computeAudit.Call,
|
||||
@@ -605,7 +605,7 @@ func flattenComputeAudits(computeAudits compute.ListAudits) []map[string]interfa
|
||||
}
|
||||
|
||||
func flattenPfwList(computePfws *compute.ListPFWs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computePfws.Data))
|
||||
for _, computePfw := range computePfws.Data {
|
||||
temp := map[string]interface{}{
|
||||
"pfw_id": computePfw.ID,
|
||||
@@ -628,7 +628,7 @@ func flattenUserList(d *schema.ResourceData, userList *compute.ListUsers) {
|
||||
}
|
||||
|
||||
func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeAudits))
|
||||
for _, computeAudit := range computeAudits {
|
||||
temp := map[string]interface{}{
|
||||
"epoch": computeAudit.Epoch,
|
||||
@@ -640,7 +640,7 @@ func flattenComputeGetAudits(computeAudits compute.ListShortAudits) []map[string
|
||||
}
|
||||
|
||||
func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages))
|
||||
for _, computeUsage := range computeSnapshotUsages {
|
||||
temp := map[string]interface{}{
|
||||
"count": computeUsage.Count,
|
||||
@@ -652,3 +652,55 @@ func flattenSnapshotUsage(computeSnapshotUsages compute.ListUsageSnapshots) []ma
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenSnapshotList(computeSnapshotUsages *compute.ListSnapShots) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(computeSnapshotUsages.Data))
|
||||
for _, computeUsage := range computeSnapshotUsages.Data {
|
||||
temp := map[string]interface{}{
|
||||
"disks": computeUsage.Disks,
|
||||
"guid": computeUsage.GUID,
|
||||
"label": computeUsage.Label,
|
||||
"timestamp": computeUsage.Timestamp,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVGPU(m []interface{}) []string {
|
||||
output := []string{}
|
||||
for _, item := range m {
|
||||
switch d := item.(type) {
|
||||
case string:
|
||||
output = append(output, d)
|
||||
case int:
|
||||
output = append(output, strconv.Itoa(d))
|
||||
case int64:
|
||||
output = append(output, strconv.FormatInt(d, 10))
|
||||
case float64:
|
||||
output = append(output, strconv.FormatInt(int64(d), 10))
|
||||
default:
|
||||
output = append(output, "")
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
func flattenPCIDevice(m []interface{}) []string {
|
||||
output := []string{}
|
||||
for _, item := range m {
|
||||
switch d := item.(type) {
|
||||
case string:
|
||||
output = append(output, d)
|
||||
case int:
|
||||
output = append(output, strconv.Itoa(d))
|
||||
case int64:
|
||||
output = append(output, strconv.FormatInt(d, 10))
|
||||
case float64:
|
||||
output = append(output, strconv.FormatInt(int64(d), 10))
|
||||
default:
|
||||
output = append(output, "")
|
||||
}
|
||||
}
|
||||
return output
|
||||
}
|
||||
@@ -548,3 +548,882 @@ func resourceComputeResourceV1() *schema.Resource {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceComputeResourceV2() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validation.IntAtLeast(1),
|
||||
Description: "ID of the resource group where this compute should be deployed.",
|
||||
},
|
||||
"driver": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
||||
Description: "Hardware architecture of this compute instance.",
|
||||
},
|
||||
"cpu": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
|
||||
Description: "Number of CPUs to allocate to this compute instance.",
|
||||
},
|
||||
"ram": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
|
||||
Description: "Amount of RAM in MB to allocate to this compute instance.",
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
//ForceNew: true, //REDEPLOY
|
||||
Description: "ID of the OS image to base this compute instance on.",
|
||||
},
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "This compute instance boot disk size in GB. Make sure it is large enough to accomodate selected OS image.",
|
||||
},
|
||||
"affinity_label": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Set affinity label for compute",
|
||||
},
|
||||
"affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"topology": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false),
|
||||
Description: "compute or node, for whom rule applies",
|
||||
},
|
||||
"policy": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false),
|
||||
Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule",
|
||||
},
|
||||
"mode": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false),
|
||||
Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'",
|
||||
},
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "key that are taken into account when analyzing this rule will be identified",
|
||||
},
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"anti_affinity_rules": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"topology": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"node", "compute"}, false),
|
||||
Description: "compute or node, for whom rule applies",
|
||||
},
|
||||
"policy": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"RECOMMENDED", "REQUIRED"}, false),
|
||||
Description: "RECOMMENDED or REQUIRED, the degree of 'strictness' of this rule",
|
||||
},
|
||||
"mode": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"EQ", "NE", "ANY"}, false),
|
||||
Description: "EQ or NE or ANY - the comparison mode is 'value', recorded by the specified 'key'",
|
||||
},
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "key that are taken into account when analyzing this rule will be identified",
|
||||
},
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "value that must match the key to be taken into account when analyzing this rule",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"disks": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"disk_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Name for disk",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Disk size in GiB",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||
},
|
||||
"disk_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Pool name; by default will be chosen automatically",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Optional description",
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Specify image id for create disk from template",
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Disk deletion status",
|
||||
},
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Disk ID",
|
||||
},
|
||||
"shareable": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"size_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"custom_fields": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
"stateless": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
|
||||
},
|
||||
"with_default_vins": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "Create compute with default resgroup ViNS (true) or without any interfaces (false). This parameter is ignored if network block is specified",
|
||||
},
|
||||
"boot_disk": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"disk_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Name for disk",
|
||||
},
|
||||
"size": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Disk size in GiB",
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||
},
|
||||
"disk_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Pool name; by default will be chosen automatically",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Optional description",
|
||||
},
|
||||
"image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Specify image id for create disk from template",
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Description: "Disk deletion status",
|
||||
},
|
||||
"disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "Disk ID",
|
||||
},
|
||||
"shareable": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"size_used": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
|
||||
},
|
||||
|
||||
"extra_disks": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
MaxItems: constants.MaxExtraDisksPerCompute,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.",
|
||||
},
|
||||
|
||||
"network": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
MinItems: 1,
|
||||
MaxItems: constants.MaxNetworksPerCompute,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating
|
||||
Description: "Type of the network for this connection, either EXTNET or VINS.",
|
||||
},
|
||||
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "ID of the network for this connection.",
|
||||
},
|
||||
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
|
||||
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
|
||||
},
|
||||
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
|
||||
"tags": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"key": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"value": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"port_forwarding": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"public_port_start": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"public_port_end": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Default: -1,
|
||||
},
|
||||
"local_port": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
"proto": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"tcp", "udp"}, false),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"user_access": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"username": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"access_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"snapshot": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"label": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"rollback": {
|
||||
Type: schema.TypeSet,
|
||||
MaxItems: 1,
|
||||
Optional: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"label": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"cd": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
MaxItems: 1,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"cdrom_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"pin_to_stack": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
|
||||
"description": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Optional text description of this compute instance.",
|
||||
},
|
||||
|
||||
"cloud_init": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "Optional cloud_init parameters. Applied when creating new compute instance only, ignored in all other cases.",
|
||||
},
|
||||
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "If true - enable compute, else - disable",
|
||||
},
|
||||
|
||||
"pause": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
|
||||
"reset": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
|
||||
"auto_start": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Flag for redeploy compute",
|
||||
},
|
||||
"force_stop": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "Flag for redeploy compute",
|
||||
},
|
||||
"data_disks": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"KEEP", "DETACH", "DESTROY"}, false),
|
||||
Default: "DETACH",
|
||||
Description: "Flag for redeploy compute",
|
||||
},
|
||||
"started": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "Is compute started.",
|
||||
},
|
||||
"detach_disks": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"permanently": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"is": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "system name",
|
||||
},
|
||||
"ipa_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "compute purpose",
|
||||
},
|
||||
// The rest are Compute properties, which are "computed" once it is created
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "ID of the account this compute instance belongs to.",
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the account this compute instance belongs to.",
|
||||
},
|
||||
"affinity_weight": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"arch": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"boot_order": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"boot_disk_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
Description: "This compute instance boot disk ID.",
|
||||
},
|
||||
"clone_reference": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"clones": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"computeci_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"devices": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"compute_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"interfaces": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"def_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"flip_group_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ip_address": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"listen_ssh": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"mac": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"netmask": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"pci_slot": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"qos": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"e_rate": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"in_brust": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"in_rate": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"vnfs": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"lock_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"manager_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"migrationjob": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"natable_vins_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"natable_vins_ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"natable_vins_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"natable_vins_network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"natable_vins_network_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"os_users": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "GUID of this guest OS user.",
|
||||
},
|
||||
|
||||
"login": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Login name of this guest OS user.",
|
||||
},
|
||||
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
//Sensitive: true,
|
||||
Description: "Password of this guest OS user.",
|
||||
},
|
||||
|
||||
"public_key": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "SSH public key of this guest OS user.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: "Guest OS users provisioned on this compute instance.",
|
||||
},
|
||||
"pinned": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"reference_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"registered": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"res_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "Name of the resource group where this compute instance is located.",
|
||||
},
|
||||
"snap_sets": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"disks": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"label": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"timestamp": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"stateless_sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"stateless_sep_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"tech_status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"user_managed": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
},
|
||||
"vgpus": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"virtual_image_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"virtual_image_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +63,16 @@ func existRgID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool
|
||||
func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
imageId := uint64(d.Get("image_id").(int))
|
||||
req := image.ListRequest{}
|
||||
req := image.ListRequest{
|
||||
ByID: imageId,
|
||||
}
|
||||
|
||||
imageList, err := c.CloudAPI().Image().List(ctx, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return len(imageList.FilterByID(imageId).Data) != 0, nil
|
||||
return len(imageList.Data) != 0, nil
|
||||
}
|
||||
|
||||
func existVinsIdInList(vinsId uint64, vinsList *vins.ListVINS) bool {
|
||||
|
||||
@@ -129,9 +129,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
createReqX86.IS = IS.(string)
|
||||
}
|
||||
|
||||
if !d.Get("with_default_vins").(bool) {
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
}
|
||||
createReqX86.Interfaces = make([]kvmx86.Interface, 0)
|
||||
|
||||
if networks, ok := d.GetOk("network"); ok {
|
||||
if networks.(*schema.Set).Len() > 0 {
|
||||
@@ -1617,14 +1615,14 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
// ForceNew: true,
|
||||
ValidateFunc: validation.IntAtLeast(1),
|
||||
Description: "ID of the resource group where this compute should be deployed.",
|
||||
},
|
||||
"driver": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
// ForceNew: true,
|
||||
StateFunc: statefuncs.StateFuncToUpper,
|
||||
ValidateFunc: validation.StringInSlice([]string{"SVA_KVM_X86", "KVM_X86", "KVM_PPC"}, false), // observe case while validating
|
||||
Description: "Hardware architecture of this compute instance.",
|
||||
@@ -1748,12 +1746,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Default: false,
|
||||
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
|
||||
},
|
||||
"with_default_vins": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
Description: "Create compute with default resgroup ViNS (true) or without any interfaces (false). This parameter is ignored if network block is specified",
|
||||
},
|
||||
"boot_disk": {
|
||||
Type: schema.TypeSet,
|
||||
Computed: true,
|
||||
@@ -1762,17 +1754,17 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
"sep_id": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
// ForceNew: true,
|
||||
Description: "ID of SEP to create bootDisk on. Uses image's sepId if not set.",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ForceNew: true,
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
// ForceNew: true,
|
||||
Description: "Pool to use if sepId is set, can be also empty if needed to be chosen by system.",
|
||||
},
|
||||
|
||||
@@ -2140,7 +2132,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
|
||||
func ResourceCompute() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 2,
|
||||
SchemaVersion: 3,
|
||||
|
||||
CreateContext: resourceComputeCreate,
|
||||
ReadContext: resourceComputeRead,
|
||||
@@ -2166,6 +2158,11 @@ func ResourceCompute() *schema.Resource {
|
||||
Upgrade: resourceCompueteStateUpgradeV1,
|
||||
Version: 1,
|
||||
},
|
||||
{
|
||||
Type: resourceComputeResourceV2().CoreConfigSchema().ImpliedType(),
|
||||
Upgrade: resourceComputeStateUpgradeV2,
|
||||
Version: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,3 +31,11 @@ func resourceCompueteStateUpgradeV1(ctx context.Context, rawState map[string]int
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
func resourceComputeStateUpgradeV2(ctx context.Context, rawState map[string]interface{}, meta any) (map[string]interface{}, error) {
|
||||
log.Debug("resourceComputeStateUpgradeV2: upgrading state")
|
||||
|
||||
delete(rawState, "with_default_vins")
|
||||
|
||||
return rawState, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityDataComputeListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListComputes, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.ListDeletedRequest{}
|
||||
|
||||
if byId, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(byId.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if accountId, ok := d.GetOk("account_id"); ok {
|
||||
req.AccountID = uint64(accountId.(int))
|
||||
}
|
||||
if rgName, ok := d.GetOk("rg_name"); ok {
|
||||
req.RGName = rgName.(string)
|
||||
}
|
||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rgId.(int))
|
||||
}
|
||||
if techStatus, ok := d.GetOk("tech_status"); ok {
|
||||
req.TechStatus = techStatus.(string)
|
||||
}
|
||||
if ipAddress, ok := d.GetOk("ip_address"); ok {
|
||||
req.IPAddress = ipAddress.(string)
|
||||
}
|
||||
if extNetName, ok := d.GetOk("extnet_name"); ok {
|
||||
req.ExtNetName = extNetName.(string)
|
||||
}
|
||||
if extnetId, ok := d.GetOk("extnet_id"); ok {
|
||||
req.ExtNetID = uint64(extnetId.(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.CloudAPI().Compute().ListDeleted(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return listComputes, nil
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityComputePCIDeviceListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListPCIDevices, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.ListPCIDeviceRequest{
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||
req.RGID = uint64(rgId.(int))
|
||||
}
|
||||
if devId, ok := d.GetOk("device_id"); ok {
|
||||
req.DevID = uint64(devId.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(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))
|
||||
}
|
||||
|
||||
listPCIDevice, err := c.CloudAPI().Compute().ListPCIDevice(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return listPCIDevice, err
|
||||
|
||||
}
|
||||
74
internal/service/cloudapi/kvmvm/utility_compute_vgpu_list.go
Normal file
74
internal/service/cloudapi/kvmvm/utility_compute_vgpu_list.go
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2019-2023 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 kvmvm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
)
|
||||
|
||||
func utilityComputeVGPUListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*compute.ListVGPUs, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := compute.ListVGPURequest{
|
||||
ComputeID: uint64(d.Get("compute_id").(int)),
|
||||
}
|
||||
if GPUID, ok := d.GetOk("gpu_id"); ok {
|
||||
req.GPUID = uint64(GPUID.(int))
|
||||
}
|
||||
if typeVGPU, ok := d.GetOk("type"); ok {
|
||||
req.Type = typeVGPU.(string)
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if includeDeleted, ok := d.GetOk("includedeleted"); ok {
|
||||
req.IncludeDeleted = includeDeleted.(bool)
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
|
||||
listVGPU, err := c.CloudAPI().Compute().ListVGPU(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return listVGPU, err
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ package pfw
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -65,5 +66,5 @@ func utilityPfwCheckPresence(ctx context.Context, d *schema.ResourceData, m inte
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil, fmt.Errorf("PFW not found")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func dataSourceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m i
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenSnapshotList(snapshotList))
|
||||
|
||||
d.Set("entry_count", snapshotList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ func dataSourceSnapshotListSchemaMake() map[string]*schema.Schema {
|
||||
Schema: dataSourceSnapshotSchemaMake(),
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
|
||||
return rets
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func flattenSnapshotList(gl *compute.ListSnapShots) []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{}{
|
||||
"label": item.Label,
|
||||
|
||||
@@ -530,6 +530,7 @@ func flattenStaticRouteData(d *schema.ResourceData, route *vins.ItemRoutes) {
|
||||
d.Set("guid", route.GUID)
|
||||
d.Set("netmask", route.Netmask)
|
||||
d.Set("compute_ids", route.ComputeIds)
|
||||
d.Set("route_id", route.ID)
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
@@ -184,8 +185,14 @@ func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m in
|
||||
|
||||
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
vinsId := uint64(d.Get("vins_id").(int))
|
||||
routeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
arr := strings.Split(d.Id(), "#")
|
||||
if len(arr) != 2 {
|
||||
return diag.FromErr(fmt.Errorf("broken state id"))
|
||||
}
|
||||
|
||||
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
|
||||
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
|
||||
|
||||
req := vins.StaticRouteDelRequest{
|
||||
VINSID: vinsId,
|
||||
RouteId: routeId,
|
||||
|
||||
@@ -32,6 +32,57 @@ data "decort_account_computes_list" "acl" {
|
||||
#тип - число
|
||||
account_id = 1111
|
||||
|
||||
#фильтр по id compute
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#compute_id = 100
|
||||
|
||||
#фильтр по имени compute
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#rg_name = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STARTED"
|
||||
|
||||
#фильтр по ip address
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "1.1.1.1.1"
|
||||
|
||||
#фильтр по имени внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#extnet_name = "test"
|
||||
|
||||
#фильтр по id внешней сети
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -38,6 +38,21 @@ data "decort_account_deleted_list" "adl" {
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
|
||||
#фильтр по id аккаунта
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по ACL
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#acl = "test"
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -32,6 +32,36 @@ data "decort_account_disks_list" "adl" {
|
||||
#тип - число
|
||||
account_id = 11111
|
||||
|
||||
#фильтр по id диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#disk_id = 100
|
||||
|
||||
#фильтр по имени диска
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "data_disk"
|
||||
|
||||
#фильтр по максимальному размеру диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#disk_max_size = 100
|
||||
|
||||
#тип диска
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#возможные типы: "b" - boot_disk, "d" - data_disk
|
||||
#type = "d"
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -31,6 +31,46 @@ data "decort_account_flipgroups_list" "afgl" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
account_id = 1111
|
||||
|
||||
#фильтр по имени flipgroup
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vins_id = 100
|
||||
|
||||
#фильтр по имени vins
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#vins_name = "test"
|
||||
|
||||
#фильтр по id extnet
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#фильтр по IP
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#by_ip = "1.1.1.1.1"
|
||||
|
||||
#фильтр по id flipgroup
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#flipgroup_id = 100
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Получение списка текущего потребления ресурсов аккаунта
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://alpha.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso-alpha.dev.decs.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_account_resource_consumption_get" "rc_get" {
|
||||
#id аккаунта
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
account_id = 111
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_account_resource_consumption_get.rc_get
|
||||
}
|
||||
|
||||
@@ -27,6 +27,26 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_account_list" "al" {
|
||||
#фильтр по id аккаунта
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по ACL
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#acl = "test"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Получение списка текущего потребления ресурсов
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://alpha.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso-alpha.dev.decs.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_account_resource_consumption_list" "rc_list" {
|
||||
#Нет входных параметров
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_account_resource_consumption_list.rc_list
|
||||
}
|
||||
|
||||
@@ -30,6 +30,43 @@ data "decort_account_rg_list" "argl" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
account_id = 66666
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 11111
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vins_id = 100
|
||||
|
||||
#фильтр по id compute
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vm_id = 100
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "CREATED"
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -31,6 +31,38 @@ data "decort_account_templates_list" "atl" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
account_id = 11111
|
||||
|
||||
#фильтр "включая удаленные шаблоны"
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
#include_deleted = true
|
||||
|
||||
#фильтр по id образа
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#image_id = 1111
|
||||
|
||||
#фильтр по имени
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по типу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#type = "linux"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -32,6 +32,37 @@ data "decort_account_vins_list" "avl" {
|
||||
#тип - число
|
||||
account_id = 22222
|
||||
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vins_id = 100
|
||||
|
||||
#фильтр по имени vins
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 11111
|
||||
|
||||
#фильтр по IP внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ext_ip = "test"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -27,17 +27,47 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_bservice_list" "bsl" {
|
||||
#фильтр по id базового сервиса
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени базового сервиса
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для фильтрации данных
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#rg_name = "test"
|
||||
|
||||
#id ресурсной группы, используется для фильтрации
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#rg_id = 11111
|
||||
#rg_id = 11111
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STARTED"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "test"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
@@ -50,7 +80,6 @@ data "decort_bservice_list" "bsl" {
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -27,6 +27,36 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_disk_list" "dl" {
|
||||
#фильтр по id диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени диска
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "data_disk"
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "user"
|
||||
|
||||
#фильтр по максимальному размеру диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#disk_max_size = 100
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по доступности иным пользователям
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
#shared = "false"
|
||||
|
||||
#id аккаунта для получения списка дисков
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
@@ -38,6 +68,16 @@ data "decort_disk_list" "dl" {
|
||||
#возможные типы: "b" - boot_disk, "d" - data_disk
|
||||
#type = "d"
|
||||
|
||||
#id SEP для получения списка дисков
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#sep_id = 11111
|
||||
|
||||
#фильтр по имени pool
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#pool_name = "test"
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
|
||||
@@ -27,6 +27,31 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_disk_list_deleted" "dld" {
|
||||
#фильтр по id диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени диска
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "data_disk"
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "user"
|
||||
|
||||
#фильтр по максимальному размеру диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#disk_max_size = 100
|
||||
|
||||
#фильтр по доступности иным пользователям
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
#shared = "false"
|
||||
|
||||
#id аккаунта для получения списка дисков
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
|
||||
@@ -32,6 +32,18 @@ data "decort_disk_list_types" "dlt" {
|
||||
#Выходной параметр
|
||||
#тип - лист строк
|
||||
#types {}
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -45,6 +45,18 @@ data "decort_disk_list_types_detailed" "dltd" {
|
||||
#Выходной параметр
|
||||
#Список типов
|
||||
#types
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -28,10 +28,58 @@ provider "decort" {
|
||||
|
||||
|
||||
data "decort_disk_list_unattached" "dlu" {
|
||||
#Номер аккаунта
|
||||
#фильтр по id диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
account_id = 100
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "user"
|
||||
|
||||
#фильтр по максимальному размеру диска
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#disk_max_size = 100
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по типу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#возможные типы: "b" - boot_disk, "d" - data_disk
|
||||
#type = "d"
|
||||
|
||||
#фильтр по id аккаунта
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 100
|
||||
|
||||
#фильтр по id sep
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#sep_id = 1
|
||||
|
||||
#фильтр по имени pool
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#pool_name = "test"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -30,6 +30,28 @@ data "decort_extnet_computes_list" "ecl" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
account_id = 1111
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 11111
|
||||
|
||||
#фильтр по id виртуальной машины
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#compute_id = 11111
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
#size = 1
|
||||
|
||||
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -32,6 +32,36 @@ data "decort_extnet_list" "el" {
|
||||
#тип - число
|
||||
#account_id = 1111111
|
||||
|
||||
#фильтр по id внешней сети
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по IP внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#network = "test"
|
||||
|
||||
#фильтр по id vlan
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vlan_id = 100
|
||||
|
||||
#фильтр по id vnfDevices
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vnfdev_id = 100
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
|
||||
@@ -21,15 +21,53 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_flipgroup_list" "fg" {
|
||||
# Номер страницы
|
||||
# Опциональный параметр
|
||||
# int
|
||||
page = 0
|
||||
#фильтр по id flipgroup
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
# Размер страницы
|
||||
# Опциональный параметр
|
||||
# int
|
||||
size = 0
|
||||
#фильтр по имени flipgroup
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#vins_id = 100
|
||||
|
||||
#фильтр по имени vins
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#vins_name = "test"
|
||||
|
||||
#фильтр по id extnet
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#фильтр по IP
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#by_ip = "1.1.1.1.1"
|
||||
|
||||
#id ресурсной группы, используется для фильтрации
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#rg_id = 11111
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 2
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
}
|
||||
|
||||
output "fg_out" {
|
||||
|
||||
@@ -26,12 +26,65 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_image_list" "il" {
|
||||
#id аккаунта для включения образов аккаунтов в результат
|
||||
#пользователь для осуществления успешного запроса должен иметь права доступа к аккаунту
|
||||
#фильтр по id sep
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все общие образа
|
||||
#account_id = 111
|
||||
#sep_id = 1
|
||||
|
||||
#фильтр по id образа
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени образа
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по архитектуре
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#architecture = "x86_64"
|
||||
|
||||
#фильтр по типу образа
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#type_image = "cdrom"
|
||||
|
||||
#фильтр по размеру образа
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#image_size = 100
|
||||
|
||||
#фильтр по имени SEP
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#sep_name = "test"
|
||||
|
||||
#фильтр по имени Pool
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#pool = "test"
|
||||
|
||||
#фильтр по доступу
|
||||
#опциональный параметр
|
||||
#тип - булевый тип
|
||||
#public = "true"
|
||||
|
||||
#фильтр по hot_resize
|
||||
#опциональный параметр
|
||||
#тип - булевый тип
|
||||
#hot_resize = "true"
|
||||
|
||||
#фильтр по bootable
|
||||
#опциональный параметр
|
||||
#тип - булевый тип
|
||||
#bootable = "true"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
@@ -44,7 +97,6 @@ data "decort_image_list" "il" {
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 3
|
||||
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -26,23 +26,63 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_k8s_list" "k8s_list" {
|
||||
#фильтр по id кластера
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени кластера
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по ip
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по id балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#lb_id = 100
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#bservice_id = 100
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#включение удаленных k8s в результат
|
||||
#опциональный параметр
|
||||
#тип - будев тип
|
||||
#если не задан - выводятся все неудаленные данные
|
||||
include_deleted = true
|
||||
# includedeleted = true
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
page = 1
|
||||
# page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
size = 1
|
||||
# size = 1
|
||||
}
|
||||
|
||||
output "output_k8s_list" {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение списка доступных кластеров включая удаленные
|
||||
Получение списка удаленных кластеров
|
||||
*/
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
@@ -26,17 +26,52 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_k8s_list_deleted" "k8s_list_deleted" {
|
||||
#фильтр по id кластера
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени кластера
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по ip
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по id балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#lb_id = 100
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#bservice_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
size = 1
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output_k8s_list_deleted" {
|
||||
|
||||
45
samples/cloudapi/data_k8s_wg_cloud_init/main.tf
Normal file
45
samples/cloudapi/data_k8s_wg_cloud_init/main.tf
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение информации о мета данных рабочей группы k8s кластера
|
||||
*/
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_k8s_wg_cloud_init" "wg_cloud_init" {
|
||||
#id кластера
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
k8s_id = 977
|
||||
|
||||
#id группы воркеров
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
wg_id = 2110
|
||||
}
|
||||
|
||||
output "wg_cloud_init" {
|
||||
value = data.decort_k8s_wg_cloud_init.wg_cloud_init
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ provider "decort" {
|
||||
data "decort_kvmvm" "comp" {
|
||||
#получение информации по идентификатору машины - compute_id
|
||||
|
||||
#id виртуальной машины
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
#compute_id = 11346
|
||||
# id виртуальной машины
|
||||
# обязательный параметр
|
||||
# тип - число
|
||||
compute_id = 11346
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
@@ -25,29 +25,79 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_kvmvm_list" "compute_list" {
|
||||
#фильтр по id ВМ
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени ВМ
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка ВМ
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#rg_name = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по ip
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "test"
|
||||
|
||||
#фильтр по имени extnet
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#extnet_name = "test"
|
||||
|
||||
#фильтр по id extnet
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#флаг влючения в результат удаленных балансироващиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
#значение по-умолчанию - false
|
||||
#если не задан - выводятся все доступные неудаленные балансировщики
|
||||
includedeleted = true
|
||||
#includedeleted = true
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
size = 1
|
||||
#size = 1
|
||||
|
||||
# Включить в список вывода ВМ, принадлежащие k8s кластерам (при значении параметра true)
|
||||
# опциональный параметр
|
||||
# bool (default = false)
|
||||
ignore_k8s = true
|
||||
#Включить в список вывода ВМ, принадлежащие k8s кластерам (при значении параметра true)
|
||||
#опциональный параметр
|
||||
#bool (default = false)
|
||||
#ignore_k8s = true
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
88
samples/cloudapi/data_kvmvm_list_deleted/main.tf
Normal file
88
samples/cloudapi/data_kvmvm_list_deleted/main.tf
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение данных о списке удаленных compute (виртуальных машин)
|
||||
*/
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_kvmvm_list_deleted" "compute_list" {
|
||||
#фильтр по id виртуальной машины
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени виртуальной машины
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id аккаунта
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 100
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#rg_name = "test"
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "some"
|
||||
|
||||
#фильтр по ip
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "test"
|
||||
|
||||
#фильтр по имени extNet
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#extnet_name = "test"
|
||||
|
||||
#фильтр по id extNet
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_kvmvm_list_deleted.compute_list
|
||||
}
|
||||
68
samples/cloudapi/data_kvmvm_pci_device_list/main.tf
Normal file
68
samples/cloudapi/data_kvmvm_pci_device_list/main.tf
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение данных о списке подключенных устройств (PCI)
|
||||
*/
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_kvmvm_pci_device_list" "pci_device_list" {
|
||||
#id виртуальной машины
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
compute_id = 100
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по id устройства
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#device_id = 100
|
||||
|
||||
#фильтр по имени устройства
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_kvmvm_pci_device_list.pci_device_list
|
||||
}
|
||||
68
samples/cloudapi/data_kvmvm_vgpu_list/main.tf
Normal file
68
samples/cloudapi/data_kvmvm_vgpu_list/main.tf
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Пример использования
|
||||
Получение данных о списке подключенных графических процессоров
|
||||
*/
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://ds1.digitalenergy.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_kvmvm_vgpu_list" "vgpu_list" {
|
||||
#id виртуальной машины
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
compute_id = 100
|
||||
|
||||
#фильтр по id графического процессора
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#gpu_id = 100
|
||||
|
||||
#фильтр по типу графического процессора
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#type = "NVIDIA"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр "включая удаленные графические процессоры"
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
#includedeleted = "false"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = data.decort_kvmvm_vgpu_list.vgpu_list
|
||||
}
|
||||
@@ -27,6 +27,46 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_lb_list" "lbl" {
|
||||
#фильтр по id балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка балансировщиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по IP front
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#front_ip = "ENABLED"
|
||||
|
||||
#фильтр по IP back
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#back_ip = "ENABLED"
|
||||
|
||||
#флаг влючения в результат удаленных балансироващиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - булев тип
|
||||
@@ -38,7 +78,7 @@ data "decort_lb_list" "lbl" {
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
|
||||
@@ -27,11 +27,46 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_lb_list_deleted" "lbld" {
|
||||
#фильтр по id балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка балансировщиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#фильтр по IP front
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#front_ip = "ENABLED"
|
||||
|
||||
#фильтр по IP back
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#back_ip = "ENABLED"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
|
||||
@@ -29,6 +29,26 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_locations_list" "ll" {
|
||||
#фильтр по флагу
|
||||
#опицональный параметр
|
||||
#тип - строка
|
||||
#flag = "some"
|
||||
|
||||
#фильтр по id локации
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени локации
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#фильтр по коду локации
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#location_code = "europe"
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
|
||||
@@ -29,6 +29,18 @@ data "decort_rg_affinity_groups_list" "list_groups" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
rg_id = 123
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
37
samples/cloudapi/data_rg_get_resource_consumption/main.tf
Normal file
37
samples/cloudapi/data_rg_get_resource_consumption/main.tf
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Получение списка текущего потребления ресурсов ресурсной группы
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://alpha.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso-alpha.dev.decs.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_rg_resource_consumption_get" "rc_get" {
|
||||
#id ресурсной группы
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
rg_id = 111
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_rg_resource_consumption_get.rc_get
|
||||
}
|
||||
|
||||
@@ -25,20 +25,60 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_rg_list" "rg_list" {
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка ресурсных групп
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "test"
|
||||
|
||||
#фильтр по времени создания (после указанного времени)
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#created_after = "123"
|
||||
|
||||
#фильтр по времени создания (перед указанным временем)
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#created_before = "123"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по lock status
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#lock_status = "UNLOCKED"
|
||||
|
||||
#отображать удаленные ресурсные группы или нет
|
||||
#необязательный параметр
|
||||
#тип - булевый
|
||||
includedeleted = false
|
||||
#includedeleted = false
|
||||
|
||||
#номер страницы
|
||||
#необязательный параметр
|
||||
#тип - число
|
||||
page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#необязательный параметр
|
||||
#тип - число
|
||||
size = 2
|
||||
#size = 2
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
@@ -29,10 +29,58 @@ data "decort_rg_list_computes" "list_computes" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
rg_id = 123
|
||||
#причина для действия
|
||||
#необязательный параметр
|
||||
|
||||
#фильтр по id compute
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#compute_id = 100
|
||||
|
||||
#фильтр по имени compute
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
reason = "TEST"
|
||||
#name = "test"
|
||||
|
||||
#фильтр по id аккаунта
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 100
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STARTED"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по ip address
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ip_address = "1.1.1.1.1"
|
||||
|
||||
#фильтр по имени внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#extnet_name = "test"
|
||||
|
||||
#фильтр по id внешней сети
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#extnet_id = 100
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
@@ -25,15 +25,50 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_rg_list_deleted" "list_deleted" {
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка ресурсных групп
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по имени аккаунта
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#account_name = "test"
|
||||
|
||||
#фильтр по времени создания (после указанного времени)
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#created_after = "123"
|
||||
|
||||
#фильтр по времени создания (перед указанным временем)
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#created_before = "123"
|
||||
|
||||
#фильтр по lock status
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#lock_status = "UNLOCKED"
|
||||
|
||||
#номер страницы
|
||||
#необязательный параметр
|
||||
#тип - число
|
||||
page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#необязательный параметр
|
||||
#тип - число
|
||||
size = 2
|
||||
#size = 2
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
@@ -29,6 +29,53 @@ data "decort_rg_list_lb" "list_lb" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
rg_id = 123
|
||||
|
||||
#фильтр по id балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени балансировщика нагрузки
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка балансировщиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по техническому статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#tech_status = "STOPPED"
|
||||
|
||||
#фильтр по статусу
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#status = "ENABLED"
|
||||
|
||||
#фильтр по IP front
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#front_ip = "ENABLED"
|
||||
|
||||
#фильтр по IP back
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#back_ip = "ENABLED"
|
||||
|
||||
#номер страницы для отображения
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#если не задан - выводятся все доступные данные
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
@@ -29,10 +29,38 @@ data "decort_rg_list_vins" "list_vins" {
|
||||
#обязательный параметр
|
||||
#тип - число
|
||||
rg_id = 123
|
||||
#причина для действия
|
||||
#необязательный параметр
|
||||
#тип - строка
|
||||
reason = "TEST"
|
||||
|
||||
# фильтр по id vins
|
||||
# опциональный параметр
|
||||
# тип - число
|
||||
# vins_id = 100
|
||||
|
||||
# фильтр по имени vins
|
||||
# опциональный параметр
|
||||
# тип - строка
|
||||
# name = "test"
|
||||
|
||||
# id аккаунта для получения списка балансировщиков нагрузки
|
||||
# опциональный параметр
|
||||
# тип - число
|
||||
# account_id = 11111
|
||||
|
||||
# фильтр по IP внешней сети
|
||||
# опциональный параметр
|
||||
# тип - строка
|
||||
# ext_ip = "test"
|
||||
|
||||
# номер страницы для отображения
|
||||
# опциональный параметр
|
||||
# тип - число
|
||||
# если не задан - выводятся все доступные данные
|
||||
# page = 2
|
||||
|
||||
# размер страницы
|
||||
# опциональный параметр
|
||||
# тип - число
|
||||
# если не задан - выводятся все доступные данные
|
||||
# size = 3
|
||||
}
|
||||
|
||||
output "output" {
|
||||
|
||||
34
samples/cloudapi/data_rg_resource_consumption_list/main.tf
Normal file
34
samples/cloudapi/data_rg_resource_consumption_list/main.tf
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Получение списка текущего потребления ресурсов
|
||||
*/
|
||||
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
#controller_url = <DECORT_CONTROLLER_URL>
|
||||
controller_url = "https://alpha.dev.decs.online"
|
||||
#oauth2_url = <DECORT_SSO_URL>
|
||||
oauth2_url = "https://sso-alpha.dev.decs.online"
|
||||
allow_unverified_ssl = true
|
||||
}
|
||||
|
||||
data "decort_rg_resource_consumption_list" "rc_list" {
|
||||
#Нет входных параметров
|
||||
}
|
||||
|
||||
output "test" {
|
||||
value = data.decort_rg_resource_consumption_list.rc_list
|
||||
}
|
||||
|
||||
@@ -26,6 +26,31 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_vins_list" "vl" {
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени vins
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка балансировщиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по IP внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ext_ip = "test"
|
||||
|
||||
#включение удаленных vins в результат
|
||||
#опциональный параметр
|
||||
#тип - будев тип
|
||||
|
||||
@@ -26,15 +26,40 @@ provider "decort" {
|
||||
}
|
||||
|
||||
data "decort_vins_list_deleted" "vins_list_deleted" {
|
||||
#фильтр по id vins
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#by_id = 100
|
||||
|
||||
#фильтр по имени vins
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#name = "test"
|
||||
|
||||
#id аккаунта для получения списка балансировщиков нагрузки
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#account_id = 11111
|
||||
|
||||
#фильтр по id ресурсной группы
|
||||
#опциональный параметр
|
||||
#тип - число
|
||||
#rg_id = 100
|
||||
|
||||
#фильтр по IP внешней сети
|
||||
#опциональный параметр
|
||||
#тип - строка
|
||||
#ext_ip = "test"
|
||||
|
||||
#кол-во страниц для вывода
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
page = 1
|
||||
#page = 1
|
||||
|
||||
#размер страницы
|
||||
#опицональный параметр
|
||||
#тип - число
|
||||
size = 1
|
||||
#size = 1
|
||||
}
|
||||
|
||||
output "test" {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user