parent
f49d9f8860
commit
91ba361af9
@ -1,36 +1,31 @@
|
|||||||
## Version 4.5.2
|
## Version 4.5.3
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Added resource_limits.cu_dm string field for account, account_consumed_units and account_reserved_units data sources in cloudapi/account
|
- Change field Value in schema resource kvmvm in blocks affinity_rules and anti_affinity_rules from required to optional in cloudapi and cloudbroker
|
||||||
- Fixed restore of account resource in cloudapi/account, it happens if restore parameter is set to true
|
- Change the format ID in resource k8s_wg from wg_id to k8s_id#wg_id
|
||||||
- Fixed restore of bservice resource in cloudapi/bservice, it happens if restore parameter is set to true and only once
|
- Fix scripts intall.bat and intall.sh
|
||||||
- Fixed enable of bservice resource in cloudapi/bservice, it happens if enable parameter is set to true
|
- Increased timeouts for resources account, disk, cdrom_image, image, virtual_image, k8s_wg, vins, rg in cloudbroker so that they match the same from cloudapi
|
||||||
- Fixed terraform state update for bservice resource update in cloudapi/bservice
|
- Increased timeouts for resources pcidevice, sep, sep_config in cloudbroker
|
||||||
- Fixed terraform state update for bservice_group resource update in cloudapi/bservice
|
- Fix bug in affinity_rules in cloudbroker/kvmvm
|
||||||
- Added entry_count field for bservice_snapshot_list data source in cloudapi/bservice
|
- Add field NeedReboot in cloudapi/kvmvm in data_source, data_source_list and resource schemas
|
||||||
- Added items.shareable boolean field for disk_list_unattached data source in cloudapi/disks
|
- Fix bug with field ExtNetID in CreateInRGRequest in cloudapi/vins and cloudbroker/vins
|
||||||
- Added items.status string field for extnet_list data source in cloudapi/extnet
|
- Add boolean field Safe in Restart func in resource cloudapi/lb
|
||||||
- Fixed multiple minor typos in samples/cloudapi
|
- Add field force_resize in Resize func in resource cloudapi/kvmvm and cloudbroker/kvmvm
|
||||||
- Added account_name string, created_by string, created_time int, deleted_by string, deleted_time int, network string, rg_id int, rg_name string, updated_by string, updated_by int fields for flipgroup data source and resource in cloudapi/flipgroup
|
- Fix bug in cloudBroker/kvmvm with disk and extra_disks
|
||||||
- Removed net_mask string, ckey string fields for flipgroup data source and resource in cloudapi/flipgroup
|
- Change logic from disk delete and disk add to disk rename when disk.disk_name field is changed in resource cloudapi/kvmvm and cloudbroker/kvmvm
|
||||||
- Add meta list field for flipgroup_list data source in cloudapi/flipgroup
|
- Fix allowed network plugin value from "weawenet" to "weavenet" for k8ci, k8s resources in cloudbroker and for k8s resource in cloudapi
|
||||||
- Fixed net_mask string field for fligroup_list data source in cloudapi/flipgroup
|
- Fix bug with deleting decort_bservice resource when setting enable=false in cloudapi/bservice
|
||||||
- Fixed id string field for image data source in cloudapi/image
|
- Fix panic in data source decort_bservice_snapshot_list in cloudapi/bservice
|
||||||
- Fix account_name string field for k8s_list data source in cloudapi/k8s
|
- Fix panic in data source decort_rg_affinity_groups_list in cloudapi/rg
|
||||||
- Add network_plugin string field for k8s and k8s_list data sources in cloudapi/k8s
|
- Fix change description in resource decort_cb_kvmvm in cloudbroker
|
||||||
- Fixed terraform state update for k8s, k8_cp and k8s_wg resources update in cloudapi/k8s
|
- Computed field bootdisk_size has been renamed to boot_disk_size in data sources decort_kvmvm, decort_kvmvm_list, decort_cb_kvmvm_list in cloudapi and cloudbroker
|
||||||
- Add image_name string, interfaces.enabled boolean fields for compute data source in cloudapi/kvmvm
|
- Change request logic for delete resource decort_cb_k8s_cp in cloudbroker
|
||||||
- Add the interfaces field to the creation request in cloudapi/kvmvm
|
- Fix schema in datasource decort_cb_kvmvm in cloudbroker, fields boot_disk_id, sep_id, pool, extra_disks, network, net_id, net_type, ip_address, mac have been removes
|
||||||
- Fixed restore of kvmvm resource in cloudapi/kvmvm, it happens if restore parameter is set to true
|
- Fix panic with RG in cloudapi
|
||||||
- The logic of network connection has been changed, only the first network connects to the kvmvm in the stopped status, the subsequent ones connect without stopping
|
- Fix permanently field for disks delete in decort_kvmvm in cloudapi/kvmvm and decort_cb_kvmvm in cloudbroker/kvmvm
|
||||||
- Token receipt has been removed from the controller
|
- Fix bug with enable request duplication
|
||||||
- Add start/stop function after create for lb in cloudapi/lb
|
|
||||||
- Fixed restore of lb resource in cloudapi/lb, it happens if restore parameter is set to true
|
### Feature
|
||||||
- Add field auth_broker in data source location list in cloudapi/location
|
|
||||||
- Add fields cpu_allocation_parameter and cpu_allocation_ratio in data source rg list lb deleted in cloudapi/rg
|
- Add RAM divisibility validation in compute, k8s, k8s_cp and k8s_wg resources in cloudapi and cloudbroker
|
||||||
- Add fields backend_haip and frontend_haip in data source rg list in cloudapi/rg
|
- Add "permanently" flag in k8s, k8s_cp in cloudapi
|
||||||
- Change type field Ram QuotaRecord struct in cloudapi/rg/models
|
|
||||||
- Add state upgrader for rg in cloudapi/rg
|
|
||||||
- Add field owner to the creation request in cloudapi/rg
|
|
||||||
- Fixed restore of rg resource in cloudapi/rg, it happens if restore parameter is set to true
|
|
||||||
- Add fields enabled and routesroutes in data source vins in cloudapi/vins
|
|
@ -1,32 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package constants
|
package constants
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
// timeouts for API calls from CRUD functions of Terraform plugin
|
// timeouts for API calls from CRUD functions of Terraform plugin
|
||||||
var Timeout30s = time.Second * 30
|
var Timeout30s = time.Second * 30
|
||||||
var Timeout60s = time.Second * 60
|
var Timeout60s = time.Second * 60
|
||||||
var Timeout180s = time.Second * 180
|
var Timeout180s = time.Second * 180
|
||||||
var Timeout300s = time.Second * 300
|
var Timeout300s = time.Second * 300
|
||||||
var Timeout600s = time.Second * 600
|
var Timeout600s = time.Second * 600
|
||||||
var Timeout20m = time.Minute * 20
|
var Timeout900s = time.Second * 900
|
||||||
var Timeout30m = time.Minute * 30
|
var Timeout20m = time.Minute * 20
|
||||||
|
var Timeout30m = time.Minute * 30
|
||||||
|
@ -1,168 +1,169 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/location"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/location"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Provider() *schema.Provider {
|
func Provider() *schema.Provider {
|
||||||
return &schema.Provider{
|
return &schema.Provider{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"authenticator": {
|
"authenticator": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
ValidateFunc: validation.StringInSlice([]string{"decs3o", "legacy", "jwt", "bvs"}, true), // ignore case while validating
|
||||||
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"oauth2_url": {
|
"oauth2_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
|
||||||
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
Description: "OAuth2 application URL in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"controller_url": {
|
"controller_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
StateFunc: statefuncs.StateFuncToLower,
|
StateFunc: statefuncs.StateFuncToLower,
|
||||||
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
|
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"user": {
|
"user": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
|
||||||
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"password": {
|
"password": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_user": {
|
"bvs_user": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_USER", nil),
|
||||||
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"bvs_password": {
|
"bvs_password": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_BVS_PASSWORD", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"domain": {
|
"domain": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_DOMAIN", nil),
|
||||||
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
Description: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_id": {
|
"app_id": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
|
||||||
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"app_secret": {
|
"app_secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
|
||||||
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
Description: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"jwt": {
|
"jwt": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
|
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
|
||||||
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
|
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"allow_unverified_ssl": {
|
"allow_unverified_ssl": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: false,
|
Default: false,
|
||||||
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
|
||||||
},
|
},
|
||||||
|
|
||||||
"path_cfg": {
|
"path_cfg": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "The path of the configuration file entry",
|
Description: "The path of the configuration file entry",
|
||||||
},
|
},
|
||||||
|
|
||||||
"path_token": {
|
"path_token": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "The path of the token file entry",
|
Description: "The path of the token file entry",
|
||||||
},
|
},
|
||||||
|
|
||||||
"time_to_refresh": {
|
"time_to_refresh": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
Description: "The number of minutes before the expiration of the token, a refresh will be made",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
},
|
||||||
ResourcesMap: newResourcesMap(),
|
|
||||||
|
ResourcesMap: newResourcesMap(),
|
||||||
DataSourcesMap: newDataSourcesMap(),
|
|
||||||
|
DataSourcesMap: newDataSourcesMap(),
|
||||||
ConfigureContextFunc: providerConfigure,
|
|
||||||
}
|
ConfigureContextFunc: providerConfigure,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
|
||||||
decsController, err := controller.ControllerConfigure(d)
|
func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
|
||||||
if err != nil {
|
decsController, err := controller.ControllerConfigure(d)
|
||||||
return nil, diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
return nil, diag.FromErr(err)
|
||||||
|
}
|
||||||
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController)
|
|
||||||
if err != nil {
|
gridId, err := location.UtilityLocationGetDefaultGridID(ctx, decsController)
|
||||||
return nil, diag.FromErr(err)
|
if err != nil {
|
||||||
}
|
return nil, diag.FromErr(err)
|
||||||
if gridId == 0 {
|
}
|
||||||
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0"))
|
if gridId == 0 {
|
||||||
}
|
return nil, diag.FromErr(fmt.Errorf("providerConfigure: invalid default Grid ID = 0"))
|
||||||
|
}
|
||||||
return decsController, nil
|
|
||||||
}
|
return decsController, nil
|
||||||
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lb, err := utilityLBCheckPresence(ctx, d, m)
|
lb, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(lb.ID, 10))
|
d.SetId(strconv.FormatUint(lb.ID, 10))
|
||||||
|
|
||||||
flattenLB(d, lb)
|
flattenLB(d, lb)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceLB() *schema.Resource {
|
func DataSourceLB() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceLBRead,
|
ReadContext: dataSourceLBRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dsLBSchemaMake(),
|
Schema: dsLBSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
lbList, err := utilityLBListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenLBList(lbList))
|
d.Set("items", flattenLBList(lbList))
|
||||||
d.Set("entry_count", lbList.EntryCount)
|
d.Set("entry_count", lbList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceLBList() *schema.Resource {
|
func DataSourceLBList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceLBListRead,
|
ReadContext: dataSourceLBListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dsLBListSchemaMake(),
|
Schema: dsLBListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenLBList(lbList))
|
d.Set("items", flattenLBList(lbList))
|
||||||
d.Set("entry_count", lbList.EntryCount)
|
d.Set("entry_count", lbList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceLBListDeleted() *schema.Resource {
|
func DataSourceLBListDeleted() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceLBListDeletedRead,
|
ReadContext: dataSourceLBListDeletedRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dsLBListDeletedSchemaMake(),
|
Schema: dsLBListDeletedSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,467 +1,470 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBCreate")
|
log.Debugf("resourceLBCreate")
|
||||||
|
|
||||||
haveRGID, err := existRGID(ctx, d, m)
|
haveRGID, err := existRGID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveRGID {
|
if !haveRGID {
|
||||||
return diag.Errorf("resourceLBCreate: can't create LB because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
return diag.Errorf("resourceLBCreate: can't create LB because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
haveExtNetID, err := existExtNetID(ctx, d, m)
|
haveExtNetID, err := existExtNetID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveExtNetID {
|
if !haveExtNetID {
|
||||||
return diag.Errorf("resourceLBCreate: can't create LB because ExtNetID %d is not allowed or does not exist", d.Get("extnet_id").(int))
|
return diag.Errorf("resourceLBCreate: can't create LB because ExtNetID %d is not allowed or does not exist", d.Get("extnet_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
haveVins, err := existViNSID(ctx, d, m)
|
haveVins, err := existViNSID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveVins {
|
if !haveVins {
|
||||||
return diag.Errorf("resourceLBCreate: can't create LB because ViNSID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
return diag.Errorf("resourceLBCreate: can't create LB because ViNSID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.CreateRequest{
|
req := lb.CreateRequest{
|
||||||
Name: d.Get("name").(string),
|
Name: d.Get("name").(string),
|
||||||
RGID: uint64(d.Get("rg_id").(int)),
|
RGID: uint64(d.Get("rg_id").(int)),
|
||||||
ExtNetID: uint64(d.Get("extnet_id").(int)),
|
ExtNetID: uint64(d.Get("extnet_id").(int)),
|
||||||
VINSID: uint64(d.Get("vins_id").(int)),
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
Start: d.Get("start").(bool),
|
Start: d.Get("start").(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
if desc, ok := d.GetOk("desc"); ok {
|
if desc, ok := d.GetOk("desc"); ok {
|
||||||
req.Description = desc.(string)
|
req.Description = desc.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if haMode, ok := d.GetOk("ha_mode"); ok {
|
if haMode, ok := d.GetOk("ha_mode"); ok {
|
||||||
req.HighlyAvailable = haMode.(bool)
|
req.HighlyAvailable = haMode.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
lbId, err := c.CloudAPI().LB().Create(ctx, req)
|
lbId, err := c.CloudAPI().LB().Create(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(lbId, 10))
|
d.SetId(strconv.FormatUint(lbId, 10))
|
||||||
d.Set("lb_id", lbId)
|
d.Set("lb_id", lbId)
|
||||||
|
|
||||||
w := dc.Warnings{}
|
w := dc.Warnings{}
|
||||||
|
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
req := lb.DisableEnableRequest{
|
req := lb.DisableEnableRequest{
|
||||||
LBID: lbId,
|
LBID: lbId,
|
||||||
}
|
}
|
||||||
|
|
||||||
if enable.(bool) {
|
if enable.(bool) {
|
||||||
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
w.Add(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
w.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
||||||
if start.(bool) {
|
if start.(bool) {
|
||||||
req := lb.StartRequest{LBID: lbId}
|
req := lb.StartRequest{LBID: lbId}
|
||||||
_, err := c.CloudAPI().LB().Start(ctx, req)
|
_, err := c.CloudAPI().LB().Start(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
w.Add(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
req := lb.StopRequest{LBID: lbId}
|
req := lb.StopRequest{LBID: lbId}
|
||||||
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.Add(err)
|
w.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return append(w.Get(), resourceLBRead(ctx, d, m)...)
|
return append(w.Get(), resourceLBRead(ctx, d, m)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBRead")
|
log.Debugf("resourceLBRead")
|
||||||
|
|
||||||
// c := m.(*controller.ControllerCfg)
|
// c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
lbRec, err := utilityLBCheckPresence(ctx, d, m)
|
lbRec, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
if lbRec == nil {
|
if lbRec == nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged := false
|
hasChanged := false
|
||||||
|
|
||||||
switch lbRec.Status {
|
switch lbRec.Status {
|
||||||
case status.Modeled:
|
case status.Modeled:
|
||||||
return diag.Errorf("The LB is in status: %s, please, contact support for more information", lbRec.Status)
|
return diag.Errorf("The LB is in status: %s, please, contact support for more information", lbRec.Status)
|
||||||
case status.Creating:
|
case status.Creating:
|
||||||
case status.Created:
|
case status.Created:
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
// lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
// lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
// restoreReq := lb.RestoreRequest{LBID: lbId}
|
// restoreReq := lb.RestoreRequest{LBID: lbId}
|
||||||
// enableReq := lb.DisableEnableRequest{LBID: lbId}
|
// enableReq := lb.DisableEnableRequest{LBID: lbId}
|
||||||
|
|
||||||
// _, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
// _, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return diag.FromErr(err)
|
// return diag.FromErr(err)
|
||||||
// }
|
// }
|
||||||
// _, err = c.CloudAPI().LB().Enable(ctx, enableReq)
|
// _, err = c.CloudAPI().LB().Enable(ctx, enableReq)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// return diag.FromErr(err)
|
// return diag.FromErr(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// hasChanged = true
|
// hasChanged = true
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
// return resourceLBCreate(ctx, d, m)
|
// return resourceLBCreate(ctx, d, m)
|
||||||
case status.Enabled:
|
case status.Enabled:
|
||||||
case status.Enabling:
|
case status.Enabling:
|
||||||
case status.Disabling:
|
case status.Disabling:
|
||||||
case status.Disabled:
|
case status.Disabled:
|
||||||
log.Debugf("The LB is in status: %s, troubles may occur with update. Please, enable LB first.", lbRec.Status)
|
log.Debugf("The LB is in status: %s, troubles may occur with update. Please, enable LB first.", lbRec.Status)
|
||||||
case status.Restoring:
|
case status.Restoring:
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasChanged {
|
if hasChanged {
|
||||||
lbRec, err = utilityLBCheckPresence(ctx, d, m)
|
lbRec, err = utilityLBCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flattenResourceLB(d, lbRec)
|
flattenResourceLB(d, lbRec)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBDelete")
|
log.Debugf("resourceLBDelete")
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
lbId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
req := lb.DeleteRequest{
|
req := lb.DeleteRequest{
|
||||||
LBID: lbId,
|
LBID: lbId,
|
||||||
}
|
}
|
||||||
|
|
||||||
if permanently, ok := d.GetOk("permanently"); ok {
|
if permanently, ok := d.GetOk("permanently"); ok {
|
||||||
req.Permanently = permanently.(bool)
|
req.Permanently = permanently.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Delete(ctx, req)
|
_, err := c.CloudAPI().LB().Delete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBUpdate")
|
log.Debugf("resourceLBUpdate")
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
haveRGID, err := existRGID(ctx, d, m)
|
haveRGID, err := existRGID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveRGID {
|
if !haveRGID {
|
||||||
return diag.Errorf("resourceLBUpdate: can't update LB because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
return diag.Errorf("resourceLBUpdate: can't update LB because RGID %d is not allowed or does not exist", d.Get("rg_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
haveExtNetID, err := existExtNetID(ctx, d, m)
|
haveExtNetID, err := existExtNetID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveExtNetID {
|
if !haveExtNetID {
|
||||||
return diag.Errorf("resourceLBUpdate: can't update LB because ExtNetID %d is not allowed or does not exist", d.Get("extnet_id").(int))
|
return diag.Errorf("resourceLBUpdate: can't update LB because ExtNetID %d is not allowed or does not exist", d.Get("extnet_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
haveVins, err := existViNSID(ctx, d, m)
|
haveVins, err := existViNSID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveVins {
|
if !haveVins {
|
||||||
return diag.Errorf("resourceLBUpdate: can't update LB because ViNSID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
return diag.Errorf("resourceLBUpdate: can't update LB because ViNSID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
lbRec, err := utilityLBCheckPresence(ctx, d, m)
|
lbRec, err := utilityLBCheckPresence(ctx, d, m)
|
||||||
if lbRec == nil {
|
if lbRec == nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged := false
|
hasChanged := false
|
||||||
|
|
||||||
switch lbRec.Status {
|
switch lbRec.Status {
|
||||||
case status.Modeled:
|
case status.Modeled:
|
||||||
return diag.Errorf("The LB is in status: %s, please, contact support for more information", lbRec.Status)
|
return diag.Errorf("The LB is in status: %s, please, contact support for more information", lbRec.Status)
|
||||||
case status.Creating:
|
case status.Creating:
|
||||||
case status.Created:
|
case status.Created:
|
||||||
case status.Deleting:
|
case status.Deleting:
|
||||||
case status.Deleted:
|
case status.Deleted:
|
||||||
if restore, ok := d.GetOk("restore"); ok && restore.(bool) {
|
if restore, ok := d.GetOk("restore"); ok && restore.(bool) {
|
||||||
restoreReq := lb.RestoreRequest{LBID: lbRec.ID}
|
restoreReq := lb.RestoreRequest{LBID: lbRec.ID}
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
_, err := c.CloudAPI().LB().Restore(ctx, restoreReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if enable, ok := d.GetOk("enable"); ok {
|
if enable, ok := d.GetOk("enable"); ok {
|
||||||
req := lb.DisableEnableRequest{
|
req := lb.DisableEnableRequest{
|
||||||
LBID: lbRec.ID,
|
LBID: lbRec.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if enable.(bool) {
|
if enable.(bool) {
|
||||||
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
if start, ok := d.GetOk("start"); ok && enable.(bool) {
|
||||||
if start.(bool) {
|
if start.(bool) {
|
||||||
req := lb.StartRequest{LBID: lbRec.ID}
|
req := lb.StartRequest{LBID: lbRec.ID}
|
||||||
_, err := c.CloudAPI().LB().Start(ctx, req)
|
_, err := c.CloudAPI().LB().Start(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
req := lb.StopRequest{LBID: lbRec.ID}
|
req := lb.StopRequest{LBID: lbRec.ID}
|
||||||
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hasChanged = true
|
hasChanged = true
|
||||||
case status.Destroying:
|
case status.Destroying:
|
||||||
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
return diag.Errorf("The LB is in progress with status: %s", lbRec.Status)
|
||||||
case status.Destroyed:
|
case status.Destroyed:
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
return diag.Errorf("The resource cannot be updated because it has been destroyed")
|
||||||
// return resourceLBCreate(ctx, d, m)
|
// return resourceLBCreate(ctx, d, m)
|
||||||
case status.Enabled:
|
case status.Enabled:
|
||||||
case status.Enabling:
|
case status.Enabling:
|
||||||
case status.Disabling:
|
case status.Disabling:
|
||||||
case status.Disabled:
|
case status.Disabled:
|
||||||
log.Debugf("The LB is in status: %s, troubles may occur with update. Please, enable LB first.", lbRec.Status)
|
log.Debugf("The LB is in status: %s, troubles may occur with update. Please, enable LB first.", lbRec.Status)
|
||||||
case status.Restoring:
|
case status.Restoring:
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasChanged {
|
if hasChanged {
|
||||||
_, err = utilityLBCheckPresence(ctx, d, m)
|
_, err = utilityLBCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("ha_mode") {
|
if d.HasChange("ha_mode") {
|
||||||
hamode := d.Get("ha_mode").(bool)
|
hamode := d.Get("ha_mode").(bool)
|
||||||
if hamode {
|
if hamode {
|
||||||
req := lb.HighlyAvailableRequest{
|
req := lb.HighlyAvailableRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
_, err := c.CloudAPI().LB().HighlyAvailable(ctx, req)
|
_, err := c.CloudAPI().LB().HighlyAvailable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("enable") {
|
if d.HasChange("enable") {
|
||||||
enable := d.Get("enable").(bool)
|
enable := d.Get("enable").(bool)
|
||||||
req := lb.DisableEnableRequest{
|
req := lb.DisableEnableRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
if enable {
|
if enable {
|
||||||
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
_, err := c.CloudAPI().LB().Enable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
_, err := c.CloudAPI().LB().Disable(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("start") {
|
if d.HasChange("start") {
|
||||||
start := d.Get("start").(bool)
|
start := d.Get("start").(bool)
|
||||||
lbId := uint64(d.Get("lb_id").(int))
|
lbId := uint64(d.Get("lb_id").(int))
|
||||||
if start {
|
if start {
|
||||||
req := lb.StartRequest{LBID: lbId}
|
req := lb.StartRequest{LBID: lbId}
|
||||||
_, err := c.CloudAPI().LB().Start(ctx, req)
|
_, err := c.CloudAPI().LB().Start(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
req := lb.StopRequest{LBID: lbId}
|
req := lb.StopRequest{LBID: lbId}
|
||||||
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
_, err := c.CloudAPI().LB().Stop(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("desc") {
|
if d.HasChange("desc") {
|
||||||
req := lb.UpdateRequest{
|
req := lb.UpdateRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
Description: d.Get("desc").(string),
|
Description: d.Get("desc").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().LB().Update(ctx, req)
|
_, err := c.CloudAPI().LB().Update(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("restart") {
|
if d.HasChange("restart") {
|
||||||
restart := d.Get("restart").(bool)
|
restart := d.Get("restart").(bool)
|
||||||
if restart {
|
if restart {
|
||||||
req := lb.RestartRequest{
|
req := lb.RestartRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
|
if safe, ok:= d.GetOk("safe"); ok {
|
||||||
_, err := c.CloudAPI().LB().Restart(ctx, req)
|
req.Safe = safe.(bool)
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
_, err := c.CloudAPI().LB().Restart(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
if d.HasChange("restore") {
|
}
|
||||||
restore := d.Get("restore").(bool)
|
}
|
||||||
if restore {
|
|
||||||
req := lb.RestoreRequest{
|
if d.HasChange("restore") {
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
restore := d.Get("restore").(bool)
|
||||||
}
|
if restore {
|
||||||
|
req := lb.RestoreRequest{
|
||||||
_, err := c.CloudAPI().LB().Restore(ctx, req)
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
_, err := c.CloudAPI().LB().Restore(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
if d.HasChange("config_reset") {
|
}
|
||||||
cfgReset := d.Get("config_reset").(bool)
|
}
|
||||||
if cfgReset {
|
|
||||||
req := lb.ConfigResetRequest{
|
if d.HasChange("config_reset") {
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
cfgReset := d.Get("config_reset").(bool)
|
||||||
}
|
if cfgReset {
|
||||||
|
req := lb.ConfigResetRequest{
|
||||||
_, err := c.CloudAPI().LB().ConfigReset(ctx, req)
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
if err != nil {
|
}
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
_, err := c.CloudAPI().LB().ConfigReset(ctx, req)
|
||||||
}
|
if err != nil {
|
||||||
}
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
return resourceLBRead(ctx, d, m)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceLB() *schema.Resource {
|
return resourceLBRead(ctx, d, m)
|
||||||
return &schema.Resource{
|
}
|
||||||
SchemaVersion: 1,
|
|
||||||
|
func ResourceLB() *schema.Resource {
|
||||||
CreateContext: resourceLBCreate,
|
return &schema.Resource{
|
||||||
ReadContext: resourceLBRead,
|
SchemaVersion: 1,
|
||||||
UpdateContext: resourceLBUpdate,
|
|
||||||
DeleteContext: resourceLBDelete,
|
CreateContext: resourceLBCreate,
|
||||||
|
ReadContext: resourceLBRead,
|
||||||
Importer: &schema.ResourceImporter{
|
UpdateContext: resourceLBUpdate,
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
DeleteContext: resourceLBDelete,
|
||||||
},
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
Timeouts: &schema.ResourceTimeout{
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
Create: &constants.Timeout600s,
|
},
|
||||||
Read: &constants.Timeout300s,
|
|
||||||
Update: &constants.Timeout300s,
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Delete: &constants.Timeout300s,
|
Create: &constants.Timeout600s,
|
||||||
Default: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
},
|
Update: &constants.Timeout300s,
|
||||||
|
Delete: &constants.Timeout300s,
|
||||||
Schema: lbResourceSchemaMake(),
|
Default: &constants.Timeout300s,
|
||||||
}
|
},
|
||||||
}
|
|
||||||
|
Schema: lbResourceSchemaMake(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,379 +1,379 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendCreate")
|
log.Debugf("resourceLBBackendCreate")
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBBackendCreate: can't create LB backend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBBackendCreate: can't create LB backend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.BackendCreateRequest{}
|
req := lb.BackendCreateRequest{}
|
||||||
|
|
||||||
req.BackendName = d.Get("name").(string)
|
req.BackendName = d.Get("name").(string)
|
||||||
req.LBID = uint64(d.Get("lb_id").(int))
|
req.LBID = uint64(d.Get("lb_id").(int))
|
||||||
|
|
||||||
if algorithm, ok := d.GetOk("algorithm"); ok {
|
if algorithm, ok := d.GetOk("algorithm"); ok {
|
||||||
req.Algorithm = algorithm.(string)
|
req.Algorithm = algorithm.(string)
|
||||||
}
|
}
|
||||||
if inter, ok := d.GetOk("inter"); ok {
|
if inter, ok := d.GetOk("inter"); ok {
|
||||||
req.Inter = uint64(inter.(int))
|
req.Inter = uint64(inter.(int))
|
||||||
}
|
}
|
||||||
if downinter, ok := d.GetOk("downinter"); ok {
|
if downinter, ok := d.GetOk("downinter"); ok {
|
||||||
req.DownInter = uint64(downinter.(int))
|
req.DownInter = uint64(downinter.(int))
|
||||||
}
|
}
|
||||||
if rise, ok := d.GetOk("rise"); ok {
|
if rise, ok := d.GetOk("rise"); ok {
|
||||||
req.Rise = uint64(rise.(int))
|
req.Rise = uint64(rise.(int))
|
||||||
}
|
}
|
||||||
if fall, ok := d.GetOk("fall"); ok {
|
if fall, ok := d.GetOk("fall"); ok {
|
||||||
req.Fall = uint64(fall.(int))
|
req.Fall = uint64(fall.(int))
|
||||||
}
|
}
|
||||||
if slowstart, ok := d.GetOk("slowstart"); ok {
|
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||||
req.SlowStart = uint64(slowstart.(int))
|
req.SlowStart = uint64(slowstart.(int))
|
||||||
}
|
}
|
||||||
if maxconn, ok := d.GetOk("maxconn"); ok {
|
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||||
req.MaxConn = uint64(maxconn.(int))
|
req.MaxConn = uint64(maxconn.(int))
|
||||||
}
|
}
|
||||||
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||||
req.MaxQueue = uint64(maxqueue.(int))
|
req.MaxQueue = uint64(maxqueue.(int))
|
||||||
}
|
}
|
||||||
if weight, ok := d.GetOk("weight"); ok {
|
if weight, ok := d.GetOk("weight"); ok {
|
||||||
req.Weight = uint64(weight.(int))
|
req.Weight = uint64(weight.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendCreate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendCreate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("name").(string))
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("name").(string))
|
||||||
|
|
||||||
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
_, err = utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBBackendRead(ctx, d, m)
|
return resourceLBBackendRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendRead")
|
log.Debugf("resourceLBBackendRead")
|
||||||
|
|
||||||
b, err := utilityLBBackendCheckPresence(ctx, d, m)
|
b, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
if b == nil {
|
if b == nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
||||||
|
|
||||||
flattenResourceLBBackend(d, b, lbId)
|
flattenResourceLBBackend(d, b, lbId)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendDelete")
|
log.Debugf("resourceLBBackendDelete")
|
||||||
|
|
||||||
_, err := utilityLBBackendCheckPresence(ctx, d, m)
|
_, err := utilityLBBackendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.BackendDeleteRequest{
|
req := lb.BackendDeleteRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
BackendName: d.Get("name").(string),
|
BackendName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendDelete(ctx, req)
|
_, err = c.CloudAPI().LB().BackendDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendEdit")
|
log.Debugf("resourceLBBackendEdit")
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBBackendUpdate: can't update LB backend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBBackendUpdate: can't update LB backend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
req := lb.BackendUpdateRequest{
|
req := lb.BackendUpdateRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
BackendName: d.Get("name").(string),
|
BackendName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("algorithm") {
|
if d.HasChange("algorithm") {
|
||||||
req.Algorithm = d.Get("algorithm").(string)
|
req.Algorithm = d.Get("algorithm").(string)
|
||||||
}
|
}
|
||||||
if d.HasChange("inter") {
|
if d.HasChange("inter") {
|
||||||
req.Inter = uint64(d.Get("inter").(int))
|
req.Inter = uint64(d.Get("inter").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("downinter") {
|
if d.HasChange("downinter") {
|
||||||
req.DownInter = uint64(d.Get("downinter").(int))
|
req.DownInter = uint64(d.Get("downinter").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("rise") {
|
if d.HasChange("rise") {
|
||||||
req.Rise = uint64(d.Get("rise").(int))
|
req.Rise = uint64(d.Get("rise").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("fall") {
|
if d.HasChange("fall") {
|
||||||
req.Fall = uint64(d.Get("fall").(int))
|
req.Fall = uint64(d.Get("fall").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("slowstart") {
|
if d.HasChange("slowstart") {
|
||||||
req.SlowStart = uint64(d.Get("slowstart").(int))
|
req.SlowStart = uint64(d.Get("slowstart").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("maxconn") {
|
if d.HasChange("maxconn") {
|
||||||
req.MaxConn = uint64(d.Get("maxconn").(int))
|
req.MaxConn = uint64(d.Get("maxconn").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("maxqueue") {
|
if d.HasChange("maxqueue") {
|
||||||
req.MaxQueue = uint64(d.Get("maxqueue").(int))
|
req.MaxQueue = uint64(d.Get("maxqueue").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("weight") {
|
if d.HasChange("weight") {
|
||||||
req.Weight = uint64(d.Get("weight").(int))
|
req.Weight = uint64(d.Get("weight").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBBackendRead(ctx, d, m)
|
return resourceLBBackendRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceLBBackend() *schema.Resource {
|
func ResourceLBBackend() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceLBBackendCreate,
|
CreateContext: resourceLBBackendCreate,
|
||||||
ReadContext: resourceLBBackendRead,
|
ReadContext: resourceLBBackendRead,
|
||||||
UpdateContext: resourceLBBackendUpdate,
|
UpdateContext: resourceLBBackendUpdate,
|
||||||
DeleteContext: resourceLBBackendDelete,
|
DeleteContext: resourceLBBackendDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout600s,
|
||||||
Read: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
Update: &constants.Timeout300s,
|
Update: &constants.Timeout300s,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout300s,
|
||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout300s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"lb_id": {
|
"lb_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the LB instance to backendCreate",
|
Description: "ID of the LB instance to backendCreate",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
},
|
},
|
||||||
"algorithm": {
|
"algorithm": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"roundrobin", "static-rr", "leastconn"}, false),
|
ValidateFunc: validation.StringInSlice([]string{"roundrobin", "static-rr", "leastconn"}, false),
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"downinter": {
|
"downinter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"fall": {
|
"fall": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"inter": {
|
"inter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxconn": {
|
"maxconn": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxqueue": {
|
"maxqueue": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rise": {
|
"rise": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"slowstart": {
|
"slowstart": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"weight": {
|
"weight": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"servers": {
|
"servers": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"address": {
|
"address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"check": {
|
"check": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"server_settings": {
|
"server_settings": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"downinter": {
|
"downinter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"fall": {
|
"fall": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"inter": {
|
"inter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxconn": {
|
"maxconn": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxqueue": {
|
"maxqueue": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rise": {
|
"rise": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"slowstart": {
|
"slowstart": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"weight": {
|
"weight": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,320 +1,320 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendServerCreate")
|
log.Debugf("resourceLBBackendServerCreate")
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBBackendServerCreate: can't create LB backend server because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBBackendServerCreate: can't create LB backend server because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.BackendServerAddRequest{
|
req := lb.BackendServerAddRequest{
|
||||||
BackendName: d.Get("backend_name").(string),
|
BackendName: d.Get("backend_name").(string),
|
||||||
ServerName: d.Get("name").(string),
|
ServerName: d.Get("name").(string),
|
||||||
Address: d.Get("address").(string),
|
Address: d.Get("address").(string),
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
Port: uint64(d.Get("port").(int)),
|
Port: uint64(d.Get("port").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if check, ok := d.GetOk("check"); ok {
|
if check, ok := d.GetOk("check"); ok {
|
||||||
req.Check = check.(string)
|
req.Check = check.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if inter, ok := d.GetOk("inter"); ok {
|
if inter, ok := d.GetOk("inter"); ok {
|
||||||
req.Inter = uint64(inter.(int))
|
req.Inter = uint64(inter.(int))
|
||||||
}
|
}
|
||||||
if downinter, ok := d.GetOk("downinter"); ok {
|
if downinter, ok := d.GetOk("downinter"); ok {
|
||||||
req.DownInter = uint64(downinter.(int))
|
req.DownInter = uint64(downinter.(int))
|
||||||
}
|
}
|
||||||
if rise, ok := d.GetOk("rise"); ok {
|
if rise, ok := d.GetOk("rise"); ok {
|
||||||
req.Rise = uint64(rise.(int))
|
req.Rise = uint64(rise.(int))
|
||||||
}
|
}
|
||||||
if fall, ok := d.GetOk("fall"); ok {
|
if fall, ok := d.GetOk("fall"); ok {
|
||||||
req.Fall = uint64(fall.(int))
|
req.Fall = uint64(fall.(int))
|
||||||
}
|
}
|
||||||
if slowstart, ok := d.GetOk("slowstart"); ok {
|
if slowstart, ok := d.GetOk("slowstart"); ok {
|
||||||
req.SlowStart = uint64(slowstart.(int))
|
req.SlowStart = uint64(slowstart.(int))
|
||||||
}
|
}
|
||||||
if maxconn, ok := d.GetOk("maxconn"); ok {
|
if maxconn, ok := d.GetOk("maxconn"); ok {
|
||||||
req.MaxConn = uint64(maxconn.(int))
|
req.MaxConn = uint64(maxconn.(int))
|
||||||
}
|
}
|
||||||
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
if maxqueue, ok := d.GetOk("maxqueue"); ok {
|
||||||
req.MaxQueue = uint64(maxqueue.(int))
|
req.MaxQueue = uint64(maxqueue.(int))
|
||||||
}
|
}
|
||||||
if weight, ok := d.GetOk("weight"); ok {
|
if weight, ok := d.GetOk("weight"); ok {
|
||||||
req.Weight = uint64(weight.(int))
|
req.Weight = uint64(weight.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerAdd(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerAdd(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("backend_name").(string) + "#" + d.Get("name").(string))
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("backend_name").(string) + "#" + d.Get("name").(string))
|
||||||
|
|
||||||
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBBackendServerRead(ctx, d, m)
|
return resourceLBBackendServerRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendServerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendServerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendServerRead")
|
log.Debugf("resourceLBBackendServerRead")
|
||||||
|
|
||||||
s, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
s, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
||||||
backendName := strings.Split(d.Id(), "#")[1]
|
backendName := strings.Split(d.Id(), "#")[1]
|
||||||
|
|
||||||
flattenResourceLBBackendServer(d, s, lbId, backendName)
|
flattenResourceLBBackendServer(d, s, lbId, backendName)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendServerDelete")
|
log.Debugf("resourceLBBackendServerDelete")
|
||||||
|
|
||||||
_, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
_, err := utilityLBBackendServerCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.BackendServerDeleteRequest{
|
req := lb.BackendServerDeleteRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
BackendName: d.Get("backend_name").(string),
|
BackendName: d.Get("backend_name").(string),
|
||||||
ServerName: d.Get("name").(string),
|
ServerName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBBackendServerUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBBackendServerUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBBackendServerEdit")
|
log.Debugf("resourceLBBackendServerEdit")
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBBackendServerUpdate: can't update LB backend server because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBBackendServerUpdate: can't update LB backend server because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
req := lb.BackendServerUpdateRequest{
|
req := lb.BackendServerUpdateRequest{
|
||||||
BackendName: d.Get("backend_name").(string),
|
BackendName: d.Get("backend_name").(string),
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
ServerName: d.Get("name").(string),
|
ServerName: d.Get("name").(string),
|
||||||
Address: d.Get("address").(string),
|
Address: d.Get("address").(string),
|
||||||
Port: uint64(d.Get("port").(int)),
|
Port: uint64(d.Get("port").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("check") {
|
if d.HasChange("check") {
|
||||||
req.Check = d.Get("check").(string)
|
req.Check = d.Get("check").(string)
|
||||||
}
|
}
|
||||||
if d.HasChange("inter") {
|
if d.HasChange("inter") {
|
||||||
req.Inter = uint64(d.Get("inter").(int))
|
req.Inter = uint64(d.Get("inter").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("downinter") {
|
if d.HasChange("downinter") {
|
||||||
req.DownInter = uint64(d.Get("downinter").(int))
|
req.DownInter = uint64(d.Get("downinter").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("rise") {
|
if d.HasChange("rise") {
|
||||||
req.Rise = uint64(d.Get("rise").(int))
|
req.Rise = uint64(d.Get("rise").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("fall") {
|
if d.HasChange("fall") {
|
||||||
req.Fall = uint64(d.Get("fall").(int))
|
req.Fall = uint64(d.Get("fall").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("slowstart") {
|
if d.HasChange("slowstart") {
|
||||||
req.SlowStart = uint64(d.Get("slowstart").(int))
|
req.SlowStart = uint64(d.Get("slowstart").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("maxconn") {
|
if d.HasChange("maxconn") {
|
||||||
req.MaxConn = uint64(d.Get("maxconn").(int))
|
req.MaxConn = uint64(d.Get("maxconn").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("maxqueue") {
|
if d.HasChange("maxqueue") {
|
||||||
req.MaxQueue = uint64(d.Get("maxqueue").(int))
|
req.MaxQueue = uint64(d.Get("maxqueue").(int))
|
||||||
}
|
}
|
||||||
if d.HasChange("weight") {
|
if d.HasChange("weight") {
|
||||||
req.Weight = uint64(d.Get("weight").(int))
|
req.Weight = uint64(d.Get("weight").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().BackendServerUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().BackendServerUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: перенести servers сюда
|
//TODO: перенести servers сюда
|
||||||
|
|
||||||
return resourceLBBackendServerRead(ctx, d, m)
|
return resourceLBBackendServerRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceLBBackendServer() *schema.Resource {
|
func ResourceLBBackendServer() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceLBBackendServerCreate,
|
CreateContext: resourceLBBackendServerCreate,
|
||||||
ReadContext: resourceLBBackendServerRead,
|
ReadContext: resourceLBBackendServerRead,
|
||||||
UpdateContext: resourceLBBackendServerUpdate,
|
UpdateContext: resourceLBBackendServerUpdate,
|
||||||
DeleteContext: resourceLBBackendServerDelete,
|
DeleteContext: resourceLBBackendServerDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout600s,
|
||||||
Read: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
Update: &constants.Timeout300s,
|
Update: &constants.Timeout300s,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout300s,
|
||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout300s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"lb_id": {
|
"lb_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the LB instance to backendCreate",
|
Description: "ID of the LB instance to backendCreate",
|
||||||
},
|
},
|
||||||
"backend_name": {
|
"backend_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
|
Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
|
||||||
},
|
},
|
||||||
"address": {
|
"address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "IP address of the server.",
|
Description: "IP address of the server.",
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Port number on the server",
|
Description: "Port number on the server",
|
||||||
},
|
},
|
||||||
"check": {
|
"check": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ValidateFunc: validation.StringInSlice([]string{"disabled", "enabled"}, false),
|
ValidateFunc: validation.StringInSlice([]string{"disabled", "enabled"}, false),
|
||||||
Description: "set to disabled if this server should be used regardless of its state.",
|
Description: "set to disabled if this server should be used regardless of its state.",
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"downinter": {
|
"downinter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"fall": {
|
"fall": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"inter": {
|
"inter": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxconn": {
|
"maxconn": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"maxqueue": {
|
"maxqueue": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rise": {
|
"rise": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"slowstart": {
|
"slowstart": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"weight": {
|
"weight": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,195 +1,195 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendCreate")
|
log.Debugf("resourceLBFrontendCreate")
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBFrontendCreate: can't create LB frontend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBFrontendCreate: can't create LB frontend because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.FrontendCreateRequest{
|
req := lb.FrontendCreateRequest{
|
||||||
BackendName: d.Get("backend_name").(string),
|
BackendName: d.Get("backend_name").(string),
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
FrontendName: d.Get("name").(string),
|
FrontendName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendCreate(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendCreate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("name").(string))
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("name").(string))
|
||||||
|
|
||||||
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBFrontendRead(ctx, d, m)
|
return resourceLBFrontendRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendRead")
|
log.Debugf("resourceLBFrontendRead")
|
||||||
|
|
||||||
f, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
f, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
||||||
|
|
||||||
flattenLBFrontend(d, f, lbId)
|
flattenLBFrontend(d, f, lbId)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendDelete")
|
log.Debugf("resourceLBFrontendDelete")
|
||||||
|
|
||||||
_, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
_, err := utilityLBFrontendCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.FrontendDeleteRequest{
|
req := lb.FrontendDeleteRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
FrontendName: d.Get("name").(string),
|
FrontendName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendDelete(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceLBFrontend() *schema.Resource {
|
func ResourceLBFrontend() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceLBFrontendCreate,
|
CreateContext: resourceLBFrontendCreate,
|
||||||
ReadContext: resourceLBFrontendRead,
|
ReadContext: resourceLBFrontendRead,
|
||||||
UpdateContext: resourceLBFrontendEdit,
|
UpdateContext: resourceLBFrontendEdit,
|
||||||
DeleteContext: resourceLBFrontendDelete,
|
DeleteContext: resourceLBFrontendDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout600s,
|
||||||
Read: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
Update: &constants.Timeout300s,
|
Update: &constants.Timeout300s,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout300s,
|
||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout300s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"lb_id": {
|
"lb_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the LB instance to backendCreate",
|
Description: "ID of the LB instance to backendCreate",
|
||||||
},
|
},
|
||||||
"backend_name": {
|
"backend_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"bindings": {
|
"bindings": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"address": {
|
"address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,216 +1,216 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package lb
|
package lb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendBindCreate")
|
log.Debugf("resourceLBFrontendBindCreate")
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBFrontendBindCreate: can't create LB frontend bind because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBFrontendBindCreate: can't create LB frontend bind because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.FrontendBindRequest{
|
req := lb.FrontendBindRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
FrontendName: d.Get("frontend_name").(string),
|
FrontendName: d.Get("frontend_name").(string),
|
||||||
BindingName: d.Get("name").(string),
|
BindingName: d.Get("name").(string),
|
||||||
BindingAddress: d.Get("address").(string),
|
BindingAddress: d.Get("address").(string),
|
||||||
BindingPort: uint64(d.Get("port").(int)),
|
BindingPort: uint64(d.Get("port").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBind(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBind(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("frontend_name").(string) + "#" + d.Get("name").(string))
|
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "#" + d.Get("frontend_name").(string) + "#" + d.Get("name").(string))
|
||||||
|
|
||||||
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBFrontendBindRead(ctx, d, m)
|
return resourceLBFrontendBindRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendBindRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendBindRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendBindRead")
|
log.Debugf("resourceLBFrontendBindRead")
|
||||||
|
|
||||||
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "#")[0], 10, 32)
|
||||||
frontendName := strings.Split(d.Id(), "#")[1]
|
frontendName := strings.Split(d.Id(), "#")[1]
|
||||||
|
|
||||||
flattenLBFrontendBind(d, b, lbId, frontendName)
|
flattenLBFrontendBind(d, b, lbId, frontendName)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendBindDelete")
|
log.Debugf("resourceLBFrontendBindDelete")
|
||||||
|
|
||||||
_, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
_, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := lb.FrontendBindDeleteRequest{
|
req := lb.FrontendBindDeleteRequest{
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
FrontendName: d.Get("frontend_name").(string),
|
FrontendName: d.Get("frontend_name").(string),
|
||||||
BindingName: d.Get("name").(string),
|
BindingName: d.Get("name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBindDelete(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBindDelete(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceLBFrontendBindUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceLBFrontendBindUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
log.Debugf("resourceLBFrontendBindEdit")
|
log.Debugf("resourceLBFrontendBindEdit")
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
haveLBID, err := existLBID(ctx, d, m)
|
haveLBID, err := existLBID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveLBID {
|
if !haveLBID {
|
||||||
return diag.Errorf("resourceLBFrontendBindUpdate: can't update LB frontend bind because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
return diag.Errorf("resourceLBFrontendBindUpdate: can't update LB frontend bind because LBID %d is not allowed or does not exist", d.Get("lb_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
req := lb.FrontendBindUpdateRequest{
|
req := lb.FrontendBindUpdateRequest{
|
||||||
FrontendName: d.Get("frontend_name").(string),
|
FrontendName: d.Get("frontend_name").(string),
|
||||||
BindingName: d.Get("name").(string),
|
BindingName: d.Get("name").(string),
|
||||||
LBID: uint64(d.Get("lb_id").(int)),
|
LBID: uint64(d.Get("lb_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("address") {
|
if d.HasChange("address") {
|
||||||
req.BindingAddress = d.Get("address").(string)
|
req.BindingAddress = d.Get("address").(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("port") {
|
if d.HasChange("port") {
|
||||||
req.BindingPort = uint64(d.Get("port").(int))
|
req.BindingPort = uint64(d.Get("port").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.CloudAPI().LB().FrontendBindUpdate(ctx, req)
|
_, err = c.CloudAPI().LB().FrontendBindUpdate(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceLBFrontendBindRead(ctx, d, m)
|
return resourceLBFrontendBindRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceLBFrontendBind() *schema.Resource {
|
func ResourceLBFrontendBind() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceLBFrontendBindCreate,
|
CreateContext: resourceLBFrontendBindCreate,
|
||||||
ReadContext: resourceLBFrontendBindRead,
|
ReadContext: resourceLBFrontendBindRead,
|
||||||
UpdateContext: resourceLBFrontendBindUpdate,
|
UpdateContext: resourceLBFrontendBindUpdate,
|
||||||
DeleteContext: resourceLBFrontendBindDelete,
|
DeleteContext: resourceLBFrontendBindDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout600s,
|
Create: &constants.Timeout600s,
|
||||||
Read: &constants.Timeout300s,
|
Read: &constants.Timeout300s,
|
||||||
Update: &constants.Timeout300s,
|
Update: &constants.Timeout300s,
|
||||||
Delete: &constants.Timeout300s,
|
Delete: &constants.Timeout300s,
|
||||||
Default: &constants.Timeout300s,
|
Default: &constants.Timeout300s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"lb_id": {
|
"lb_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of the LB instance to backendCreate",
|
Description: "ID of the LB instance to backendCreate",
|
||||||
},
|
},
|
||||||
"frontend_name": {
|
"frontend_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
Description: "Must be unique among all backends of this LB - name of the new backend to create",
|
||||||
},
|
},
|
||||||
"address": {
|
"address": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,190 +1,190 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package locations
|
package locations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/flattens"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} {
|
func flattenLocationsList(ll *locations.ListLocations) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0, len(ll.Data))
|
res := make([]map[string]interface{}, 0, len(ll.Data))
|
||||||
for _, l := range ll.Data {
|
for _, l := range ll.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"ckey": l.CKey,
|
"ckey": l.CKey,
|
||||||
"meta": flattens.FlattenMeta(l.Meta),
|
"meta": flattens.FlattenMeta(l.Meta),
|
||||||
"auth_broker": l.AuthBroker,
|
"auth_broker": l.AuthBroker,
|
||||||
"flag": l.Flag,
|
"flag": l.Flag,
|
||||||
"gid": l.GID,
|
"gid": l.GID,
|
||||||
"guid": l.GUID,
|
"guid": l.GUID,
|
||||||
"id": l.ID,
|
"id": l.ID,
|
||||||
"location_code": l.LocationCode,
|
"location_code": l.LocationCode,
|
||||||
"name": l.Name,
|
"name": l.Name,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLocationsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
locations, err := utilityLocationsListCheckPresence(ctx, d, m)
|
locations, err := utilityLocationsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
|
|
||||||
d.Set("items", flattenLocationsList(locations))
|
d.Set("items", flattenLocationsList(locations))
|
||||||
d.Set("entry_count", locations.EntryCount)
|
d.Set("entry_count", locations.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
func dataSourceLocationsListSchemaMake() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"flag": {
|
"flag": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Filter by flag",
|
Description: "Filter by flag",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Filter by name",
|
Description: "Filter by name",
|
||||||
},
|
},
|
||||||
"by_id": {
|
"by_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Filter by ID",
|
Description: "Filter by ID",
|
||||||
},
|
},
|
||||||
"location_code": {
|
"location_code": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Filter by location code",
|
Description: "Filter by location code",
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "page number",
|
Description: "page number",
|
||||||
},
|
},
|
||||||
"size": {
|
"size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "page size",
|
Description: "page size",
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Locations list",
|
Description: "Locations list",
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"ckey": {
|
"ckey": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"auth_broker": {
|
"auth_broker": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"flag": {
|
"flag": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Grid id",
|
Description: "Grid id",
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "location id",
|
Description: "location id",
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "location id",
|
Description: "location id",
|
||||||
},
|
},
|
||||||
"location_code": {
|
"location_code": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Location code",
|
Description: "Location code",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Location name",
|
Description: "Location name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"entry_count": {
|
"entry_count": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceLocationsList() *schema.Resource {
|
func DataSourceLocationsList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceLocationsListRead,
|
ReadContext: dataSourceLocationsListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceLocationsListSchemaMake(),
|
Schema: dataSourceLocationsListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,85 +1,85 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package locations
|
package locations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceLocationUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceLocationUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
url, err := utilityLocationUrlCheckPresence(ctx, m)
|
url, err := utilityLocationUrlCheckPresence(ctx, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
|
|
||||||
url = strings.ReplaceAll(url, "\\", "")
|
url = strings.ReplaceAll(url, "\\", "")
|
||||||
url = strings.ReplaceAll(url, "\"", "")
|
url = strings.ReplaceAll(url, "\"", "")
|
||||||
d.Set("url", url)
|
d.Set("url", url)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceLocationUrlSchemaMake() map[string]*schema.Schema {
|
func dataSourceLocationUrlSchemaMake() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"url": {
|
"url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "Location url",
|
Description: "Location url",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceLocationUrl() *schema.Resource {
|
func DataSourceLocationUrl() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceLocationUrlRead,
|
ReadContext: dataSourceLocationUrlRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceLocationUrlSchemaMake(),
|
Schema: dataSourceLocationUrlSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,280 +1,280 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package rg
|
package rg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceRgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceRgListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
rgList, err := utilityRgListCheckPresence(ctx, d, m)
|
rgList, err := utilityRgListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenRgList(rgList))
|
d.Set("items", flattenRgList(rgList))
|
||||||
d.Set("entry_count", rgList.EntryCount)
|
d.Set("entry_count", rgList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
func dataSourceRgListSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
"by_id": {
|
"by_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by ID",
|
Description: "Find by ID",
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by name",
|
Description: "Find by name",
|
||||||
},
|
},
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by account ID",
|
Description: "Find by account ID",
|
||||||
},
|
},
|
||||||
"account_name": {
|
"account_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by account name",
|
Description: "Find by account name",
|
||||||
},
|
},
|
||||||
"created_after": {
|
"created_after": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find RGs created after specific time (unix timestamp)",
|
Description: "Find RGs created after specific time (unix timestamp)",
|
||||||
},
|
},
|
||||||
"created_before": {
|
"created_before": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find RGs created before specific time (unix timestamp)",
|
Description: "Find RGs created before specific time (unix timestamp)",
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by status",
|
Description: "Find by status",
|
||||||
},
|
},
|
||||||
"lock_status": {
|
"lock_status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Find by lock status",
|
Description: "Find by lock status",
|
||||||
},
|
},
|
||||||
"includedeleted": {
|
"includedeleted": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: false,
|
Default: false,
|
||||||
Description: "included deleted resource groups",
|
Description: "included deleted resource groups",
|
||||||
},
|
},
|
||||||
"page": {
|
"page": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page number",
|
Description: "Page number",
|
||||||
},
|
},
|
||||||
"size": {
|
"size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "Page size",
|
Description: "Page size",
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"account_acl": {
|
"account_acl": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: aclSchemaMake(),
|
Schema: aclSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"account_name": {
|
"account_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_by": {
|
"created_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"created_time": {
|
"created_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"def_net_id": {
|
"def_net_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"def_net_type": {
|
"def_net_type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_by": {
|
"deleted_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"deleted_time": {
|
"deleted_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"desc": {
|
"desc": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"dirty": {
|
"dirty": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gid": {
|
"gid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"rg_id": {
|
"rg_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"lock_status": {
|
"lock_status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"milestones": {
|
"milestones": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"register_computes": {
|
"register_computes": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"resource_limits": {
|
"resource_limits": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: resourceLimitsSchemaMake(),
|
Schema: resourceLimitsSchemaMake(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"secret": {
|
"secret": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_by": {
|
"updated_by": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"updated_time": {
|
"updated_time": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"vins": {
|
"vins": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"vms": {
|
"vms": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"resource_types": {
|
"resource_types": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"cpu_allocation_parameter": {
|
"cpu_allocation_parameter": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"cpu_allocation_ratio": {
|
"cpu_allocation_ratio": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"uniq_pools": {
|
"uniq_pools": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"entry_count": {
|
"entry_count": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceRgList() *schema.Resource {
|
func DataSourceRgList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceRgListRead,
|
ReadContext: dataSourceRgListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceRgListSchemaMake(),
|
Schema: dataSourceRgListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,110 +1,110 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceStackRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceStackRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
stack, err := utilityStackCheckPresence(ctx, d, m)
|
stack, err := utilityStackCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("") // ensure ID is empty in this case
|
d.SetId("") // ensure ID is empty in this case
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
d.SetId(strconv.Itoa(d.Get("stack_id").(int)))
|
d.SetId(strconv.Itoa(d.Get("stack_id").(int)))
|
||||||
flattenStack(d, stack)
|
flattenStack(d, stack)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceStackSchemaMake() map[string]*schema.Schema {
|
func dataSourceStackSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
"stack_id": {
|
"stack_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"cpu_allocation_ratio": {
|
"cpu_allocation_ratio": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"descr": {
|
"descr": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"drivers": {
|
"drivers": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"mem_allocation_ratio": {
|
"mem_allocation_ratio": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceStack() *schema.Resource {
|
func DataSourceStack() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceStackRead,
|
ReadContext: dataSourceStackRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceStackSchemaMake(),
|
Schema: dataSourceStackSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
||||||
)
|
)
|
||||||
|
|
||||||
func flattenStackList(stackl *stack.ListStacks) []map[string]interface{} {
|
func flattenStackList(stackl *stack.ListStacks) []map[string]interface{} {
|
||||||
res := make([]map[string]interface{}, 0)
|
res := make([]map[string]interface{}, 0)
|
||||||
for _, stack := range stackl.Data {
|
for _, stack := range stackl.Data {
|
||||||
temp := map[string]interface{}{
|
temp := map[string]interface{}{
|
||||||
"stack_id": stack.ID,
|
"stack_id": stack.ID,
|
||||||
"name": stack.Name,
|
"name": stack.Name,
|
||||||
"status": stack.Status,
|
"status": stack.Status,
|
||||||
"type": stack.Type,
|
"type": stack.Type,
|
||||||
}
|
}
|
||||||
res = append(res, temp)
|
res = append(res, temp)
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func flattenStack(d *schema.ResourceData, details *stack.InfoStack) error {
|
func flattenStack(d *schema.ResourceData, details *stack.InfoStack) error {
|
||||||
log.Debugf("flattenStack: decoded Stack name %q / ID %d",
|
log.Debugf("flattenStack: decoded Stack name %q / ID %d",
|
||||||
details.Name, details.ID)
|
details.Name, details.ID)
|
||||||
|
|
||||||
d.Set("stack_id", details.ID)
|
d.Set("stack_id", details.ID)
|
||||||
d.Set("cpu_allocation_ratio", details.CPUAllocationRatio)
|
d.Set("cpu_allocation_ratio", details.CPUAllocationRatio)
|
||||||
d.Set("name", details.Name)
|
d.Set("name", details.Name)
|
||||||
d.Set("descr", details.Descr)
|
d.Set("descr", details.Descr)
|
||||||
d.Set("mem_allocation_ratio", details.MemAllocationRatio)
|
d.Set("mem_allocation_ratio", details.MemAllocationRatio)
|
||||||
d.Set("status", details.Status)
|
d.Set("status", details.Status)
|
||||||
d.Set("type", details.Type)
|
d.Set("type", details.Type)
|
||||||
d.Set("drivers", details.Drivers)
|
d.Set("drivers", details.Drivers)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,108 +1,108 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
staticRoute, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
staticRoute, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(strconv.FormatUint(staticRoute.ID, 10))
|
d.SetId(strconv.FormatUint(staticRoute.ID, 10))
|
||||||
flattenStaticRouteData(d, staticRoute)
|
flattenStaticRouteData(d, staticRoute)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
func dataSourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
||||||
rets := map[string]*schema.Schema{
|
rets := map[string]*schema.Schema{
|
||||||
"vins_id": {
|
"vins_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Unique ID of the ViNS",
|
Description: "Unique ID of the ViNS",
|
||||||
},
|
},
|
||||||
"route_id": {
|
"route_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "Unique ID of the static route",
|
Description: "Unique ID of the static route",
|
||||||
},
|
},
|
||||||
"compute_ids": {
|
"compute_ids": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"destination": {
|
"destination": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gateway": {
|
"gateway": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"netmask": {
|
"netmask": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return rets
|
return rets
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceStaticRoute() *schema.Resource {
|
func DataSourceStaticRoute() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceStaticRouteRead,
|
ReadContext: dataSourceStaticRouteRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceStaticRouteSchemaMake(),
|
Schema: dataSourceStaticRouteSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,122 +1,122 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceStaticRouteListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceStaticRouteListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
staticRouteList, err := utilityStaticRouteListCheckPresence(ctx, d, m)
|
staticRouteList, err := utilityStaticRouteListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenStaticRouteList(staticRouteList))
|
d.Set("items", flattenStaticRouteList(staticRouteList))
|
||||||
d.Set("entry_count", staticRouteList.EntryCount)
|
d.Set("entry_count", staticRouteList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dataSourceStaticRouteListSchemaMake() map[string]*schema.Schema {
|
func dataSourceStaticRouteListSchemaMake() map[string]*schema.Schema {
|
||||||
res := map[string]*schema.Schema{
|
res := map[string]*schema.Schema{
|
||||||
"vins_id": {
|
"vins_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
Description: "ID of VINS",
|
Description: "ID of VINS",
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"compute_ids": {
|
"compute_ids": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"destination": {
|
"destination": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"gateway": {
|
"gateway": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"guid": {
|
"guid": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"netmask": {
|
"netmask": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"route_id": {
|
"route_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"entry_count": {
|
"entry_count": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceStaticRouteList() *schema.Resource {
|
func DataSourceStaticRouteList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceStaticRouteListRead,
|
ReadContext: dataSourceStaticRouteListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceStaticRouteListSchemaMake(),
|
Schema: dataSourceStaticRouteListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,277 +1,277 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"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/controller"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/dc"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceStaticRouteCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
|
|
||||||
if _, ok := d.GetOk("vins_id"); ok {
|
if _, ok := d.GetOk("vins_id"); ok {
|
||||||
haveVinsID, err := existVinsID(ctx, d, m)
|
haveVinsID, err := existVinsID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveVinsID {
|
if !haveVinsID {
|
||||||
return diag.Errorf("resourceStaticRouteCreate: can't create Static Route because Vins ID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
return diag.Errorf("resourceStaticRouteCreate: can't create Static Route because Vins ID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := vins.StaticRouteAddRequest{
|
req := vins.StaticRouteAddRequest{
|
||||||
VINSID: uint64(d.Get("vins_id").(int)),
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
Destination: d.Get("destination").(string),
|
Destination: d.Get("destination").(string),
|
||||||
Netmask: d.Get("netmask").(string),
|
Netmask: d.Get("netmask").(string),
|
||||||
Gateway: d.Get("gateway").(string),
|
Gateway: d.Get("gateway").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if computesIDS, ok := d.GetOk("compute_ids"); ok {
|
if computesIDS, ok := d.GetOk("compute_ids"); ok {
|
||||||
ids := computesIDS.([]interface{})
|
ids := computesIDS.([]interface{})
|
||||||
|
|
||||||
res := make([]uint64, 10)
|
res := make([]uint64, 10)
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
computeId := uint64(id.(int))
|
computeId := uint64(id.(int))
|
||||||
res = append(res, computeId)
|
res = append(res, computeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.ComputeIds = res
|
req.ComputeIds = res
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
|
_, err := c.CloudAPI().VINS().StaticRouteAdd(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
staticRouteData, err := getStaticRouteData(ctx, d, m)
|
staticRouteData, err := getStaticRouteData(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
|
d.SetId(fmt.Sprintf("%d#%d", req.VINSID, staticRouteData.ID))
|
||||||
|
|
||||||
return resourceStaticRouteRead(ctx, d, m)
|
return resourceStaticRouteRead(ctx, d, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceStaticRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
warnings := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flattenStaticRouteData(d, staticRouteData)
|
flattenStaticRouteData(d, staticRouteData)
|
||||||
|
|
||||||
return warnings.Get()
|
return warnings.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceStaticRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
warnings := dc.Warnings{}
|
warnings := dc.Warnings{}
|
||||||
|
|
||||||
if _, ok := d.GetOk("vins_id"); ok {
|
if _, ok := d.GetOk("vins_id"); ok {
|
||||||
haveVinsID, err := existVinsID(ctx, d, m)
|
haveVinsID, err := existVinsID(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !haveVinsID {
|
if !haveVinsID {
|
||||||
return diag.Errorf("resourceVinsUpdate: can't update Static Route because VinsID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
return diag.Errorf("resourceVinsUpdate: can't update Static Route because VinsID %d is not allowed or does not exist", d.Get("vins_id").(int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
staticRouteData, err := utilityDataStaticRouteCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("compute_ids") {
|
if d.HasChange("compute_ids") {
|
||||||
deletedIds := make([]uint64, 0)
|
deletedIds := make([]uint64, 0)
|
||||||
addedIds := make([]uint64, 0)
|
addedIds := make([]uint64, 0)
|
||||||
|
|
||||||
oldComputeIds, newComputeIds := d.GetChange("compute_ids")
|
oldComputeIds, newComputeIds := d.GetChange("compute_ids")
|
||||||
oldComputeIdsSlice := oldComputeIds.([]interface{})
|
oldComputeIdsSlice := oldComputeIds.([]interface{})
|
||||||
newComputeIdsSlice := newComputeIds.([]interface{})
|
newComputeIdsSlice := newComputeIds.([]interface{})
|
||||||
|
|
||||||
for _, el := range oldComputeIdsSlice {
|
for _, el := range oldComputeIdsSlice {
|
||||||
if !isContainsIds(newComputeIdsSlice, el) {
|
if !isContainsIds(newComputeIdsSlice, el) {
|
||||||
convertedEl := uint64(el.(int))
|
convertedEl := uint64(el.(int))
|
||||||
deletedIds = append(deletedIds, convertedEl)
|
deletedIds = append(deletedIds, convertedEl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, el := range newComputeIdsSlice {
|
for _, el := range newComputeIdsSlice {
|
||||||
if !isContainsIds(oldComputeIdsSlice, el) {
|
if !isContainsIds(oldComputeIdsSlice, el) {
|
||||||
convertedEl := uint64(el.(int))
|
convertedEl := uint64(el.(int))
|
||||||
addedIds = append(addedIds, convertedEl)
|
addedIds = append(addedIds, convertedEl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(deletedIds) > 0 {
|
if len(deletedIds) > 0 {
|
||||||
req := vins.StaticRouteAccessRevokeRequest{
|
req := vins.StaticRouteAccessRevokeRequest{
|
||||||
VINSID: uint64(d.Get("vins_id").(int)),
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
RouteId: staticRouteData.ID,
|
RouteId: staticRouteData.ID,
|
||||||
ComputeIds: deletedIds,
|
ComputeIds: deletedIds,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteAccessRevoke(ctx, req)
|
_, err := c.CloudAPI().VINS().StaticRouteAccessRevoke(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(addedIds) > 0 {
|
if len(addedIds) > 0 {
|
||||||
req := vins.StaticRouteAccessGrantRequest{
|
req := vins.StaticRouteAccessGrantRequest{
|
||||||
VINSID: uint64(d.Get("vins_id").(int)),
|
VINSID: uint64(d.Get("vins_id").(int)),
|
||||||
RouteId: staticRouteData.ID,
|
RouteId: staticRouteData.ID,
|
||||||
ComputeIds: addedIds,
|
ComputeIds: addedIds,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteAccessGrant(ctx, req)
|
_, err := c.CloudAPI().VINS().StaticRouteAccessGrant(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
warnings.Add(err)
|
warnings.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return append(warnings.Get(), resourceStaticRouteRead(ctx, d, m)...)
|
return append(warnings.Get(), resourceStaticRouteRead(ctx, d, m)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func resourceStaticRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
arr := strings.Split(d.Id(), "#")
|
arr := strings.Split(d.Id(), "#")
|
||||||
if len(arr) != 2 {
|
if len(arr) != 2 {
|
||||||
return diag.FromErr(fmt.Errorf("broken state id"))
|
return diag.FromErr(fmt.Errorf("broken state id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
|
vinsId, _ := strconv.ParseUint(arr[0], 10, 64)
|
||||||
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
|
routeId, _ := strconv.ParseUint(arr[1], 10, 64)
|
||||||
|
|
||||||
req := vins.StaticRouteDelRequest{
|
req := vins.StaticRouteDelRequest{
|
||||||
VINSID: vinsId,
|
VINSID: vinsId,
|
||||||
RouteId: routeId,
|
RouteId: routeId,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := c.CloudAPI().VINS().StaticRouteDel(ctx, req)
|
_, err := c.CloudAPI().VINS().StaticRouteDel(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
func resourceStaticRouteSchemaMake() map[string]*schema.Schema {
|
||||||
rets := dataSourceStaticRouteSchemaMake()
|
rets := dataSourceStaticRouteSchemaMake()
|
||||||
rets["route_id"] = &schema.Schema{
|
rets["route_id"] = &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
}
|
}
|
||||||
rets["compute_ids"] = &schema.Schema{
|
rets["compute_ids"] = &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Elem: &schema.Schema{
|
Elem: &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rets["destination"] = &schema.Schema{
|
rets["destination"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
rets["gateway"] = &schema.Schema{
|
rets["gateway"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
}
|
}
|
||||||
rets["netmask"] = &schema.Schema{
|
rets["netmask"] = &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return rets
|
return rets
|
||||||
}
|
}
|
||||||
|
|
||||||
func isContainsIds(els []interface{}, el interface{}) bool {
|
func isContainsIds(els []interface{}, el interface{}) bool {
|
||||||
convEl := el.(int)
|
convEl := el.(int)
|
||||||
for _, elOld := range els {
|
for _, elOld := range els {
|
||||||
if convEl == elOld.(int) {
|
if convEl == elOld.(int) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResourceStaticRoute() *schema.Resource {
|
func ResourceStaticRoute() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
CreateContext: resourceStaticRouteCreate,
|
CreateContext: resourceStaticRouteCreate,
|
||||||
ReadContext: resourceStaticRouteRead,
|
ReadContext: resourceStaticRouteRead,
|
||||||
UpdateContext: resourceStaticRouteUpdate,
|
UpdateContext: resourceStaticRouteUpdate,
|
||||||
DeleteContext: resourceStaticRouteDelete,
|
DeleteContext: resourceStaticRouteDelete,
|
||||||
|
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
StateContext: schema.ImportStatePassthroughContext,
|
StateContext: schema.ImportStatePassthroughContext,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &constants.Timeout20m,
|
Create: &constants.Timeout20m,
|
||||||
Read: &constants.Timeout600s,
|
Read: &constants.Timeout600s,
|
||||||
Update: &constants.Timeout20m,
|
Update: &constants.Timeout20m,
|
||||||
Delete: &constants.Timeout600s,
|
Delete: &constants.Timeout600s,
|
||||||
Default: &constants.Timeout600s,
|
Default: &constants.Timeout600s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: resourceStaticRouteSchemaMake(),
|
Schema: resourceStaticRouteSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,70 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
accountAuditsList, err := utilityAccountAuditsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
d.Set("items", flattenAccountAuditsList(accountAuditsList))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountAuditsList() *schema.Resource {
|
func DataSourceAccountAuditsList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountAuditsListRead,
|
ReadContext: dataSourceAccountAuditsListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountAuditsListSchemaMake(),
|
Schema: dataSourceAccountAuditsListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
accountComputesList, err := utilityAccountComputesListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountComputesList(accountComputesList))
|
d.Set("items", flattenAccountComputesList(accountComputesList))
|
||||||
d.Set("entry_count", accountComputesList.EntryCount)
|
d.Set("entry_count", accountComputesList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountComputesList() *schema.Resource {
|
func DataSourceAccountComputesList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountComputesListRead,
|
ReadContext: dataSourceAccountComputesListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountComputesListSchemaMake(),
|
Schema: dataSourceAccountComputesListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
accountDeletedList, err := utilityAccountDeletedListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenListDeleted(accountDeletedList))
|
d.Set("items", flattenListDeleted(accountDeletedList))
|
||||||
d.Set("entry_count", accountDeletedList.EntryCount)
|
d.Set("entry_count", accountDeletedList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountDeletedList() *schema.Resource {
|
func DataSourceAccountDeletedList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountDeletedListRead,
|
ReadContext: dataSourceAccountDeletedListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountListDeletedSchemaMake(),
|
Schema: dataSourceAccountListDeletedSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,70 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
accountDisksList, err := utilityAccountDisksListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountDisksList(accountDisksList))
|
d.Set("items", flattenAccountDisksList(accountDisksList))
|
||||||
d.Set("entry_count", accountDisksList.EntryCount)
|
d.Set("entry_count", accountDisksList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountDisksList() *schema.Resource {
|
func DataSourceAccountDisksList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountDisksListRead,
|
ReadContext: dataSourceAccountDisksListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountDisksListSchemaMake(),
|
Schema: dataSourceAccountDisksListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
d.Set("items", flattenAccountFlipGroupsList(accountFlipGroupsList))
|
||||||
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
d.Set("entry_count", accountFlipGroupsList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
func DataSourceAccountFlipGroupsList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountFlipGroupsListRead,
|
ReadContext: dataSourceAccountFlipGroupsListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
Schema: dataSourceAccountFlipGroupsListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,72 +1,72 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
Nikita Sorokin, <nesorokin@basistech.ru>
|
Nikita Sorokin, <nesorokin@basistech.ru>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
accountList, err := utilityAccountListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountList(accountList))
|
d.Set("items", flattenAccountList(accountList))
|
||||||
d.Set("entry_count", accountList.EntryCount)
|
d.Set("entry_count", accountList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountList() *schema.Resource {
|
func DataSourceAccountList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountListRead,
|
ReadContext: dataSourceAccountListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountListSchemaMake(),
|
Schema: dataSourceAccountListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
accountRGList, err := utilityAccountRGListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountRGList(accountRGList))
|
d.Set("items", flattenAccountRGList(accountRGList))
|
||||||
d.Set("entry_count", accountRGList.EntryCount)
|
d.Set("entry_count", accountRGList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountRGList() *schema.Resource {
|
func DataSourceAccountRGList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountRGListRead,
|
ReadContext: dataSourceAccountRGListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountRGListSchemaMake(),
|
Schema: dataSourceAccountRGListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package account
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||||
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
accountVinsList, err := utilityAccountVinsListCheckPresence(ctx, d, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
d.SetId(id.String())
|
d.SetId(id.String())
|
||||||
d.Set("items", flattenAccountVinsList(accountVinsList))
|
d.Set("items", flattenAccountVinsList(accountVinsList))
|
||||||
d.Set("entry_count", accountVinsList.EntryCount)
|
d.Set("entry_count", accountVinsList.EntryCount)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DataSourceAccountVinsList() *schema.Resource {
|
func DataSourceAccountVinsList() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
|
|
||||||
ReadContext: dataSourceAccountVinsListRead,
|
ReadContext: dataSourceAccountVinsListRead,
|
||||||
|
|
||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Read: &constants.Timeout30s,
|
Read: &constants.Timeout30s,
|
||||||
Default: &constants.Timeout60s,
|
Default: &constants.Timeout60s,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: dataSourceAccountVinsListSchemaMake(),
|
Schema: dataSourceAccountVinsListSchemaMake(),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,60 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.RecordImage, error) {
|
func utilityImageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.RecordImage, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.GetRequest{}
|
req := image.GetRequest{}
|
||||||
|
|
||||||
if d.Id() != "" {
|
if d.Id() != "" {
|
||||||
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
id, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||||
req.ImageID = id
|
req.ImageID = id
|
||||||
} else {
|
} else {
|
||||||
req.ImageID = uint64(d.Get("image_id").(int))
|
req.ImageID = uint64(d.Get("image_id").(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := c.CloudBroker().Image().Get(ctx, req)
|
image, err := c.CloudBroker().Image().Get(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return image, nil
|
return image, nil
|
||||||
}
|
}
|
||||||
|
@ -1,98 +1,98 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
func utilityImageListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListImages, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListRequest{}
|
req := image.ListRequest{}
|
||||||
|
|
||||||
if sepId, ok := d.GetOk("sep_id"); ok {
|
if sepId, ok := d.GetOk("sep_id"); ok {
|
||||||
req.SepID = uint64(sepId.(int))
|
req.SepID = uint64(sepId.(int))
|
||||||
}
|
}
|
||||||
if byId, ok := d.GetOk("by_id"); ok {
|
if byId, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(byId.(int))
|
req.ByID = uint64(byId.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
if architecture, ok := d.GetOk("architecture"); ok {
|
if architecture, ok := d.GetOk("architecture"); ok {
|
||||||
req.Architecture = architecture.(string)
|
req.Architecture = architecture.(string)
|
||||||
}
|
}
|
||||||
if typeImage, ok := d.GetOk("type_image"); ok {
|
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||||
req.TypeImage = typeImage.(string)
|
req.TypeImage = typeImage.(string)
|
||||||
}
|
}
|
||||||
if imageSize, ok := d.GetOk("image_size"); ok {
|
if imageSize, ok := d.GetOk("image_size"); ok {
|
||||||
req.ImageSize = uint64(imageSize.(int))
|
req.ImageSize = uint64(imageSize.(int))
|
||||||
}
|
}
|
||||||
if sepName, ok := d.GetOk("sep_name"); ok {
|
if sepName, ok := d.GetOk("sep_name"); ok {
|
||||||
req.SEPName = sepName.(string)
|
req.SEPName = sepName.(string)
|
||||||
}
|
}
|
||||||
if pool, ok := d.GetOk("pool"); ok {
|
if pool, ok := d.GetOk("pool"); ok {
|
||||||
req.Pool = pool.(string)
|
req.Pool = pool.(string)
|
||||||
}
|
}
|
||||||
if public, ok := d.GetOk("public"); ok {
|
if public, ok := d.GetOk("public"); ok {
|
||||||
req.Public = public.(bool)
|
req.Public = public.(bool)
|
||||||
}
|
}
|
||||||
if hotResize, ok := d.GetOk("hot_resize"); ok {
|
if hotResize, ok := d.GetOk("hot_resize"); ok {
|
||||||
req.HotResize = hotResize.(bool)
|
req.HotResize = hotResize.(bool)
|
||||||
}
|
}
|
||||||
if bootable, ok := d.GetOk("bootable"); ok {
|
if bootable, ok := d.GetOk("bootable"); ok {
|
||||||
req.Bootable = bootable.(bool)
|
req.Bootable = bootable.(bool)
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityImageListCheckPresence: load image list")
|
log.Debugf("utilityImageListCheckPresence: load image list")
|
||||||
imageList, err := c.CloudBroker().Image().List(ctx, req)
|
imageList, err := c.CloudBroker().Image().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageList, nil
|
return imageList, nil
|
||||||
}
|
}
|
||||||
|
@ -1,73 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityImageListStacksCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListStacks, error) {
|
func utilityImageListStacksCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*image.ListStacks, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := image.ListStacksRequest{
|
req := image.ListStacksRequest{
|
||||||
ImageID: uint64(d.Get("image_id").(int)),
|
ImageID: uint64(d.Get("image_id").(int)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if status, ok := d.GetOk("status"); ok {
|
if status, ok := d.GetOk("status"); ok {
|
||||||
req.Status = status.(string)
|
req.Status = status.(string)
|
||||||
}
|
}
|
||||||
if typeImage, ok := d.GetOk("type_image"); ok {
|
if typeImage, ok := d.GetOk("type_image"); ok {
|
||||||
req.Type = typeImage.(string)
|
req.Type = typeImage.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityImageListStacksCheckPresence: load image list")
|
log.Debugf("utilityImageListStacksCheckPresence: load image list")
|
||||||
imageListStacks, err := c.CloudBroker().Image().ListStacks(ctx, req)
|
imageListStacks, err := c.CloudBroker().Image().ListStacks(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageListStacks, nil
|
return imageListStacks, nil
|
||||||
}
|
}
|
||||||
|
@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||||
Authors:
|
Authors:
|
||||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||||
Orchestration Technology) with Terraform by Hashicorp.
|
Orchestration Technology) with Terraform by Hashicorp.
|
||||||
|
|
||||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||||
|
|
||||||
Please see README.md to learn where to place source code so that it
|
Please see README.md to learn where to place source code so that it
|
||||||
builds seamlessly.
|
builds seamlessly.
|
||||||
|
|
||||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package vins
|
package vins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
|
||||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
|
func utilityVinsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListVINS, error) {
|
||||||
c := m.(*controller.ControllerCfg)
|
c := m.(*controller.ControllerCfg)
|
||||||
req := vins.ListRequest{}
|
req := vins.ListRequest{}
|
||||||
|
|
||||||
if byId, ok := d.GetOk("by_id"); ok {
|
if byId, ok := d.GetOk("by_id"); ok {
|
||||||
req.ByID = uint64(byId.(int))
|
req.ByID = uint64(byId.(int))
|
||||||
}
|
}
|
||||||
if name, ok := d.GetOk("name"); ok {
|
if name, ok := d.GetOk("name"); ok {
|
||||||
req.Name = name.(string)
|
req.Name = name.(string)
|
||||||
}
|
}
|
||||||
if accountId, ok := d.GetOk("account_id"); ok {
|
if accountId, ok := d.GetOk("account_id"); ok {
|
||||||
req.AccountID = uint64(accountId.(int))
|
req.AccountID = uint64(accountId.(int))
|
||||||
}
|
}
|
||||||
if rgId, ok := d.GetOk("rg_id"); ok {
|
if rgId, ok := d.GetOk("rg_id"); ok {
|
||||||
req.RGID = uint64(rgId.(int))
|
req.RGID = uint64(rgId.(int))
|
||||||
}
|
}
|
||||||
if extIp, ok := d.GetOk("ext_ip"); ok {
|
if extIp, ok := d.GetOk("ext_ip"); ok {
|
||||||
req.ExtIP = extIp.(string)
|
req.ExtIP = extIp.(string)
|
||||||
}
|
}
|
||||||
if page, ok := d.GetOk("page"); ok {
|
if page, ok := d.GetOk("page"); ok {
|
||||||
req.Page = uint64(page.(int))
|
req.Page = uint64(page.(int))
|
||||||
}
|
}
|
||||||
if size, ok := d.GetOk("size"); ok {
|
if size, ok := d.GetOk("size"); ok {
|
||||||
req.Size = uint64(size.(int))
|
req.Size = uint64(size.(int))
|
||||||
}
|
}
|
||||||
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
|
if includeDeleted, ok := d.GetOk("include_deleted"); ok {
|
||||||
req.IncludeDeleted = includeDeleted.(bool)
|
req.IncludeDeleted = includeDeleted.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("utilityVinsListCheckPresence")
|
log.Debugf("utilityVinsListCheckPresence")
|
||||||
vinsList, err := c.CloudBroker().VINS().List(ctx, req)
|
vinsList, err := c.CloudBroker().VINS().List(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return vinsList, nil
|
return vinsList, nil
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package validators
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DivisibleBy(divisibility int) schema.SchemaValidateFunc {
|
||||||
|
return func(i interface{}, k string) (warnings []string, errors []error) {
|
||||||
|
total, ok := i.(int)
|
||||||
|
if !ok {
|
||||||
|
errors = append(errors, fmt.Errorf("expected type of %s to be integer", k))
|
||||||
|
return warnings, errors
|
||||||
|
}
|
||||||
|
if total % divisibility != 0 {
|
||||||
|
errors = append(errors, fmt.Errorf("expected value of %s to be divisible by %d", k, divisibility))
|
||||||
|
}
|
||||||
|
|
||||||
|
return warnings, errors
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
users:
|
||||||
|
- groups: users, wheel
|
||||||
|
name: user
|
||||||
|
plain_text_passwd: examplePassword
|
||||||
|
primary_group: user
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ssh-rsa EXAMPLE%id_rsa.pub
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
Loading…
Reference in new issue