4.11.3
This commit is contained in:
@@ -68,6 +68,34 @@ func flattenFlipgroup(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
|
||||
d.Set("updated_time", flip.UpdatedTime)
|
||||
}
|
||||
|
||||
func flattenFlipgroupResource(d *schema.ResourceData, flip *flipgroup.RecordFLIPGroup) {
|
||||
d.Set("flipgroup_id", flip.ID)
|
||||
d.Set("account_id", flip.AccountID)
|
||||
d.Set("account_name", flip.AccountName)
|
||||
d.Set("client_ids", flip.ClientIDs)
|
||||
d.Set("client_names", flip.ClientNames)
|
||||
d.Set("client_type", flip.ClientType)
|
||||
d.Set("conn_id", flip.ConnID)
|
||||
d.Set("conn_type", flip.ConnType)
|
||||
d.Set("created_by", flip.CreatedBy)
|
||||
d.Set("created_time", flip.CreatedTime)
|
||||
d.Set("default_gw", flip.DefaultGW)
|
||||
d.Set("deleted_by", flip.DeletedBy)
|
||||
d.Set("deleted_time", flip.DeletedTime)
|
||||
d.Set("desc", flip.Description)
|
||||
d.Set("gid", flip.GID)
|
||||
d.Set("guid", flip.GUID)
|
||||
d.Set("ip", flip.IP)
|
||||
d.Set("milestones", flip.Milestones)
|
||||
d.Set("name", flip.Name)
|
||||
d.Set("net_id", flip.NetID)
|
||||
d.Set("net_type", flip.NetType)
|
||||
d.Set("network", flip.Network)
|
||||
d.Set("status", flip.Status)
|
||||
d.Set("updated_by", flip.UpdatedBy)
|
||||
d.Set("updated_time", flip.UpdatedTime)
|
||||
}
|
||||
|
||||
func flattenFlipgroupsList(fg *flipgroup.ListFLIPGroups) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(fg.Data))
|
||||
for _, flip := range fg.Data {
|
||||
|
||||
@@ -110,7 +110,7 @@ func resourceFlipgroupRead(ctx context.Context, d *schema.ResourceData, m interf
|
||||
return diag.Errorf("The flipgroup status is destroyed and cannot be read.")
|
||||
}
|
||||
|
||||
flattenFlipgroup(d, fg)
|
||||
flattenFlipgroupResource(d, fg)
|
||||
|
||||
log.Debugf("resourceFlipgroupRead: after flattenFlipgroup: flipgroup_id %s, name %s",
|
||||
d.Id(), d.Get("name").(string))
|
||||
|
||||
@@ -1466,14 +1466,14 @@ func resourceK8sCPSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "insert ssl certificate in x509 pem format",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"lb_sysctl_params": {
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"lb_sysctl_params": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Description: "Custom sysctl values for Load Balancer instance. Applied on boot.",
|
||||
@@ -1810,19 +1810,19 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
||||
),
|
||||
Description: "Node RAM in MB.",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"disk": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
|
||||
},
|
||||
"chipset": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"Q35", "i440fx"}, false),
|
||||
Default: "Q35",
|
||||
Description: "Type of the emulated system. Possible values: i440fx, Q35. Default: Q35",
|
||||
},
|
||||
"disk": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Worker node boot disk size. If unspecified or 0, size is defined by OS image size.",
|
||||
},
|
||||
"labels": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
|
||||
@@ -17,8 +17,10 @@ func checkParamsExistence(ctx context.Context, d *schema.ResourceData, c *contro
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
|
||||
errs = append(errs, err)
|
||||
if !d.Get("create_blank").(bool) {
|
||||
if err := ic.ExistImage(ctx, uint64(d.Get("image_id").(int)), c); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if netErrs := existNetworks(ctx, d, c); errs != nil {
|
||||
|
||||
@@ -251,7 +251,32 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
}
|
||||
|
||||
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM x86")
|
||||
apiResp, err := c.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
||||
var apiResp uint64
|
||||
var err error
|
||||
if d.Get("create_blank").(bool) {
|
||||
log.Debugf("resourceComputeCreate: using createBlank endpoint")
|
||||
createBlankReq := kvmx86.CreateBlankRequest{
|
||||
RGID: createReqX86.RGID,
|
||||
Name: createReqX86.Name,
|
||||
CPU: createReqX86.CPU,
|
||||
RAM: createReqX86.RAM,
|
||||
StoragePolicyID: createReqX86.StoragePolicyID,
|
||||
WithoutBootDisk: createReqX86.WithoutBootDisk,
|
||||
BootDisk: createReqX86.BootDisk,
|
||||
SEPID: createReqX86.SEPID,
|
||||
Pool: createReqX86.Pool,
|
||||
DataDisks: createReqX86.DataDisks,
|
||||
Interfaces: createReqX86.Interfaces,
|
||||
Description: createReqX86.Description,
|
||||
Chipset: createReqX86.Chipset,
|
||||
PreferredCPU: createReqX86.PreferredCPU,
|
||||
ZoneID: createReqX86.ZoneID,
|
||||
OSVersion: createReqX86.OSVersion,
|
||||
}
|
||||
apiResp, err = c.CloudBroker().KVMX86().CreateBlank(ctx, createBlankReq)
|
||||
} else {
|
||||
apiResp, err = c.CloudBroker().KVMX86().Create(ctx, createReqX86)
|
||||
}
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@@ -448,6 +473,9 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
|
||||
if nodeID, ok := d.GetOk("node_id"); ok {
|
||||
req.NodeID = uint64(nodeID.(int))
|
||||
}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", computeId)
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||
warnings.Add(err)
|
||||
|
||||
@@ -3409,6 +3409,12 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: false,
|
||||
},
|
||||
"create_blank": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
Description: "If True, the compute is created via kvmx86/createBlank endpoint (without OS image). The image_id field is not required in this case.",
|
||||
},
|
||||
"boot_disk_size": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
@@ -3531,22 +3537,22 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
DiffSuppressFunc: networkSubresIPAddreDiffSupperss,
|
||||
Description: "unique_identifier of LogicalPort on SDN side",
|
||||
},
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "network enable flag",
|
||||
},
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Subnet mask, used only for DPDK and VFNIC network types",
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "network enable flag",
|
||||
},
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Subnet mask, used only for DPDK and VFNIC network types",
|
||||
},
|
||||
},
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
},
|
||||
|
||||
"libvirt_settings": {
|
||||
Type: schema.TypeSet,
|
||||
@@ -3757,11 +3763,9 @@ func resourceComputeSchemaMake() map[string]*schema.Schema {
|
||||
Description: "Storage endpoint provider ID; by default the same with boot disk",
|
||||
},
|
||||
"disk_type": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
ValidateFunc: validation.StringInSlice([]string{"B", "D"}, false),
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
Description: "The type of disk in terms of its role in compute: 'B=Boot, D=Data'",
|
||||
},
|
||||
"pool": {
|
||||
Type: schema.TypeString,
|
||||
|
||||
@@ -209,7 +209,11 @@ func utilityComputeResize(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
}
|
||||
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
|
||||
req := compute.StartRequest{ComputeID: computeId}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -362,9 +366,6 @@ func utilityComputeUpdateDisks(ctx context.Context, d *schema.ResourceData, m in
|
||||
if diskConv["sep_id"].(int) != 0 {
|
||||
req.SepID = uint64(diskConv["sep_id"].(int))
|
||||
}
|
||||
if diskConv["disk_type"].(string) != "" {
|
||||
req.DiskType = diskConv["disk_type"].(string)
|
||||
}
|
||||
if diskConv["pool"].(string) != "" {
|
||||
req.Pool = diskConv["pool"].(string)
|
||||
}
|
||||
@@ -981,7 +982,13 @@ func utilityComputeNetworksConfigure(ctx context.Context, d *schema.ResourceData
|
||||
|
||||
if needStart {
|
||||
computeId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
if numErr, err := utilityComputeStart(ctx, computeId, m); err != nil {
|
||||
var altBootID uint64
|
||||
if altBootIDRaw, ok := d.Get("alt_boot_id").(int); ok {
|
||||
altBootID = uint64(altBootIDRaw)
|
||||
} else {
|
||||
altBootID = 0
|
||||
}
|
||||
if numErr, err := utilityComputeStart(ctx, altBootID, computeId, m); err != nil {
|
||||
apiErrCount += numErr
|
||||
lastSavedError = err
|
||||
}
|
||||
@@ -1308,7 +1315,11 @@ func utilityComputeUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
|
||||
// If used to be STARTED, we need to start it after update
|
||||
if isStopRequired {
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, compute.StartRequest{ComputeID: computeId}); err != nil {
|
||||
req := compute.StartRequest{ComputeID: computeId}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
req.AltBootID = uint64(altBootID)
|
||||
}
|
||||
if _, err := c.CloudBroker().Compute().Start(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1779,6 +1790,9 @@ func utilityComputeRollback(ctx context.Context, d *schema.ResourceData, m inter
|
||||
}
|
||||
|
||||
startReq := compute.StartRequest{ComputeID: computeId}
|
||||
if altBootID, ok := d.Get("alt_boot_id").(int); ok {
|
||||
startReq.AltBootID = uint64(altBootID)
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeRollback: starting compute %d", computeId)
|
||||
|
||||
@@ -2036,10 +2050,14 @@ func utilityComputeStop(ctx context.Context, d *schema.ResourceData, m interface
|
||||
return nil
|
||||
}
|
||||
|
||||
func utilityComputeStart(ctx context.Context, computeID uint64, m interface{}) (int, error) {
|
||||
func utilityComputeStart(ctx context.Context, computeID uint64, altBootID uint64, m interface{}) (int, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
startReq := compute.StartRequest{ComputeID: computeID}
|
||||
|
||||
if altBootID > 0 {
|
||||
startReq.AltBootID = altBootID
|
||||
}
|
||||
|
||||
log.Debugf("utilityComputeStart: starting compute %d", computeID)
|
||||
_, err := c.CloudBroker().Compute().Start(ctx, startReq)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,11 +15,11 @@ func flattenTrunkResource(d *schema.ResourceData, details *trunk.ItemTrunk) {
|
||||
d.Set("name", details.Name)
|
||||
d.Set("mac", details.MAC)
|
||||
d.Set("description", details.Description)
|
||||
d.Set("accountIds", details.AccountIDs)
|
||||
d.Set("ovsBridge", details.OVSBridge)
|
||||
d.Set("nativeVlanId", details.NativeVLANID)
|
||||
d.Set("account_ids", details.AccountIDs)
|
||||
d.Set("ovs_bridge", details.OVSBridge)
|
||||
d.Set("native_vlan_id", details.NativeVLANID)
|
||||
d.Set("status", details.Status)
|
||||
d.Set("trunkTags", details.TrunkTags)
|
||||
d.Set("trunk_tags", details.TrunkTags)
|
||||
d.Set("created_at", details.CreatedAt)
|
||||
d.Set("created_by", details.CreatedBy)
|
||||
d.Set("updated_at", details.UpdatedAt)
|
||||
|
||||
@@ -33,6 +33,7 @@ package vfpool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
@@ -85,6 +86,12 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
}
|
||||
|
||||
config, configOk := d.GetOk("config")
|
||||
|
||||
enableVal := d.Get("enable").(bool)
|
||||
if enableVal && !configOk {
|
||||
return diag.FromErr(fmt.Errorf("enable requires config to be set"))
|
||||
}
|
||||
|
||||
if configOk {
|
||||
configArray := config.(*schema.Set).List()
|
||||
req.Config = make([]vfpool.Config, 0, len(configArray))
|
||||
@@ -117,10 +124,8 @@ func resourceVFPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
if enable, ok := d.GetOk("enable"); ok {
|
||||
if err := utilityVFPoolEnabled(ctx, m, enable.(bool), vfPoolID, configOk); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
if err := utilityVFPoolEnabled(ctx, m, enableVal, vfPoolID); err != nil {
|
||||
warnings.Add(err)
|
||||
}
|
||||
|
||||
log.Debugf("resourceVFPoolCreate: create VFPool with ID: %d, complete", vfPoolID)
|
||||
@@ -147,20 +152,12 @@ func resourceVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
|
||||
|
||||
log.Debugf("resourceVFPoolUpdate: called VFPool with id %d", vfPoolID)
|
||||
|
||||
_, ok := d.GetOk("config")
|
||||
|
||||
if d.HasChanges("name,", "description", "account_access", "rg_access,", "config") {
|
||||
if d.HasChanges("name", "description", "account_access", "rg_access", "config", "enable") {
|
||||
if err := utilityVFPoolUpdate(ctx, d, m, vfPoolID); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("enable") {
|
||||
if err := utilityVFPoolEnabled(ctx, m, d.Get("enable").(bool), vfPoolID, ok); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("resourceVFPoolUpdate: update VFPool with id %d, complete", vfPoolID)
|
||||
|
||||
return resourceVFPoolRead(ctx, d, m)
|
||||
|
||||
@@ -64,37 +64,26 @@ func utilityVFpoolCheckPresence(ctx context.Context, d *schema.ResourceData, m i
|
||||
return vfpoolData, nil
|
||||
}
|
||||
|
||||
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64, configOk bool) error {
|
||||
func utilityVFPoolEnabled(ctx context.Context, m interface{}, enable bool, vfPoolID uint64) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if enable && configOk {
|
||||
req := vfpool.EnableRequest{
|
||||
VFPoolID: vfPoolID,
|
||||
}
|
||||
_, err := c.CloudBroker().VFPool().Enable(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if enable && !configOk {
|
||||
return fmt.Errorf("you must provide configuration for this resource, after enabling it")
|
||||
}
|
||||
if !enable {
|
||||
req := vfpool.DisableRequest{
|
||||
VFPoolID: vfPoolID,
|
||||
}
|
||||
_, err := c.CloudBroker().VFPool().Disable(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var err error
|
||||
|
||||
if enable {
|
||||
_, err = c.CloudBroker().VFPool().Enable(ctx, vfpool.EnableRequest{VFPoolID: vfPoolID})
|
||||
} else {
|
||||
_, err = c.CloudBroker().VFPool().Disable(ctx, vfpool.DisableRequest{VFPoolID: vfPoolID})
|
||||
}
|
||||
|
||||
log.Debugf("utilityVFPoolEnabled: enable=%v vfPool ID %d after completing its resource configuration", enable, vfPoolID)
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, vfPoolID uint64) error {
|
||||
hasConfig := len(d.Get("config").(*schema.Set).List()) > 0
|
||||
if d.Get("enable").(bool) && !hasConfig {
|
||||
return fmt.Errorf("enable requires config to be set")
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
vfPool, err := utilityVFpoolCheckPresence(ctx, d, m)
|
||||
@@ -190,7 +179,7 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
}
|
||||
log.Debugf("utilityVFPoolUpdate: update vfPool with ID: %d, complete with params=%v", vfPoolID, req)
|
||||
|
||||
if len(d.Get("config").(*schema.Set).List()) > 0 && d.Get("enable").(bool) {
|
||||
if hasConfig && d.Get("enable").(bool) {
|
||||
reqEnable := vfpool.EnableRequest{
|
||||
VFPoolID: vfPoolID,
|
||||
}
|
||||
@@ -201,8 +190,6 @@ func utilityVFPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfac
|
||||
return err
|
||||
}
|
||||
log.Debugf("utilityVFPoolUpdate: enable vfPool with ID: %d, complete", vfPoolID)
|
||||
} else {
|
||||
return (fmt.Errorf("the vfPool is not enabled after update, you must provide configuration for this resource, after enabling it"))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
)
|
||||
|
||||
func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
|
||||
log.Debugf("flattenZone: start decoding RecordZone name %q / ID %d",
|
||||
item.Name, item.ID)
|
||||
|
||||
d.Set("zone_id", int(item.ID))
|
||||
d.Set("guid", int(item.GUID))
|
||||
d.Set("gid", int(item.GID))
|
||||
d.Set("name", item.Name)
|
||||
d.Set("description", item.Description)
|
||||
d.Set("deletable", item.Deletable)
|
||||
d.Set("status", item.Status)
|
||||
d.Set("created_time", item.CreatedTime)
|
||||
d.Set("updated_time", item.UpdatedTime)
|
||||
d.Set("node_ids", item.NodeIDs)
|
||||
d.Set("account_ids", item.AccountIDs)
|
||||
d.Set("compute_ids", item.ComputeIDs)
|
||||
d.Set("extnet_ids", item.ExtnetIDs)
|
||||
d.Set("vins_ids", item.VinsIDs)
|
||||
d.Set("lb_ids", item.LBIDs)
|
||||
d.Set("bservice_ids", item.BserviceIDs)
|
||||
d.Set("k8s_ids", item.K8SIDs)
|
||||
d.Set("auto_start", item.AutoStart)
|
||||
|
||||
log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete",
|
||||
item.Name, item.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenZoneList(zone *zone.ListZones) []map[string]interface{} {
|
||||
log.Debugf("flattenZoneList start")
|
||||
res := make([]map[string]interface{}, 0, len(zone.Data))
|
||||
for _, zone := range zone.Data {
|
||||
temp := map[string]interface{}{
|
||||
"zone_id": int(zone.ID),
|
||||
"guid": int(zone.GUID),
|
||||
"gid": int(zone.GID),
|
||||
"name": zone.Name,
|
||||
"description": zone.Description,
|
||||
"deletable": zone.Deletable,
|
||||
"status": zone.Status,
|
||||
"created_time": zone.CreatedTime,
|
||||
"updated_time": zone.UpdatedTime,
|
||||
"node_ids": zone.NodeIDs,
|
||||
"auto_start": zone.AutoStart,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
log.Debugf("flattenZoneList end")
|
||||
return res
|
||||
|
||||
}
|
||||
/*
|
||||
Copyright (c) 2019-2024 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
)
|
||||
|
||||
func flattenZone(d *schema.ResourceData, item *zone.RecordZone) error {
|
||||
log.Debugf("flattenZone: start decoding RecordZone name %q / ID %d",
|
||||
item.Name, item.ID)
|
||||
|
||||
d.Set("zone_id", int(item.ID))
|
||||
d.Set("guid", int(item.GUID))
|
||||
d.Set("gid", int(item.GID))
|
||||
d.Set("name", item.Name)
|
||||
d.Set("description", item.Description)
|
||||
d.Set("deletable", item.Deletable)
|
||||
d.Set("status", item.Status)
|
||||
d.Set("created_time", item.CreatedTime)
|
||||
d.Set("updated_time", item.UpdatedTime)
|
||||
d.Set("node_ids", item.NodeIDs)
|
||||
d.Set("account_ids", item.AccountIDs)
|
||||
d.Set("compute_ids", item.ComputeIDs)
|
||||
d.Set("extnet_ids", item.ExtnetIDs)
|
||||
d.Set("vins_ids", item.VinsIDs)
|
||||
d.Set("lb_ids", item.LBIDs)
|
||||
d.Set("bservice_ids", item.BserviceIDs)
|
||||
d.Set("k8s_ids", item.K8SIDs)
|
||||
d.Set("auto_start", item.AutoStart)
|
||||
|
||||
log.Debugf("flattenZone: decoded RecordZone name %q / ID %d, complete",
|
||||
item.Name, item.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func flattenZoneList(zone *zone.ListZones) []map[string]interface{} {
|
||||
log.Debugf("flattenZoneList start")
|
||||
res := make([]map[string]interface{}, 0, len(zone.Data))
|
||||
for _, zone := range zone.Data {
|
||||
temp := map[string]interface{}{
|
||||
"zone_id": int(zone.ID),
|
||||
"guid": int(zone.GUID),
|
||||
"gid": int(zone.GID),
|
||||
"name": zone.Name,
|
||||
"description": zone.Description,
|
||||
"deletable": zone.Deletable,
|
||||
"status": zone.Status,
|
||||
"created_time": zone.CreatedTime,
|
||||
"updated_time": zone.UpdatedTime,
|
||||
"node_ids": zone.NodeIDs,
|
||||
"auto_start": zone.AutoStart,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
log.Debugf("flattenZoneList end")
|
||||
return res
|
||||
|
||||
}
|
||||
|
||||
@@ -1,159 +1,159 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := zone.GetRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
zoneId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.ID = zoneId
|
||||
} else {
|
||||
req.ID = uint64(d.Get("zone_id").(int))
|
||||
}
|
||||
|
||||
zoneData, err := c.CloudBroker().Zone().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return zoneData, nil
|
||||
}
|
||||
|
||||
func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if d.HasChanges("name", "description", "auto_start") {
|
||||
req := zone.UpdateRequest{
|
||||
ID: zoneID,
|
||||
}
|
||||
|
||||
if d.HasChange("name") {
|
||||
req.Name = d.Get("name").(string)
|
||||
}
|
||||
if d.HasChange("description") {
|
||||
req.Description = d.Get("description").(string)
|
||||
}
|
||||
|
||||
if d.HasChange("auto_start") {
|
||||
req.AutoStart = d.Get("auto_start").(bool)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Zone().Update(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("utilityZoneUpdate: update zone with ID: %d, complete with params=%v", zoneID, req)
|
||||
}
|
||||
|
||||
addedNodes := make([]interface{}, 0)
|
||||
removedNodes := make([]interface{}, 0)
|
||||
|
||||
old_set, new_set := d.GetChange("node_ids")
|
||||
oldSlice := old_set.([]interface{})
|
||||
newSlice := new_set.([]interface{})
|
||||
|
||||
for _, oldElem := range oldSlice {
|
||||
if !containsNodes(newSlice, oldElem) {
|
||||
removedNodes = append(removedNodes, oldElem)
|
||||
}
|
||||
}
|
||||
|
||||
for _, newElem := range newSlice {
|
||||
if !containsNodes(oldSlice, newElem) {
|
||||
addedNodes = append(addedNodes, newElem)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("Found node_ids change with %v deletion(s) and %v addition(s) [zoneID=%v]", len(removedNodes), len(addedNodes), zoneID)
|
||||
|
||||
if len(addedNodes) > 0 {
|
||||
|
||||
addedUint := make([]uint64, len(addedNodes))
|
||||
for i, v := range addedNodes {
|
||||
addedUint[i] = uint64(v.(int))
|
||||
}
|
||||
|
||||
req := zone.AddNodeRequest{
|
||||
ID: zoneID,
|
||||
NodeIDs: addedUint,
|
||||
}
|
||||
if _, err := c.CloudBroker().Zone().AddNode(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(removedNodes) > 0 {
|
||||
removedUint := make([]uint64, len(removedNodes))
|
||||
for i, v := range removedNodes {
|
||||
removedUint[i] = uint64(v.(int))
|
||||
}
|
||||
|
||||
req := zone.DelNodeRequest{
|
||||
ID: zoneID,
|
||||
NodeIDs: removedUint,
|
||||
}
|
||||
log.Debug("del")
|
||||
log.Debug(req.NodeIDs)
|
||||
if _, err := c.CloudBroker().Zone().DelNode(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func containsNodes(set []interface{}, check interface{}) bool {
|
||||
for _, elem := range set {
|
||||
elemConv := elem.(int)
|
||||
checkConv := check.(int)
|
||||
if elemConv == checkConv {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func utilityZoneCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.RecordZone, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := zone.GetRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
zoneId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.ID = zoneId
|
||||
} else {
|
||||
req.ID = uint64(d.Get("zone_id").(int))
|
||||
}
|
||||
|
||||
zoneData, err := c.CloudBroker().Zone().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return zoneData, nil
|
||||
}
|
||||
|
||||
func utilityZoneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}, zoneID uint64) error {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if d.HasChanges("name", "description", "auto_start") {
|
||||
req := zone.UpdateRequest{
|
||||
ID: zoneID,
|
||||
}
|
||||
|
||||
if d.HasChange("name") {
|
||||
req.Name = d.Get("name").(string)
|
||||
}
|
||||
if d.HasChange("description") {
|
||||
req.Description = d.Get("description").(string)
|
||||
}
|
||||
|
||||
if d.HasChange("auto_start") {
|
||||
req.AutoStart = d.Get("auto_start").(bool)
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().Zone().Update(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Debugf("utilityZoneUpdate: update zone with ID: %d, complete with params=%v", zoneID, req)
|
||||
}
|
||||
|
||||
addedNodes := make([]interface{}, 0)
|
||||
removedNodes := make([]interface{}, 0)
|
||||
|
||||
old_set, new_set := d.GetChange("node_ids")
|
||||
oldSlice := old_set.([]interface{})
|
||||
newSlice := new_set.([]interface{})
|
||||
|
||||
for _, oldElem := range oldSlice {
|
||||
if !containsNodes(newSlice, oldElem) {
|
||||
removedNodes = append(removedNodes, oldElem)
|
||||
}
|
||||
}
|
||||
|
||||
for _, newElem := range newSlice {
|
||||
if !containsNodes(oldSlice, newElem) {
|
||||
addedNodes = append(addedNodes, newElem)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("Found node_ids change with %v deletion(s) and %v addition(s) [zoneID=%v]", len(removedNodes), len(addedNodes), zoneID)
|
||||
|
||||
if len(addedNodes) > 0 {
|
||||
|
||||
addedUint := make([]uint64, len(addedNodes))
|
||||
for i, v := range addedNodes {
|
||||
addedUint[i] = uint64(v.(int))
|
||||
}
|
||||
|
||||
req := zone.AddNodeRequest{
|
||||
ID: zoneID,
|
||||
NodeIDs: addedUint,
|
||||
}
|
||||
if _, err := c.CloudBroker().Zone().AddNode(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(removedNodes) > 0 {
|
||||
removedUint := make([]uint64, len(removedNodes))
|
||||
for i, v := range removedNodes {
|
||||
removedUint[i] = uint64(v.(int))
|
||||
}
|
||||
|
||||
req := zone.DelNodeRequest{
|
||||
ID: zoneID,
|
||||
NodeIDs: removedUint,
|
||||
}
|
||||
log.Debug("del")
|
||||
log.Debug(req.NodeIDs)
|
||||
if _, err := c.CloudBroker().Zone().DelNode(ctx, req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func containsNodes(set []interface{}, check interface{}) bool {
|
||||
for _, elem := range set {
|
||||
elemConv := elem.(int)
|
||||
checkConv := check.(int)
|
||||
if elemConv == checkConv {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := zone.ListRequest{}
|
||||
|
||||
if byId, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(byId.(int))
|
||||
}
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
req.GID = uint64(gid.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if description, ok := d.GetOk("description"); ok {
|
||||
req.Description = description.(string)
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if deletable, ok := d.GetOk("deletable"); ok {
|
||||
req.Deletable = deletable.(bool)
|
||||
}
|
||||
if nodeID, ok := d.GetOk("nodeId"); ok {
|
||||
req.NodeID = uint64(nodeID.(int))
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
zoneList, err := c.CloudBroker().Zone().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return zoneList, nil
|
||||
}
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
Kasim Baybikov, <kmbaybikov@basistech.ru>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
|
||||
Orchestration Technology) with Terraform by Hashicorp.
|
||||
|
||||
Source code: https://repository.basistech.ru/BASIS/terraform-provider-decort
|
||||
|
||||
Please see README.md to learn where to place source code so that it
|
||||
builds seamlessly.
|
||||
|
||||
Documentation: https://repository.basistech.ru/BASIS/terraform-provider-decort/wiki
|
||||
*/
|
||||
|
||||
package zone
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
func utilityZoneListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*zone.ListZones, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := zone.ListRequest{}
|
||||
|
||||
if byId, ok := d.GetOk("by_id"); ok {
|
||||
req.ByID = uint64(byId.(int))
|
||||
}
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
req.GID = uint64(gid.(int))
|
||||
}
|
||||
if name, ok := d.GetOk("name"); ok {
|
||||
req.Name = name.(string)
|
||||
}
|
||||
if description, ok := d.GetOk("description"); ok {
|
||||
req.Description = description.(string)
|
||||
}
|
||||
if status, ok := d.GetOk("status"); ok {
|
||||
req.Status = status.(string)
|
||||
}
|
||||
if deletable, ok := d.GetOk("deletable"); ok {
|
||||
req.Deletable = deletable.(bool)
|
||||
}
|
||||
if nodeID, ok := d.GetOk("nodeId"); ok {
|
||||
req.NodeID = uint64(nodeID.(int))
|
||||
}
|
||||
if sortBy, ok := d.GetOk("sort_by"); ok {
|
||||
req.SortBy = sortBy.(string)
|
||||
}
|
||||
if size, ok := d.GetOk("size"); ok {
|
||||
req.Size = uint64(size.(int))
|
||||
}
|
||||
if page, ok := d.GetOk("page"); ok {
|
||||
req.Page = uint64(page.(int))
|
||||
}
|
||||
|
||||
zoneList, err := c.CloudBroker().Zone().List(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return zoneList, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user