Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 371bb0d90f | |||
| caf7213bca |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,10 +1,10 @@
|
||||
## Version 4.0.2
|
||||
## Version 4.1.1
|
||||
|
||||
## Features
|
||||
- Added new data source decort_k8s_computes used to list all VMs in k8s cluster
|
||||
- Added the ability to manipulate worker-groups inside resource decort_k8s
|
||||
- Added new required field name to workers block
|
||||
- Added new optional fields (labels, annotations, taints) to workers block
|
||||
|
||||
## Bug Fix
|
||||
- Fixed incorrect state reading in resource decort_k8s
|
||||
## Bug Fixes
|
||||
- Resolved possible context cancelation issues when awaiting platform response
|
||||
- resource decort_k8s_wg:
|
||||
- Added ignore of "workersGroupName" label
|
||||
- resource decort_kvmvm:
|
||||
- Fixed "boot_disk_size" incorrect state
|
||||
- Fixed disappearing of "cloud_init" field value
|
||||
- Set "started" default value to true
|
||||
|
||||
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ ZIPDIR = ./zip
|
||||
BINARY=${NAME}.exe
|
||||
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
|
||||
MAINPATH = ./cmd/decort/
|
||||
VERSION=4.0.2
|
||||
VERSION=4.1.1
|
||||
#OS_ARCH=darwin_amd64
|
||||
OS_ARCH=windows_amd64
|
||||
#OS_ARCH=linux_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.5.0
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.4
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
4
go.sum
4
go.sum
@@ -332,5 +332,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.4.3 h1:jrBl90lRfp34bE3m30N3mYIDTSlaPySuo+pE7bK4eOI=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.3/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.4 h1:qoot6a9UPOihncfhmhmyzMd0nGVAzY/b1Gvs+AFk1/k=
|
||||
repository.basistech.ru/BASIS/decort-golang-sdk v1.4.4/go.mod h1:szsTGa73O75ckCWVGJPvTtRbhA/ubuYrYhMkPjvHlmE=
|
||||
|
||||
@@ -158,7 +158,6 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
||||
Username: ret_config.legacy_user,
|
||||
Password: ret_config.legacy_password,
|
||||
DecortURL: ret_config.controller_url,
|
||||
Retries: 0,
|
||||
SSLSkipVerify: allow_unverified_ssl,
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/extnet"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||
@@ -119,6 +120,8 @@ func newDataSourcesMap() map[string]*schema.Resource {
|
||||
"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_cb_account": cb_account.DataSourceAccount(),
|
||||
"decort_cb_account_list": cb_account.DataSourceAccountList(),
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/account"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/bservice"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/disks"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/flipgroup"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/image"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/service/cloudapi/kvmvm"
|
||||
@@ -68,22 +69,23 @@ func newResourcesMap() map[string]*schema.Resource {
|
||||
"decort_lb_backend_server": lb.ResourceLBBackendServer(),
|
||||
"decort_lb_frontend": lb.ResourceLBFrontend(),
|
||||
"decort_lb_frontend_bind": lb.ResourceLBFrontendBind(),
|
||||
"decort_flipgroup": flipgroup.ResourceFlipgroup(),
|
||||
|
||||
"decort_cb_account": cb_account.ResourceAccount(),
|
||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||
"decort_cb_image": cb_image.ResourceImage(),
|
||||
"decort_cb_virtual_image":cb_image.ResourceVirtualImage(),
|
||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||
"decort_cb_delete_images":cb_image.ResourceDeleteImages(),
|
||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
||||
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
||||
"decort_cb_account": cb_account.ResourceAccount(),
|
||||
"decort_cb_disk": cb_disks.ResourceDisk(),
|
||||
"decort_cb_image": cb_image.ResourceImage(),
|
||||
"decort_cb_virtual_image": cb_image.ResourceVirtualImage(),
|
||||
"decort_cb_cdrom_image": cb_image.ResourceCDROMImage(),
|
||||
"decort_cb_delete_images": cb_image.ResourceDeleteImages(),
|
||||
"decort_cb_pcidevice": cb_pcidevice.ResourcePcidevice(),
|
||||
"decort_cb_sep": cb_sep.ResourceSep(),
|
||||
"decort_cb_sep_config": cb_sep.ResourceSepConfig(),
|
||||
"decort_cb_resgroup": cb_rg.ResourceResgroup(),
|
||||
"decort_cb_kvmvm": cb_kvmvm.ResourceCompute(),
|
||||
"decort_cb_vins": cb_vins.ResourceVins(),
|
||||
"decort_cb_pfw": cb_pfw.ResourcePfw(),
|
||||
"decort_cb_k8s": cb_k8s.ResourceK8s(),
|
||||
"decort_cb_k8s_wg": cb_k8s.ResourceK8sWg(),
|
||||
"decort_cb_snapshot": cb_snapshot.ResourceSnapshot(),
|
||||
}
|
||||
}
|
||||
|
||||
191
internal/service/cloudapi/flipgroup/data_source_flipgroup.go
Normal file
191
internal/service/cloudapi/flipgroup/data_source_flipgroup.go
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
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>
|
||||
Tim Tkachev, <tvtkachev@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 flipgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"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 dataSourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenFlipgroup(d, fg)
|
||||
d.SetId(fmt.Sprint(fg.ID))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"flipgroup_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Flipgroupd ID",
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceFlipgroup() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceFlipgroupRead,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout180s,
|
||||
Default: &constants.Timeout180s,
|
||||
},
|
||||
|
||||
Schema: dataSourceFlipgroupSchemaMake(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
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>
|
||||
Tim Tkachev, <tvtkachev@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 flipgroup
|
||||
|
||||
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 dataSourceFlipgroupList(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
fg_list, err := utilityFlipgroupListCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
|
||||
d.Set("items", flattenFlipgroupList(fg_list))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dataSourceFlipgroupListSchemaMake() map[string]*schema.Schema {
|
||||
return 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,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"flipgroup_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_ids": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DataSourceFlipGroupList() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
ReadContext: dataSourceFlipgroupList,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Read: &constants.Timeout180s,
|
||||
Default: &constants.Timeout180s,
|
||||
},
|
||||
|
||||
Schema: dataSourceFlipgroupListSchemaMake(),
|
||||
}
|
||||
}
|
||||
107
internal/service/cloudapi/flipgroup/flattens.go
Normal file
107
internal/service/cloudapi/flipgroup/flattens.go
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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>
|
||||
Tim Tkachev, <tvtkachev@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 flipgroup
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||
)
|
||||
|
||||
func flattenFlipgroup(d *schema.ResourceData, fg *flipgroup.ItemFLIPGroup) {
|
||||
d.Set("account_id", fg.AccountID)
|
||||
d.Set("account_name", fg.AccountName)
|
||||
d.Set("client_ids", fg.ClientIDs)
|
||||
d.Set("client_names", fg.ClientNames)
|
||||
d.Set("client_type", fg.ClientType)
|
||||
d.Set("conn_id", fg.ConnID)
|
||||
d.Set("conn_type", fg.ConnType)
|
||||
d.Set("created_by", fg.CreatedBy)
|
||||
d.Set("created_time", fg.CreatedTime)
|
||||
d.Set("default_gw", fg.DefaultGW)
|
||||
d.Set("deleted_by", fg.DeletedBy)
|
||||
d.Set("deleted_time", fg.DeletedTime)
|
||||
d.Set("desc", fg.Description)
|
||||
d.Set("gid", fg.GID)
|
||||
d.Set("guid", fg.GUID)
|
||||
d.Set("flipgroup_id", fg.ID)
|
||||
d.Set("ip", fg.IP)
|
||||
d.Set("milestones", fg.Milestones)
|
||||
d.Set("name", fg.Name)
|
||||
d.Set("net_id", fg.NetID)
|
||||
d.Set("net_type", fg.NetType)
|
||||
d.Set("network", fg.Network)
|
||||
d.Set("rg_id", fg.RGID)
|
||||
d.Set("rg_name", fg.RGName)
|
||||
d.Set("status", fg.Status)
|
||||
d.Set("updated_by", fg.UpdatedBy)
|
||||
d.Set("updated_time", fg.UpdatedTime)
|
||||
}
|
||||
|
||||
func flattenFlipgroupList(fg_list flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, fg := range fg_list {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": fg.AccountID,
|
||||
"account_name": fg.AccountName,
|
||||
"client_ids": fg.ClientIDs,
|
||||
"client_names": fg.ClientNames,
|
||||
"client_type": fg.ClientType,
|
||||
"conn_id": fg.ConnID,
|
||||
"conn_type": fg.ConnType,
|
||||
"created_by": fg.CreatedBy,
|
||||
"created_time": fg.CreatedTime,
|
||||
"default_gw": fg.DefaultGW,
|
||||
"deleted_by": fg.DeletedBy,
|
||||
"deleted_time": fg.DeletedTime,
|
||||
"desc": fg.Description,
|
||||
"gid": fg.GID,
|
||||
"guid": fg.GUID,
|
||||
"flipgroup_id": fg.ID,
|
||||
"ip": fg.IP,
|
||||
"milestones": fg.Milestones,
|
||||
"name": fg.Name,
|
||||
"net_id": fg.NetID,
|
||||
"net_type": fg.NetType,
|
||||
"network": fg.Network,
|
||||
"rg_id": fg.RGID,
|
||||
"rg_name": fg.RGName,
|
||||
"status": fg.Status,
|
||||
"updated_by": fg.UpdatedBy,
|
||||
"updated_time": fg.UpdatedTime,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
309
internal/service/cloudapi/flipgroup/resource_flipgroup.go
Normal file
309
internal/service/cloudapi/flipgroup/resource_flipgroup.go
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
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>
|
||||
Tim Tkachev, <tvtkachev@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 flipgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func resourceFlipgroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceFlipgroupCreate called with name: %s, accountID %v", d.Get("name").(string), d.Get("account_id").(int))
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := flipgroup.CreateRequest{
|
||||
AccountID: uint64(d.Get("account_id").(int)),
|
||||
Name: d.Get("name").(string),
|
||||
NetType: d.Get("net_type").(string),
|
||||
NetID: uint64(d.Get("net_id").(int)),
|
||||
ClientType: d.Get("client_type").(string),
|
||||
IP: d.Get("ip").(string),
|
||||
Description: d.Get("desc").(string),
|
||||
}
|
||||
|
||||
resp, err := c.CloudAPI().FLIPGroup().Create(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(fmt.Sprint(resp.ID))
|
||||
|
||||
var warnings dc.Warnings
|
||||
|
||||
if client_ids, ok := d.GetOk("client_ids"); ok {
|
||||
casted := client_ids.([]interface{})
|
||||
addComputesAfterCreation(ctx, &warnings, c, casted, resp.ID)
|
||||
}
|
||||
|
||||
defer resourceFlipgroupRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
}
|
||||
|
||||
func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
flattenFlipgroup(d, fg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceFlipgroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceFlipgroupUpdate called with id: %v", d.Get("flipgroup_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
var warnings dc.Warnings
|
||||
basicUpdate := false
|
||||
req := flipgroup.EditRequest{FLIPGroupID: fg.ID}
|
||||
|
||||
if d.HasChange("desc") {
|
||||
req.Description = d.Get("desc").(string)
|
||||
basicUpdate = true
|
||||
}
|
||||
|
||||
if d.HasChange("name") {
|
||||
req.Name = d.Get("name").(string)
|
||||
basicUpdate = true
|
||||
}
|
||||
|
||||
if basicUpdate {
|
||||
_, err := c.CloudAPI().FLIPGroup().Edit(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("client_ids") {
|
||||
handleClientIDsUpdate(ctx, d, c, fg, &warnings)
|
||||
}
|
||||
|
||||
defer resourceFlipgroupRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
}
|
||||
|
||||
func resourceFlipgroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
log.Debugf("resourceFlipgroupDelete called with id: %v", d.Get("flipgroup_id").(int))
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
fg, err := utilityFlipgroupCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
req := flipgroup.DeleteRequest{
|
||||
FLIPGroupID: fg.ID,
|
||||
}
|
||||
|
||||
_, err = c.CloudAPI().FLIPGroup().Delete(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceFlipgroupSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "Account ID",
|
||||
},
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Flipgroup name",
|
||||
},
|
||||
"net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
Description: "EXTNET or ViNS ID",
|
||||
},
|
||||
"net_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, true),
|
||||
Description: "Network type, EXTNET or VINS",
|
||||
},
|
||||
"client_type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
Description: "Type of client, 'compute' ('vins' will be later)",
|
||||
ValidateFunc: validation.StringInSlice([]string{"compute"}, true),
|
||||
},
|
||||
"ip": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "IP address to associate with this group. If empty, the platform will autoselect IP address",
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Text description of this Flipgroup instance",
|
||||
},
|
||||
"client_ids": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
},
|
||||
Description: "List of clients attached to this Flipgroup instance",
|
||||
},
|
||||
"flipgroup_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"client_names": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
},
|
||||
},
|
||||
"conn_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"conn_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"gid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"guid": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"network": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"rg_name": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"status": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ResourceFlipgroup() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
SchemaVersion: 1,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
StateContext: schema.ImportStatePassthroughContext,
|
||||
},
|
||||
|
||||
CreateContext: resourceFlipgroupCreate,
|
||||
ReadContext: resourceFlipgroupRead,
|
||||
UpdateContext: resourceFlipgroupUpdate,
|
||||
DeleteContext: resourceFlipgroupDelete,
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout300s,
|
||||
Read: &constants.Timeout300s,
|
||||
Update: &constants.Timeout300s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
},
|
||||
|
||||
Schema: resourceFlipgroupSchemaMake(),
|
||||
}
|
||||
}
|
||||
167
internal/service/cloudapi/flipgroup/utility_flipgroup.go
Normal file
167
internal/service/cloudapi/flipgroup/utility_flipgroup.go
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
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>
|
||||
Tim Tkachev, <tvtkachev@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 flipgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func handleClientIDsUpdate(ctx context.Context, d *schema.ResourceData, c *controller.ControllerCfg, fg *flipgroup.ItemFLIPGroup, warn *dc.Warnings) {
|
||||
addedClients := make([]interface{}, 0)
|
||||
removedClients := make([]interface{}, 0)
|
||||
|
||||
old_set, new_set := d.GetChange("client_ids")
|
||||
oldSlice := old_set.([]interface{})
|
||||
newSlice := new_set.([]interface{})
|
||||
|
||||
for _, oldElem := range oldSlice {
|
||||
if !containsClient(newSlice, oldElem) {
|
||||
removedClients = append(removedClients, oldElem)
|
||||
}
|
||||
}
|
||||
|
||||
for _, newElem := range newSlice {
|
||||
if !containsClient(oldSlice, newElem) {
|
||||
addedClients = append(addedClients, newElem)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("Found client_ids change with %v deletion(s) and %v addition(s) [flipgroupID=%v]", len(removedClients), len(addedClients), fg.ID)
|
||||
|
||||
if len(addedClients) > 0 {
|
||||
for _, id := range addedClients {
|
||||
req := flipgroup.ComputeAddRequest{
|
||||
FLIPGroupID: fg.ID,
|
||||
ComputeID: uint64(id.(int)),
|
||||
}
|
||||
|
||||
if _, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req); err != nil {
|
||||
warn.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(removedClients) > 0 {
|
||||
for _, id := range removedClients {
|
||||
req := flipgroup.ComputeRemoveRequest{
|
||||
FLIPGroupID: fg.ID,
|
||||
ComputeID: uint64(id.(int)),
|
||||
}
|
||||
|
||||
if _, err := c.CloudAPI().FLIPGroup().ComputeRemove(ctx, req); err != nil {
|
||||
warn.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func containsClient(set []interface{}, check interface{}) bool {
|
||||
for _, elem := range set {
|
||||
elemConv := elem.(int)
|
||||
checkConv := check.(int)
|
||||
if elemConv == checkConv {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func addComputesAfterCreation(ctx context.Context, warnings *dc.Warnings, c *controller.ControllerCfg, compute_ids []interface{}, flipgroupID uint64) {
|
||||
if len(compute_ids) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("Adding %v computes to flipgroup [id=%v]...", len(compute_ids), flipgroupID)
|
||||
|
||||
for _, elem := range compute_ids {
|
||||
compute_id := uint64(elem.(int))
|
||||
req := flipgroup.ComputeAddRequest{
|
||||
FLIPGroupID: flipgroupID,
|
||||
ComputeID: compute_id,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().FLIPGroup().ComputeAdd(ctx, req)
|
||||
if err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func utilityFlipgroupCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*flipgroup.ItemFLIPGroup, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := flipgroup.GetRequest{}
|
||||
|
||||
if d.Id() == "" {
|
||||
req.FLIPGroupID = uint64(d.Get("flipgroup_id").(int))
|
||||
} else {
|
||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.FLIPGroupID = id
|
||||
}
|
||||
|
||||
fg, err := c.CloudAPI().FLIPGroup().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fg, err
|
||||
}
|
||||
|
||||
func utilityFlipgroupListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (flipgroup.ListFLIPGroups, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := flipgroup.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))
|
||||
}
|
||||
|
||||
fg_list, err := c.CloudAPI().FLIPGroup().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fg_list, err
|
||||
}
|
||||
@@ -33,6 +33,8 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
@@ -168,6 +170,14 @@ 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)
|
||||
for _, k8sGroup := range k8SGroupList {
|
||||
labels := make([]string, 0)
|
||||
for _, label := range k8sGroup.Labels {
|
||||
if strings.HasPrefix(label, "workersGroupName") {
|
||||
continue
|
||||
}
|
||||
|
||||
labels = append(labels, label)
|
||||
}
|
||||
temp := map[string]interface{}{
|
||||
"annotations": k8sGroup.Annotations,
|
||||
"cpu": k8sGroup.CPU,
|
||||
@@ -175,7 +185,7 @@ func flattenK8sGroup(k8SGroupList k8s.ListK8SGroups, workers []compute.RecordCom
|
||||
"disk": k8sGroup.Disk,
|
||||
"guid": k8sGroup.GUID,
|
||||
"id": k8sGroup.ID,
|
||||
"labels": k8sGroup.Labels,
|
||||
"labels": labels,
|
||||
"name": k8sGroup.Name,
|
||||
"num": k8sGroup.Num,
|
||||
"ram": k8sGroup.RAM,
|
||||
@@ -323,12 +333,21 @@ 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)
|
||||
for _, label := range wg.Labels {
|
||||
if strings.HasPrefix(label, "workersGroupName") {
|
||||
continue
|
||||
}
|
||||
|
||||
labels = append(labels, label)
|
||||
}
|
||||
|
||||
d.Set("annotations", wg.Annotations)
|
||||
d.Set("cpu", wg.CPU)
|
||||
d.Set("detailed_info", flattenDetailedInfo(wg.DetailedInfo, computes))
|
||||
d.Set("disk", wg.Disk)
|
||||
d.Set("guid", wg.GUID)
|
||||
d.Set("labels", wg.Labels)
|
||||
d.Set("labels", labels)
|
||||
d.Set("name", wg.Name)
|
||||
d.Set("num", wg.Num)
|
||||
d.Set("ram", wg.RAM)
|
||||
|
||||
@@ -32,7 +32,9 @@ Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/w
|
||||
|
||||
package k8s
|
||||
|
||||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func nodeMasterDefault() K8sNodeRecord {
|
||||
return K8sNodeRecord{
|
||||
|
||||
@@ -123,7 +123,9 @@ func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{
|
||||
if labels, ok := d.GetOk("labels"); ok {
|
||||
labels := labels.([]interface{})
|
||||
for _, label := range labels {
|
||||
createReq.Labels = append(createReq.Labels, label.(string))
|
||||
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||
createReq.Labels = append(createReq.Labels, label.(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
|
||||
if !haveK8sID {
|
||||
return diag.Errorf("resourceK8sCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
|
||||
return diag.Errorf("resourceK8sWgCreate: can't create k8s cluster because K8sID %d is not allowed or does not exist", d.Get("k8s_id").(int))
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
@@ -71,7 +71,9 @@ func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
|
||||
labels, _ := d.Get("labels").([]interface{})
|
||||
for _, label := range labels {
|
||||
req.Labels = append(req.Labels, label.(string))
|
||||
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||
req.Labels = append(req.Labels, label.(string))
|
||||
}
|
||||
}
|
||||
|
||||
annotations, _ := d.Get("annotations").([]interface{})
|
||||
@@ -317,11 +319,11 @@ func ResourceK8sWg() *schema.Resource {
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout600s,
|
||||
Read: &constants.Timeout600s,
|
||||
Update: &constants.Timeout600s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
Create: &constants.Timeout20m,
|
||||
Read: &constants.Timeout20m,
|
||||
Update: &constants.Timeout20m,
|
||||
Delete: &constants.Timeout20m,
|
||||
Default: &constants.Timeout20m,
|
||||
},
|
||||
|
||||
Schema: resourceK8sWgSchemaMake(),
|
||||
|
||||
@@ -35,6 +35,7 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
@@ -148,7 +149,9 @@ func addWGs(ctx context.Context, c *controller.ControllerCfg, cluster *k8s.Recor
|
||||
|
||||
labels, _ := found_wg["labels"].([]interface{})
|
||||
for _, label := range labels {
|
||||
req.Labels = append(req.Labels, label.(string))
|
||||
if !strings.HasPrefix(label.(string), "workersGroupName") {
|
||||
req.Labels = append(req.Labels, label.(string))
|
||||
}
|
||||
}
|
||||
|
||||
annotations, _ := found_wg["annotations"].([]interface{})
|
||||
|
||||
@@ -296,7 +296,6 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
||||
log.Debugf("flattenCompute: ID %d, RG ID %d", computeRec.ID, computeRec.RGID)
|
||||
|
||||
devices, _ := json.Marshal(computeRec.Devices)
|
||||
userdata, _ := json.Marshal(computeRec.Userdata)
|
||||
bootDisk := findBootDisk(computeRec.Disks)
|
||||
|
||||
//check extraDisks, ipa_type, is,
|
||||
@@ -307,16 +306,13 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute) er
|
||||
d.Set("affinity_weight", computeRec.AffinityWeight)
|
||||
d.Set("arch", computeRec.Architecture)
|
||||
d.Set("boot_order", computeRec.BootOrder)
|
||||
d.Set("boot_disk_size", computeRec.BootDiskSize)
|
||||
d.Set("boot_disk_size", bootDisk.SizeMax)
|
||||
d.Set("boot_disk", flattenBootDisk(bootDisk))
|
||||
d.Set("boot_disk_id", bootDisk.ID)
|
||||
d.Set("sep_id", bootDisk.SepID)
|
||||
d.Set("pool", bootDisk.Pool)
|
||||
d.Set("clone_reference", computeRec.CloneReference)
|
||||
d.Set("clones", computeRec.Clones)
|
||||
if string(userdata) != "{}" {
|
||||
d.Set("cloud_init", string(userdata))
|
||||
}
|
||||
d.Set("computeci_id", computeRec.ComputeCIID)
|
||||
d.Set("created_by", computeRec.CreatedBy)
|
||||
d.Set("created_time", computeRec.CreatedTime)
|
||||
|
||||
@@ -35,6 +35,7 @@ package kvmvm
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
||||
@@ -142,8 +143,8 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if ok {
|
||||
userdata := argVal.(string)
|
||||
if userdata != "" && userdata != "applied" {
|
||||
createReqPPC.Userdata = userdata
|
||||
createReqX86.Userdata = userdata
|
||||
createReqPPC.Userdata = strings.TrimSpace(userdata)
|
||||
createReqX86.Userdata = strings.TrimSpace(userdata)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
argVal, ok = d.GetOk("network")
|
||||
if ok && argVal.(*schema.Set).Len() > 0 {
|
||||
log.Debugf("resourceComputeCreate: calling utilityComputeNetworksConfigure to attach %d network(s)", argVal.(*schema.Set).Len())
|
||||
err = utilityComputeNetworksConfigure(ctx, d, m, false, true)
|
||||
err = utilityComputeNetworksConfigure(ctx, d, m, false, true, computeId)
|
||||
if err != nil {
|
||||
log.Errorf("resourceComputeCreate: error when attaching networks to a new Compute ID %d: %s", computeId, err)
|
||||
cleanup = true
|
||||
@@ -592,7 +593,7 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
log.Debugf("resourceComputeUpdate: enable=%t Compute ID %s after completing its resource configuration", d.Id(), enabled)
|
||||
log.Debugf("resourceComputeUpdate: enable=%s Compute ID %v after completing its resource configuration", d.Id(), enabled)
|
||||
}
|
||||
|
||||
// check compute statuses
|
||||
@@ -693,16 +694,21 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
}
|
||||
|
||||
err = utilityComputeNetworksConfigure(ctx, d, m, true, false) // pass do_delta = true to apply changes, if any
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
if d.HasChange("network") {
|
||||
err = utilityComputeNetworksConfigure(ctx, d, m, true, false, computeRec.ID) // pass do_delta = true to apply changes, if any
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("description") || d.HasChange("name") {
|
||||
req := compute.UpdateRequest{
|
||||
ComputeID: computeRec.ID,
|
||||
Name: d.Get("name").(string),
|
||||
Description: d.Get("desc").(string),
|
||||
ComputeID: computeRec.ID,
|
||||
Name: d.Get("name").(string),
|
||||
}
|
||||
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
|
||||
if _, err := c.CloudAPI().Compute().Update(ctx, req); err != nil {
|
||||
@@ -1529,7 +1535,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
Description: "Name of this compute. Compute names are case sensitive and must be unique in the resource group.",
|
||||
},
|
||||
|
||||
@@ -1830,7 +1835,7 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
"started": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: true,
|
||||
Description: "Is compute started.",
|
||||
},
|
||||
"detach_disks": {
|
||||
|
||||
@@ -144,11 +144,21 @@ func utilityComputeExtraDisksConfigure(ctx context.Context, d *schema.ResourceDa
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool, skip_zero bool) error {
|
||||
func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData, m interface{}, do_delta bool, skip_zero bool, computeID uint64) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
old_set, new_set := d.GetChange("network")
|
||||
|
||||
req := compute.StopRequest{
|
||||
ComputeID: computeID,
|
||||
Force: true,
|
||||
}
|
||||
|
||||
_, err := c.CloudAPI().Compute().Stop(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
apiErrCount := 0
|
||||
var lastSavedError error
|
||||
|
||||
@@ -232,6 +242,14 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
}
|
||||
}
|
||||
|
||||
startReq := compute.StartRequest{ComputeID: computeID}
|
||||
|
||||
_, err = c.CloudAPI().Compute().Start(ctx, startReq)
|
||||
if err != nil {
|
||||
apiErrCount++
|
||||
lastSavedError = err
|
||||
}
|
||||
|
||||
if apiErrCount > 0 {
|
||||
log.Errorf("utilityComputeNetworksConfigure: there were %d error(s) when managing networks of Compute ID %s. Last error was: %s",
|
||||
apiErrCount, d.Id(), lastSavedError)
|
||||
|
||||
@@ -847,11 +847,11 @@ func ResourceVins() *schema.Resource {
|
||||
},
|
||||
|
||||
Timeouts: &schema.ResourceTimeout{
|
||||
Create: &constants.Timeout600s,
|
||||
Read: &constants.Timeout300s,
|
||||
Update: &constants.Timeout300s,
|
||||
Delete: &constants.Timeout300s,
|
||||
Default: &constants.Timeout300s,
|
||||
Create: &constants.Timeout20m,
|
||||
Read: &constants.Timeout600s,
|
||||
Update: &constants.Timeout20m,
|
||||
Delete: &constants.Timeout600s,
|
||||
Default: &constants.Timeout600s,
|
||||
},
|
||||
|
||||
Schema: resourceVinsSchemaMake(),
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
samples/cloudapi/data_flipgroup/main.tf
Normal file
32
samples/cloudapi/data_flipgroup/main.tf
Normal file
@@ -0,0 +1,32 @@
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
controller_url = "https://mr4.digitalenergy.online"
|
||||
app_id = ""
|
||||
app_secret = ""
|
||||
}
|
||||
|
||||
data "decort_flipgroup" "fg" {
|
||||
# ID флипгруппы
|
||||
# Обязательный параметр
|
||||
# int
|
||||
flipgroup_id = 999
|
||||
}
|
||||
|
||||
output "fg_out" {
|
||||
value = data.decort_flipgroup.fg
|
||||
}
|
||||
37
samples/cloudapi/data_flipgroup_list/main.tf
Normal file
37
samples/cloudapi/data_flipgroup_list/main.tf
Normal file
@@ -0,0 +1,37 @@
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
controller_url = "https://mr4.digitalenergy.online"
|
||||
app_id = ""
|
||||
app_secret = ""
|
||||
}
|
||||
|
||||
data "decort_flipgroup_list" "fg" {
|
||||
# Номер страницы
|
||||
# Опциональный параметр
|
||||
# int
|
||||
page = 0
|
||||
|
||||
# Размер страницы
|
||||
# Опциональный параметр
|
||||
# int
|
||||
size = 0
|
||||
}
|
||||
|
||||
output "fg_out" {
|
||||
value = data.decort_flipgroup_list.fg
|
||||
}
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "terraform.local/local/decort"
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
/* terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
version = "1.1"
|
||||
source = "digitalenergy.online/decort/decort"
|
||||
version = "<VERSION>"
|
||||
source = "basis/decort/decort"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
samples/cloudapi/resource_flipgroup/main.tf
Normal file
67
samples/cloudapi/resource_flipgroup/main.tf
Normal file
@@ -0,0 +1,67 @@
|
||||
#Расскомментируйте этот код,
|
||||
#и внесите необходимые правки в версию и путь,
|
||||
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
|
||||
/*
|
||||
terraform {
|
||||
required_providers {
|
||||
decort = {
|
||||
source = "basis/decort/decort"
|
||||
version = "<VERSION>"
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
provider "decort" {
|
||||
authenticator = "oauth2"
|
||||
oauth2_url = "https://sso.digitalenergy.online"
|
||||
controller_url = "https://mr4.digitalenergy.online"
|
||||
app_id = ""
|
||||
app_secret = ""
|
||||
}
|
||||
|
||||
resource "decort_flipgroup" "fg" {
|
||||
# ID аккаунта
|
||||
# Обязательный параметр
|
||||
# int
|
||||
account_id = 999
|
||||
|
||||
# Наименование Flipgroup
|
||||
# Обязательный параметр
|
||||
# string
|
||||
name = "flipgroup_name"
|
||||
|
||||
# Тип сети (EXTNET, ViNS)
|
||||
# Обязательный параметр
|
||||
# string
|
||||
net_type = "EXTNET"
|
||||
|
||||
# ID сети
|
||||
# Обязательный параметр
|
||||
# int
|
||||
net_id = 13
|
||||
|
||||
# Тип клиентов (в данный момент поддерживается только тип 'compute')
|
||||
# Обязательный параметр
|
||||
# string
|
||||
client_type = "compute"
|
||||
|
||||
# IP-адрес
|
||||
# Опциональный параметр
|
||||
# string
|
||||
ip = "127.0.0.1"
|
||||
|
||||
# Список клиентов, прикрепленных к флипгруппе
|
||||
# Опциональный параметр
|
||||
# []int
|
||||
client_ids = [11269]
|
||||
|
||||
# Описание флипгруппы
|
||||
# Опциональный параметр
|
||||
# string
|
||||
desc = "CHANGED"
|
||||
}
|
||||
|
||||
output "fg_out" {
|
||||
value = decort_flipgroup.fg
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user