This commit is contained in:
Пётр Крутов
2022-09-21 12:11:42 +00:00
parent b152359706
commit 1a983e945b
78 changed files with 5009 additions and 87 deletions

View File

@@ -786,7 +786,7 @@ func ResourceAccount() *schema.Resource {
DeleteContext: resourceAccountDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -511,7 +511,7 @@ func ResourceBasicService() *schema.Resource {
DeleteContext: resourceBasicServiceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -616,7 +616,7 @@ func ResourceBasicServiceGroup() *schema.Resource {
DeleteContext: resourceBasicServiceGroupDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
DeleteContext: resourceDiskDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -244,7 +244,7 @@ func ResourceImage() *schema.Resource {
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -116,7 +116,7 @@ func ResourceImageVirtual() *schema.Resource {
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
DeleteContext: resourceK8sDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
DeleteContext: resourceK8sWgDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -44,3 +44,4 @@ const ComputeStopAPI = "/restmachine/cloudapi/compute/stop"
const ComputeResizeAPI = "/restmachine/cloudapi/compute/resize"
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
const ComputeDeleteAPI = "/restmachine/cloudapi/compute/delete"
const ComputeUpdateAPI = "/restmachine/cloudapi/compute/update"

View File

@@ -92,6 +92,14 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
urlValues.Add("pool", pool.(string))
}
if ipaType, ok := d.GetOk("ipa_type"); ok {
urlValues.Add("ipaType", ipaType.(string))
}
if IS, ok := d.GetOk("is"); ok {
urlValues.Add("IS", IS.(string))
}
/*
sshKeysVal, sshKeysSet := d.GetOk("ssh_keys")
if sshKeysSet {
@@ -287,6 +295,16 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}
if d.HasChange("description") || d.HasChange("name") {
updateParams := &url.Values{}
updateParams.Add("computeId", d.Id())
updateParams.Add("name", d.Get("name").(string))
updateParams.Add("desc", d.Get("description").(string))
if _, err := c.DecortAPICall(ctx, "POST", ComputeUpdateAPI, updateParams); err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("started") {
params := &url.Values{}
params.Add("computeId", d.Id())
@@ -318,8 +336,8 @@ func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interf
params := &url.Values{}
params.Add("computeId", d.Id())
params.Add("permanently", "1")
params.Add("detachDisks", "1")
params.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
params.Add("detachDisks", strconv.FormatBool(d.Get("detach_disks").(bool)))
if _, err := c.DecortAPICall(ctx, "POST", ComputeDeleteAPI, params); err != nil {
return diag.FromErr(err)
@@ -338,7 +356,7 @@ func ResourceCompute() *schema.Resource {
DeleteContext: resourceComputeDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
@@ -501,6 +519,26 @@ func ResourceCompute() *schema.Resource {
Default: true,
Description: "Is compute started.",
},
"detach_disks": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"permanently": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"is": {
Type: schema.TypeString,
Optional: true,
Description: "system name",
},
"ipa_type": {
Type: schema.TypeString,
Optional: true,
Description: "compute purpose",
},
},
}
}

View File

@@ -267,12 +267,12 @@ func utilityComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m
// and RG ID
computeName, argSet := d.GetOk("name")
if !argSet {
return "", fmt.Errorf("Cannot locate compute instance if name is empty and no compute ID specified")
return "", fmt.Errorf("cannot locate compute instance if name is empty and no compute ID specified")
}
rgId, argSet := d.GetOk("rg_id")
if !argSet {
return "", fmt.Errorf("Cannot locate compute by name %s if no resource group ID is set", computeName.(string))
return "", fmt.Errorf("cannot locate compute by name %s if no resource group ID is set", computeName.(string))
}
urlValues.Add("rgId", fmt.Sprintf("%d", rgId))

View File

@@ -0,0 +1,57 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
const lbListAPI = "/restmachine/cloudapi/lb/list"
const lbListDeletedAPI = "/restmachine/cloudapi/lb/listDeleted"
const lbGetAPI = "/restmachine/cloudapi/lb/get"
const lbCreateAPI = "/restmachine/cloudapi/lb/create"
const lbDeleteAPI = "/restmachine/cloudapi/lb/delete"
const lbDisableAPI = "/restmachine/cloudapi/lb/disable"
const lbEnableAPI = "/restmachine/cloudapi/lb/enable"
const lbUpdateAPI = "/restmachine/cloudapi/lb/update"
const lbStartAPI = "/restmachine/cloudapi/lb/start"
const lbStopAPI = "/restmachine/cloudapi/lb/stop"
const lbRestartAPI = "/restmachine/cloudapi/lb/restart"
const lbRestoreAPI = "/restmachine/cloudapi/lb/restore"
const lbConfigResetAPI = "/restmachine/cloudapi/lb/configReset"
const lbBackendCreateAPI = "/restmachine/cloudapi/lb/backendCreate"
const lbBackendDeleteAPI = "/restmachine/cloudapi/lb/backendDelete"
const lbBackendUpdateAPI = "/restmachine/cloudapi/lb/backendUpdate"
const lbBackendServerAddAPI = "/restmachine/cloudapi/lb/backendServerAdd"
const lbBackendServerDeleteAPI = "/restmachine/cloudapi/lb/backendServerDelete"
const lbBackendServerUpdateAPI = "/restmachine/cloudapi/lb/backendServerUpdate"
const lbFrontendCreateAPI = "/restmachine/cloudapi/lb/frontendCreate"
const lbFrontendDeleteAPI = "/restmachine/cloudapi/lb/frontendDelete"
const lbFrontendBindAPI = "/restmachine/cloudapi/lb/frontendBind"
const lbFrontendBindDeleteAPI = "/restmachine/cloudapi/lb/frontendBindDelete"
const lbFrontendBindUpdateAPI = "/restmachine/cloudapi/lb/frontendBindingUpdate"

View File

@@ -0,0 +1,96 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
)
func flattenLB(d *schema.ResourceData, lb *LoadBalancer) {
d.Set("ha_mode", lb.HAMode)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtnetId)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("image_id", lb.ImageId)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("vins_id", lb.VinsId)
}
func dataSourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
lb, err := utilityLBCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(lb.ID, 10))
flattenLB(d, lb)
return nil
}
func DataSourceLB() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceLBRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dsLBSchemaMake(),
}
}

View File

@@ -0,0 +1,103 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
)
func flattenLBList(lbl LBList) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lbl))
for _, lb := range lbl {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backends": flattenLBBackends(lb.Backends),
"created_by": lb.CreatedBy,
"created_time": lb.CreatedTime,
"deleted_by": lb.DeletedBy,
"deleted_time": lb.DeletedTime,
"desc": lb.Description,
"dp_api_user": lb.DPAPIUser,
"dp_api_password": lb.DPAPIPassword,
"extnet_id": lb.ExtnetId,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"image_id": lb.ImageId,
"milestones": lb.Milestones,
"name": lb.Name,
"primary_node": flattenNode(lb.PrimaryNode),
"rg_id": lb.RGID,
"rg_name": lb.RGName,
"secondary_node": flattenNode(lb.SecondaryNode),
"status": lb.Status,
"tech_status": lb.TechStatus,
"updated_by": lb.UpdatedBy,
"updated_time": lb.UpdatedTime,
"vins_id": lb.VinsId,
}
res = append(res, temp)
}
return res
}
func dataSourceLBListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
lbList, err := utilityLBListCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenLBList(lbList))
return nil
}
func DataSourceLBList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceLBListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dsLBListSchemaMake(),
}
}

View File

@@ -0,0 +1,68 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
)
func dataSourceLBListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
lbList, err := utilityLBListDeletedCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenLBList(lbList))
return nil
}
func DataSourceLBListDeleted() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceLBListDeletedRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dsLBListDeletedSchemaMake(),
}
}

View File

@@ -0,0 +1,128 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
func flattenNode(node Node) []map[string]interface{} {
temp := make([]map[string]interface{}, 0)
n := map[string]interface{}{
"backend_ip": node.BackendIp,
"compute_id": node.ComputeId,
"frontend_ip": node.FrontendIp,
"guid": node.GUID,
"mgmt_ip": node.MGMTIp,
"network_id": node.NetworkId,
}
temp = append(temp, n)
return temp
}
func flattendBindings(bs []Binding) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(bs))
for _, b := range bs {
t := map[string]interface{}{
"address": b.Address,
"guid": b.GUID,
"name": b.Name,
"port": b.Port,
}
temp = append(temp, t)
}
return temp
}
func flattenFrontends(fs []Frontend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(fs))
for _, f := range fs {
t := map[string]interface{}{
"backend": f.Backend,
"bindings": flattendBindings(f.Bindings),
"guid": f.GUID,
"name": f.Name,
}
temp = append(temp, t)
}
return temp
}
func flattenServers(servers []Server) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(servers))
for _, server := range servers {
t := map[string]interface{}{
"address": server.Address,
"check": server.Check,
"guid": server.GUID,
"name": server.Name,
"port": server.Port,
"server_settings": flattenServerSettings(server.ServerSettings),
}
temp = append(temp, t)
}
return temp
}
func flattenServerSettings(defSet ServerSettings) []map[string]interface{} {
temp := map[string]interface{}{
"downinter": defSet.DownInter,
"fall": defSet.Fall,
"guid": defSet.GUID,
"inter": defSet.Inter,
"maxconn": defSet.MaxConn,
"maxqueue": defSet.MaxQueue,
"rise": defSet.Rise,
"slowstart": defSet.SlowStart,
"weight": defSet.Weight,
}
res := make([]map[string]interface{}, 0)
res = append(res, temp)
return res
}
func flattenLBBackends(backends []Backend) []map[string]interface{} {
temp := make([]map[string]interface{}, 0, len(backends))
for _, item := range backends {
t := map[string]interface{}{
"algorithm": item.Algorithm,
"guid": item.GUID,
"name": item.Name,
"server_default_settings": flattenServerSettings(item.ServerDefaultSettings),
"servers": flattenServers(item.Servers),
}
temp = append(temp, t)
}
return temp
}

View File

@@ -0,0 +1,101 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func dsLBSchemaMake() map[string]*schema.Schema {
sch := createLBSchema()
sch["lb_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
return sch
}
func dsLBListDeletedSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"page": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
"size": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dsLBItemSchemaMake(),
},
},
}
}
func dsLBListSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"includedeleted": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"page": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
"size": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
},
"items": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: dsLBItemSchemaMake(),
},
},
}
}
func dsLBItemSchemaMake() map[string]*schema.Schema {
sch := createLBSchema()
sch["dp_api_password"] = &schema.Schema{
Type: schema.TypeString,
Computed: true,
}
return sch
}

View File

@@ -0,0 +1,91 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func lbResourceSchemaMake() map[string]*schema.Schema {
sch := createLBSchema()
sch["rg_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
sch["name"] = &schema.Schema{
Type: schema.TypeString,
Required: true,
}
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Required: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
Required: true,
}
sch["desc"] = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
}
sch["enable"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restart"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["restore"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["config_reset"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
return sch
}

View File

@@ -0,0 +1,367 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func createLBSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"ha_mode": {
Type: schema.TypeBool,
Computed: true,
},
"backends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"algorithm": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"server_default_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"servers": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"check": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
"server_settings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
},
},
},
},
},
},
"created_by": {
Type: schema.TypeString,
Computed: true,
},
"created_time": {
Type: schema.TypeInt,
Computed: true,
},
"deleted_by": {
Type: schema.TypeString,
Computed: true,
},
"deleted_time": {
Type: schema.TypeInt,
Computed: true,
},
"desc": {
Type: schema.TypeString,
Computed: true,
},
"dp_api_user": {
Type: schema.TypeString,
Computed: true,
},
"extnet_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontends": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend": {
Type: schema.TypeString,
Computed: true,
},
"bindings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"gid": {
Type: schema.TypeInt,
Computed: true,
},
"guid": {
Type: schema.TypeInt,
Computed: true,
},
"lb_id": {
Type: schema.TypeInt,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"primary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"rg_id": {
Type: schema.TypeInt,
Computed: true,
},
"rg_name": {
Type: schema.TypeString,
Computed: true,
},
"secondary_node": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"backend_ip": {
Type: schema.TypeString,
Computed: true,
},
"compute_id": {
Type: schema.TypeInt,
Computed: true,
},
"frontend_ip": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"mgmt_ip": {
Type: schema.TypeString,
Computed: true,
},
"network_id": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"tech_status": {
Type: schema.TypeString,
Computed: true,
},
"updated_by": {
Type: schema.TypeString,
Computed: true,
},
"updated_time": {
Type: schema.TypeInt,
Computed: true,
},
"vins_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}

View File

@@ -0,0 +1,120 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
type LoadBalancer struct {
HAMode bool `json:"HAmode"`
ACL interface{} `json:"acl"`
Backends []Backend `json:"backends"`
CreatedBy string `json:"createdBy"`
CreatedTime uint64 `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime uint64 `json:"deletedTime"`
Description string `json:"desc"`
DPAPIUser string `json:"dpApiUser"`
ExtnetId uint64 `json:"extnetId"`
Frontends []Frontend `json:"frontends"`
GID uint64 `json:"gid"`
GUID uint64 `json:"guid"`
ID uint64 `json:"id"`
ImageId uint64 `json:"imageId"`
Milestones uint64 `json:"milestones"`
Name string `json:"name"`
PrimaryNode Node `json:"primaryNode"`
RGID uint64 `json:"rgId"`
RGName string `json:"rgName"`
SecondaryNode Node `json:"secondaryNode"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime uint64 `json:"updatedTime"`
VinsId uint64 `json:"vinsId"`
}
type LoadBalancerDetailed struct {
DPAPIPassword string `json:"dpApiPassword"`
LoadBalancer
}
type Backend struct {
Algorithm string `json:"algorithm"`
GUID string `json:"guid"`
Name string `json:"name"`
ServerDefaultSettings ServerSettings `json:"serverDefaultSettings"`
Servers []Server `json:"servers"`
}
type LBList []LoadBalancerDetailed
type ServerSettings struct {
Inter uint64 `json:"inter"`
GUID string `json:"guid"`
DownInter uint64 `json:"downinter"`
Rise uint `json:"rise"`
Fall uint `json:"fall"`
SlowStart uint64 `json:"slowstart"`
MaxConn uint `json:"maxconn"`
MaxQueue uint `json:"maxqueue"`
Weight uint `json:"weight"`
}
type Server struct {
Address string `json:"address"`
Check string `json:"check"`
GUID string `json:"guid"`
Name string `json:"name"`
Port uint `json:"port"`
ServerSettings ServerSettings `json:"serverSettings"`
}
type Node struct {
BackendIp string `json:"backendIp"`
ComputeId uint64 `json:"computeId"`
FrontendIp string `json:"frontendIp"`
GUID string `json:"guid"`
MGMTIp string `json:"mgmtIp"`
NetworkId uint64 `json:"networkId"`
}
type Frontend struct {
Backend string `json:"backend"`
Bindings []Binding `json:"bindings"`
GUID string `json:"guid"`
Name string `json:"name"`
}
type Binding struct {
Address string `json:"address"`
GUID string `json:"guid"`
Name string `json:"name"`
Port uint `json:"port"`
}

View File

@@ -0,0 +1,281 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"net/url"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
)
func resourceLBCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBCreate")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("name", d.Get("name").(string))
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
urlValues.Add("extnetId", strconv.Itoa(d.Get("extnet_id").(int)))
urlValues.Add("vinsId", strconv.Itoa(d.Get("vins_id").(int)))
urlValues.Add("start", strconv.FormatBool((d.Get("start").(bool))))
if desc, ok := d.GetOk("desc"); ok {
urlValues.Add("desc", desc.(string))
}
lbId, err := c.DecortAPICall(ctx, "POST", lbCreateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId(lbId)
d.Set("lb_id", lbId)
_, err = utilityLBCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
diagnostics := resourceLBRead(ctx, d, m)
if diagnostics != nil {
return diagnostics
}
urlValues = &url.Values{}
if enable, ok := d.GetOk("enable"); ok {
api := lbDisableAPI
if enable.(bool) {
api = lbEnableAPI
}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
return nil
}
func resourceLBRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBRead")
lb, err := utilityLBCheckPresence(ctx, d, m)
if lb == nil {
d.SetId("")
return diag.FromErr(err)
}
d.Set("ha_mode", lb.HAMode)
d.Set("backends", flattenLBBackends(lb.Backends))
d.Set("created_by", lb.CreatedBy)
d.Set("created_time", lb.CreatedTime)
d.Set("deleted_by", lb.DeletedBy)
d.Set("deleted_time", lb.DeletedTime)
d.Set("desc", lb.Description)
d.Set("dp_api_user", lb.DPAPIUser)
d.Set("extnet_id", lb.ExtnetId)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("lb_id", lb.ID)
d.Set("image_id", lb.ImageId)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("primary_node", flattenNode(lb.PrimaryNode))
d.Set("rg_id", lb.RGID)
d.Set("rg_name", lb.RGName)
d.Set("secondary_node", flattenNode(lb.SecondaryNode))
d.Set("status", lb.Status)
d.Set("tech_status", lb.TechStatus)
d.Set("updated_by", lb.UpdatedBy)
d.Set("updated_time", lb.UpdatedTime)
d.Set("vins_id", lb.VinsId)
return nil
}
func resourceLBDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBDelete")
lb, err := utilityLBCheckPresence(ctx, d, m)
if lb == nil {
if err != nil {
return diag.FromErr(err)
}
return nil
}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
if permanently, ok := d.GetOk("permanently"); ok {
urlValues.Add("permanently", strconv.FormatBool(permanently.(bool)))
}
_, err = c.DecortAPICall(ctx, "POST", lbDeleteAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceLBEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBEdit")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
if d.HasChange("enable") {
api := lbDisableAPI
enable := d.Get("enable").(bool)
if enable {
api = lbEnableAPI
}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
if d.HasChange("start") {
api := lbStopAPI
start := d.Get("start").(bool)
if start {
api = lbStartAPI
}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", api, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
if d.HasChange("desc") {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("desc", d.Get("desc").(string))
_, err := c.DecortAPICall(ctx, "POST", lbUpdateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
if d.HasChange("restart") {
restart := d.Get("restart").(bool)
if restart {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", lbRestartAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
}
if d.HasChange("restore") {
restore := d.Get("restore").(bool)
if restore {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", lbRestoreAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
}
if d.HasChange("config_reset") {
cfgReset := d.Get("config_reset").(bool)
if cfgReset {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
_, err := c.DecortAPICall(ctx, "POST", lbConfigResetAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
urlValues = &url.Values{}
}
}
//TODO: перенести backend и frontend из ресурсов сюда
return resourceLBRead(ctx, d, m)
}
func ResourceLB() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceLBCreate,
ReadContext: resourceLBRead,
UpdateContext: resourceLBEdit,
DeleteContext: resourceLBDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout60s,
Read: &constants.Timeout30s,
Update: &constants.Timeout60s,
Delete: &constants.Timeout60s,
Default: &constants.Timeout60s,
},
Schema: lbResourceSchemaMake(),
}
}

View File

@@ -0,0 +1,373 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
)
func resourceLBBackendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendCreate")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("backendName", d.Get("name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
if algorithm, ok := d.GetOk("algorithm"); ok {
urlValues.Add("algorithm", algorithm.(string))
}
if inter, ok := d.GetOk("inter"); ok {
urlValues.Add("inter", strconv.Itoa(inter.(int)))
}
if downinter, ok := d.GetOk("downinter"); ok {
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
}
if rise, ok := d.GetOk("rise"); ok {
urlValues.Add("rise", strconv.Itoa(rise.(int)))
}
if fall, ok := d.GetOk("fall"); ok {
urlValues.Add("fall", strconv.Itoa(fall.(int)))
}
if slowstart, ok := d.GetOk("slowstart"); ok {
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
}
if maxconn, ok := d.GetOk("maxconn"); ok {
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
}
if maxqueue, ok := d.GetOk("maxqueue"); ok {
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
}
if weight, ok := d.GetOk("weight"); ok {
urlValues.Add("weight", strconv.Itoa(weight.(int)))
}
_, err := c.DecortAPICall(ctx, "POST", lbBackendCreateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
_, err = utilityLBBackendCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
diagnostics := resourceLBBackendRead(ctx, d, m)
if diagnostics != nil {
return diagnostics
}
return nil
}
func resourceLBBackendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendRead")
b, err := utilityLBBackendCheckPresence(ctx, d, m)
if b == nil {
d.SetId("")
return diag.FromErr(err)
}
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
d.Set("lb_id", lbId)
d.Set("name", b.Name)
d.Set("algorithm", b.Algorithm)
d.Set("guid", b.GUID)
d.Set("downinter", b.ServerDefaultSettings.DownInter)
d.Set("fall", b.ServerDefaultSettings.Fall)
d.Set("inter", b.ServerDefaultSettings.Inter)
d.Set("maxconn", b.ServerDefaultSettings.MaxConn)
d.Set("maxqueue", b.ServerDefaultSettings.MaxQueue)
d.Set("rise", b.ServerDefaultSettings.Rise)
d.Set("slowstart", b.ServerDefaultSettings.SlowStart)
d.Set("weight", b.ServerDefaultSettings.Weight)
d.Set("servers", flattenServers(b.Servers))
return nil
}
func resourceLBBackendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendDelete")
lb, err := utilityLBBackendCheckPresence(ctx, d, m)
if lb == nil {
if err != nil {
return diag.FromErr(err)
}
return nil
}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("backendName", d.Get("name").(string))
_, err = c.DecortAPICall(ctx, "POST", lbBackendDeleteAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceLBBackendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendEdit")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("backendName", d.Get("name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
if d.HasChange("algorithm") {
urlValues.Add("algorithm", d.Get("algorithm").(string))
}
if d.HasChange("inter") {
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
}
if d.HasChange("downinter") {
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
}
if d.HasChange("rise") {
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
}
if d.HasChange("fall") {
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
}
if d.HasChange("slowstart") {
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
}
if d.HasChange("maxconn") {
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
}
if d.HasChange("maxqueue") {
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
}
if d.HasChange("weight") {
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
}
_, err := c.DecortAPICall(ctx, "POST", lbBackendUpdateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
//TODO: перенести servers сюда
return resourceLBBackendRead(ctx, d, m)
}
func ResourceLBBackend() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceLBBackendCreate,
ReadContext: resourceLBBackendRead,
UpdateContext: resourceLBBackendEdit,
DeleteContext: resourceLBBackendDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout60s,
Read: &constants.Timeout30s,
Update: &constants.Timeout60s,
Delete: &constants.Timeout60s,
Default: &constants.Timeout60s,
},
Schema: map[string]*schema.Schema{
"lb_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the LB instance to backendCreate",
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Must be unique among all backends of this LB - name of the new backend to create",
},
"algorithm": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"roundrobin", "static-rr", "leastconn"}, false),
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"downinter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"servers": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"check": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"server_settings": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"downinter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
},
},
},
},
},
},
}
}

View File

@@ -0,0 +1,314 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
)
func resourceLBBackendServerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendServerCreate")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("backendName", d.Get("backend_name").(string))
urlValues.Add("serverName", d.Get("name").(string))
urlValues.Add("address", d.Get("address").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
if check, ok := d.GetOk("check"); ok {
urlValues.Add("check", check.(string))
}
if inter, ok := d.GetOk("inter"); ok {
urlValues.Add("inter", strconv.Itoa(inter.(int)))
}
if downinter, ok := d.GetOk("downinter"); ok {
urlValues.Add("downinter", strconv.Itoa(downinter.(int)))
}
if rise, ok := d.GetOk("rise"); ok {
urlValues.Add("rise", strconv.Itoa(rise.(int)))
}
if fall, ok := d.GetOk("fall"); ok {
urlValues.Add("fall", strconv.Itoa(fall.(int)))
}
if slowstart, ok := d.GetOk("slowstart"); ok {
urlValues.Add("slowstart", strconv.Itoa(slowstart.(int)))
}
if maxconn, ok := d.GetOk("maxconn"); ok {
urlValues.Add("maxconn", strconv.Itoa(maxconn.(int)))
}
if maxqueue, ok := d.GetOk("maxqueue"); ok {
urlValues.Add("maxqueue", strconv.Itoa(maxqueue.(int)))
}
if weight, ok := d.GetOk("weight"); ok {
urlValues.Add("weight", strconv.Itoa(weight.(int)))
}
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerAddAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("backend_name").(string) + "-" + d.Get("name").(string))
_, err = utilityLBBackendServerCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
diagnostics := resourceLBBackendServerRead(ctx, d, m)
if diagnostics != nil {
return diagnostics
}
return nil
}
func resourceLBBackendServerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendServerRead")
s, err := utilityLBBackendServerCheckPresence(ctx, d, m)
if s == nil {
d.SetId("")
return diag.FromErr(err)
}
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
backendName := strings.Split(d.Id(), "-")[1]
d.Set("lb_id", lbId)
d.Set("backend_name", backendName)
d.Set("name", s.Name)
d.Set("port", s.Port)
d.Set("address", s.Address)
d.Set("check", s.Check)
d.Set("guid", s.GUID)
d.Set("downinter", s.ServerSettings.DownInter)
d.Set("fall", s.ServerSettings.Fall)
d.Set("inter", s.ServerSettings.Inter)
d.Set("maxconn", s.ServerSettings.MaxConn)
d.Set("maxqueue", s.ServerSettings.MaxQueue)
d.Set("rise", s.ServerSettings.Rise)
d.Set("slowstart", s.ServerSettings.SlowStart)
d.Set("weight", s.ServerSettings.Weight)
return nil
}
func resourceLBBackendServerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendServerDelete")
lb, err := utilityLBBackendServerCheckPresence(ctx, d, m)
if lb == nil {
if err != nil {
return diag.FromErr(err)
}
return nil
}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("serverName", d.Get("name").(string))
urlValues.Add("backendName", d.Get("backend_name").(string))
_, err = c.DecortAPICall(ctx, "POST", lbBackendServerDeleteAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceLBBackendServerEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBBackendServerEdit")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("backendName", d.Get("backend_name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("serverName", d.Get("name").(string))
urlValues.Add("address", d.Get("address").(string))
urlValues.Add("port", strconv.Itoa(d.Get("port").(int)))
if d.HasChange("check") {
urlValues.Add("check", d.Get("check").(string))
}
if d.HasChange("inter") {
urlValues.Add("inter", strconv.Itoa(d.Get("inter").(int)))
}
if d.HasChange("downinter") {
urlValues.Add("downinter", strconv.Itoa(d.Get("downinter").(int)))
}
if d.HasChange("rise") {
urlValues.Add("rise", strconv.Itoa(d.Get("rise").(int)))
}
if d.HasChange("fall") {
urlValues.Add("fall", strconv.Itoa(d.Get("fall").(int)))
}
if d.HasChange("slowstart") {
urlValues.Add("slowstart", strconv.Itoa(d.Get("slowstart").(int)))
}
if d.HasChange("maxconn") {
urlValues.Add("maxconn", strconv.Itoa(d.Get("maxconn").(int)))
}
if d.HasChange("maxqueue") {
urlValues.Add("maxqueue", strconv.Itoa(d.Get("maxqueue").(int)))
}
if d.HasChange("weight") {
urlValues.Add("weight", strconv.Itoa(d.Get("weight").(int)))
}
_, err := c.DecortAPICall(ctx, "POST", lbBackendServerUpdateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
//TODO: перенести servers сюда
return resourceLBBackendServerRead(ctx, d, m)
}
func ResourceLBBackendServer() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceLBBackendServerCreate,
ReadContext: resourceLBBackendServerRead,
UpdateContext: resourceLBBackendServerEdit,
DeleteContext: resourceLBBackendServerDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout60s,
Read: &constants.Timeout30s,
Update: &constants.Timeout60s,
Delete: &constants.Timeout60s,
Default: &constants.Timeout60s,
},
Schema: map[string]*schema.Schema{
"lb_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the LB instance to backendCreate",
},
"backend_name": {
Type: schema.TypeString,
Required: true,
Description: "Must be unique among all backends of this LB - name of the new backend to create",
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "Must be unique among all servers defined for this backend - name of the server definition to add.",
},
"address": {
Type: schema.TypeString,
Required: true,
Description: "IP address of the server.",
},
"port": {
Type: schema.TypeInt,
Required: true,
Description: "Port number on the server",
},
"check": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"disabled", "enabled"}, false),
Description: "set to disabled if this server should be used regardless of its state.",
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"downinter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"fall": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"inter": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxconn": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"maxqueue": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"rise": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"slowstart": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"weight": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
},
}
}

View File

@@ -0,0 +1,192 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
)
func resourceLBFrontendCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendCreate")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("backendName", d.Get("backend_name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("frontendName", d.Get("name").(string))
_, err := c.DecortAPICall(ctx, "POST", lbFrontendCreateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("name").(string))
_, err = utilityLBFrontendCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
diagnostics := resourceLBFrontendRead(ctx, d, m)
if diagnostics != nil {
return diagnostics
}
return nil
}
func resourceLBFrontendRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendRead")
f, err := utilityLBFrontendCheckPresence(ctx, d, m)
if f == nil {
d.SetId("")
return diag.FromErr(err)
}
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
d.Set("lb_id", lbId)
d.Set("backend_name", f.Backend)
d.Set("name", f.Name)
d.Set("guid", f.GUID)
d.Set("bindings", flattendBindings(f.Bindings))
return nil
}
func resourceLBFrontendDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendDelete")
lb, err := utilityLBFrontendCheckPresence(ctx, d, m)
if lb == nil {
if err != nil {
return diag.FromErr(err)
}
return nil
}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("frontendName", d.Get("name").(string))
_, err = c.DecortAPICall(ctx, "POST", lbFrontendDeleteAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceLBFrontendEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
//TODO: перенести bindings сюда
return nil
}
func ResourceLBFrontend() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceLBFrontendCreate,
ReadContext: resourceLBFrontendRead,
UpdateContext: resourceLBFrontendEdit,
DeleteContext: resourceLBFrontendDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout60s,
Read: &constants.Timeout30s,
Update: &constants.Timeout60s,
Delete: &constants.Timeout60s,
Default: &constants.Timeout60s,
},
Schema: map[string]*schema.Schema{
"lb_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the LB instance to backendCreate",
},
"backend_name": {
Type: schema.TypeString,
Required: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
"bindings": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"address": {
Type: schema.TypeString,
Computed: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

View File

@@ -0,0 +1,201 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
)
func resourceLBFrontendBindCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendBindCreate")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("frontendName", d.Get("frontend_name").(string))
urlValues.Add("bindingName", d.Get("name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("bindingAddress", d.Get("address").(string))
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.Itoa(d.Get("lb_id").(int)) + "-" + d.Get("frontend_name").(string) + "-" + d.Get("name").(string))
_, err = utilityLBFrontendBindCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
diagnostics := resourceLBFrontendBindRead(ctx, d, m)
if diagnostics != nil {
return diagnostics
}
return nil
}
func resourceLBFrontendBindRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendBindRead")
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
if b == nil {
d.SetId("")
return diag.FromErr(err)
}
lbId, _ := strconv.ParseInt(strings.Split(d.Id(), "-")[0], 10, 32)
frontendName := strings.Split(d.Id(), "-")[1]
d.Set("lb_id", lbId)
d.Set("frontend_name", frontendName)
d.Set("name", b.Name)
d.Set("address", b.Address)
d.Set("guid", b.GUID)
d.Set("port", b.Port)
return nil
}
func resourceLBFrontendBindDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendBindDelete")
b, err := utilityLBFrontendBindCheckPresence(ctx, d, m)
if b == nil {
if err != nil {
return diag.FromErr(err)
}
return nil
}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
urlValues.Add("bindingName", d.Get("name").(string))
urlValues.Add("frontendName", d.Get("frontend_name").(string))
_, err = c.DecortAPICall(ctx, "POST", lbFrontendBindDeleteAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
d.SetId("")
return nil
}
func resourceLBFrontendBindEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceLBFrontendBindEdit")
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("frontendName", d.Get("frontend_name").(string))
urlValues.Add("bindingName", d.Get("name").(string))
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
if d.HasChange("address") {
urlValues.Add("bindingAddress", d.Get("address").(string))
}
if d.HasChange("port") {
urlValues.Add("bindingPort", strconv.Itoa(d.Get("port").(int)))
}
_, err := c.DecortAPICall(ctx, "POST", lbFrontendBindUpdateAPI, urlValues)
if err != nil {
return diag.FromErr(err)
}
return resourceLBFrontendBindRead(ctx, d, m)
}
func ResourceLBFrontendBind() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
CreateContext: resourceLBFrontendBindCreate,
ReadContext: resourceLBFrontendBindRead,
UpdateContext: resourceLBFrontendBindEdit,
DeleteContext: resourceLBFrontendBindDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout60s,
Read: &constants.Timeout30s,
Update: &constants.Timeout60s,
Delete: &constants.Timeout60s,
Default: &constants.Timeout60s,
},
Schema: map[string]*schema.Schema{
"lb_id": {
Type: schema.TypeInt,
Required: true,
Description: "ID of the LB instance to backendCreate",
},
"frontend_name": {
Type: schema.TypeString,
Required: true,
Description: "Must be unique among all backends of this LB - name of the new backend to create",
},
"address": {
Type: schema.TypeString,
Required: true,
},
"guid": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
"port": {
Type: schema.TypeInt,
Required: true,
},
},
}
}

View File

@@ -0,0 +1,70 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
)
func utilityLBCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*LoadBalancer, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
if (d.Get("lb_id").(int)) != 0 {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
} else {
urlValues.Add("lbId", d.Id())
}
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
lb := &LoadBalancer{}
if err := json.Unmarshal([]byte(resp), lb); err != nil {
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
}
return lb, nil
}

View File

@@ -0,0 +1,82 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
)
func utilityLBBackendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Backend, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
bName := d.Get("name").(string)
if (d.Get("lb_id").(int)) != 0 {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
} else {
parameters := strings.Split(d.Id(), "-")
urlValues.Add("lbId", parameters[0])
bName = parameters[1]
}
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
lb := &LoadBalancer{}
if err := json.Unmarshal([]byte(resp), lb); err != nil {
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
}
backends := lb.Backends
for _, b := range backends {
if b.Name == bName {
return &b, nil
}
}
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
}

View File

@@ -0,0 +1,95 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
)
func utilityLBBackendServerCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Server, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
bName := d.Get("backend_name").(string)
sName := d.Get("name").(string)
if (d.Get("lb_id").(int)) != 0 {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
} else {
parameters := strings.Split(d.Id(), "-")
urlValues.Add("lbId", parameters[0])
bName = parameters[1]
sName = parameters[2]
}
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
lb := &LoadBalancer{}
if err := json.Unmarshal([]byte(resp), lb); err != nil {
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
}
backend := &Backend{}
backends := lb.Backends
for i, b := range backends {
if b.Name == bName {
backend = &backends[i]
break
}
}
if backend.Name == "" {
return nil, fmt.Errorf("can not find backend with name: %s for lb: %d", bName, lb.ID)
}
for _, s := range backend.Servers {
if s.Name == sName {
return &s, nil
}
}
return nil, fmt.Errorf("can not find server with name: %s for backend: %s for lb: %d", sName, bName, lb.ID)
}

View File

@@ -0,0 +1,82 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
)
func utilityLBFrontendCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Frontend, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
fName := d.Get("name").(string)
if (d.Get("lb_id").(int)) != 0 {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
} else {
parameters := strings.Split(d.Id(), "-")
urlValues.Add("lbId", parameters[0])
fName = parameters[1]
}
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
lb := &LoadBalancer{}
if err := json.Unmarshal([]byte(resp), lb); err != nil {
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
}
frontends := lb.Frontends
for _, f := range frontends {
if f.Name == fName {
return &f, nil
}
}
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
}

View File

@@ -0,0 +1,95 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"fmt"
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
)
func utilityLBFrontendBindCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Binding, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
fName := d.Get("frontend_name").(string)
bName := d.Get("name").(string)
if (d.Get("lb_id").(int)) != 0 {
urlValues.Add("lbId", strconv.Itoa(d.Get("lb_id").(int)))
} else {
parameters := strings.Split(d.Id(), "-")
urlValues.Add("lbId", parameters[0])
fName = parameters[1]
bName = parameters[2]
}
resp, err := c.DecortAPICall(ctx, "POST", lbGetAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
lb := &LoadBalancer{}
if err := json.Unmarshal([]byte(resp), lb); err != nil {
return nil, fmt.Errorf("can not unmarshall data to lb: %s %+v", resp, lb)
}
frontend := &Frontend{}
frontends := lb.Frontends
for i, f := range frontends {
if f.Name == fName {
frontend = &frontends[i]
break
}
}
if frontend.Name == "" {
return nil, fmt.Errorf("can not find frontend with name: %s for lb: %d", fName, lb.ID)
}
for _, b := range frontend.Bindings {
if b.Name == bName {
return &b, nil
}
}
return nil, fmt.Errorf("can not find bind with name: %s for frontend: %s for lb: %d", bName, fName, lb.ID)
}

View File

@@ -0,0 +1,74 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityLBListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
lbList := LBList{}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
if includedeleted, ok := d.GetOk("includedeleted"); ok {
urlValues.Add("includedeleted", strconv.FormatBool((includedeleted.(bool))))
}
if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int)))
}
if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int)))
}
log.Debugf("utilityLBListCheckPresence: load lb list")
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(lbListRaw), &lbList)
if err != nil {
return nil, err
}
return lbList, nil
}

View File

@@ -0,0 +1,70 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package lb
import (
"context"
"encoding/json"
"net/url"
"strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func utilityLBListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (LBList, error) {
lbList := LBList{}
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok {
urlValues.Add("page", strconv.Itoa(page.(int)))
}
if size, ok := d.GetOk("size"); ok {
urlValues.Add("size", strconv.Itoa(size.(int)))
}
log.Debugf("utilityLBListDeletedCheckPresence: load lb list")
lbListRaw, err := c.DecortAPICall(ctx, "POST", lbListDeletedAPI, urlValues)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(lbListRaw), &lbList)
if err != nil {
return nil, err
}
return lbList, nil
}

View File

@@ -181,7 +181,7 @@ func ResourcePfw() *schema.Resource {
DeleteContext: resourcePfwDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
DeleteContext: resourceResgroupDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
DeleteContext: resourceSnapshotDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
DeleteContext: resourceVinsDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -455,7 +455,7 @@ func ResourceAccount() *schema.Resource {
DeleteContext: resourceAccountDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -610,7 +610,7 @@ func ResourceDisk() *schema.Resource {
DeleteContext: resourceDiskDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -381,7 +381,7 @@ func ResourceCDROMImage() *schema.Resource {
DeleteContext: resourceCDROMImageDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -126,7 +126,7 @@ func ResourceDeleteImages() *schema.Resource {
DeleteContext: resourceDeleteListImages,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -665,7 +665,7 @@ func ResourceImage() *schema.Resource {
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -328,7 +328,7 @@ func ResourceVirtualImage() *schema.Resource {
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -376,7 +376,7 @@ func ResourceK8s() *schema.Resource {
DeleteContext: resourceK8sDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -228,7 +228,7 @@ func ResourceK8sWg() *schema.Resource {
DeleteContext: resourceK8sWgDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -338,7 +338,7 @@ func ResourceCompute() *schema.Resource {
DeleteContext: resourceComputeDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -229,7 +229,7 @@ func ResourcePcidevice() *schema.Resource {
DeleteContext: resourcePcideviceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -181,7 +181,7 @@ func ResourcePfw() *schema.Resource {
DeleteContext: resourcePfwDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -307,7 +307,7 @@ func ResourceResgroup() *schema.Resource {
DeleteContext: resourceResgroupDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -492,7 +492,7 @@ func ResourceSep() *schema.Resource {
DeleteContext: resourceSepDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -188,7 +188,7 @@ func ResourceSepConfig() *schema.Resource {
DeleteContext: resourceSepConfigDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -178,7 +178,7 @@ func ResourceSnapshot() *schema.Resource {
DeleteContext: resourceSnapshotDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{

View File

@@ -292,7 +292,7 @@ func ResourceVins() *schema.Resource {
DeleteContext: resourceVinsDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{