This commit is contained in:
dayterr
2026-02-27 17:24:15 +03:00
parent b8283ebfaf
commit 156b0a2d0c
37 changed files with 1664 additions and 1835 deletions

View File

@@ -802,6 +802,11 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
Type: schema.TypeBool,
Computed: true,
},
"blk_discard": {
Type: schema.TypeBool,
Computed: true,
Description: "Flag indicating whether blk-discard is enabled for the disk",
},
}
return rets

View File

@@ -71,7 +71,7 @@ func resourceDiskSnapshotCreate(ctx context.Context, d *schema.ResourceData, m i
TimeStamp: uint64(d.Get("timestamp").(int)),
}
log.Debugf("resourceDiskCreate: Snapshot rollback with label", label)
log.Debugf("resourceDiskCreate: Snapshot rollback with label %s", label)
_, err := c.CloudAPI().Disks().SnapshotRollback(ctx, req)
if err != nil {
return diag.FromErr(err)

View File

@@ -1,139 +1,139 @@
/*
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 image
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string))
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
Name: d.Get("name").(string),
TargetID: uint64(d.Get("link_to").(int)),
AccountID: uint64(d.Get("account_id").(int)),
}
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId)
_, err = utilityImageCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
if d.HasChange("name") {
err := resourceImageRename(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("link_to") {
err := resourceImageVirtualLink(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
req := image.LinkRequest{
ImageID: uint64(d.Get("image_id").(int)),
TargetID: uint64(d.Get("link_to").(int)),
}
_, err := c.CloudAPI().Image().Link(ctx, req)
if err != nil {
return err
}
return nil
}
func ResourceImageVirtual() *schema.Resource {
return &schema.Resource{
SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead,
UpdateContext: resourceImageVirtualUpdate,
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
}
}
/*
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 image
import (
"context"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
)
func resourceImageVirtualCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageVirtualCreate: called for image %s", d.Get("name").(string))
c := m.(*controller.ControllerCfg)
req := image.CreateVirtualRequest{
Name: d.Get("name").(string),
TargetID: uint64(d.Get("link_to").(int)),
AccountID: uint64(d.Get("account_id").(int)),
}
imageId, err := c.CloudAPI().Image().CreateVirtual(ctx, req)
if err != nil {
return diag.FromErr(err)
}
d.SetId(strconv.FormatUint(imageId, 10))
d.Set("image_id", imageId)
_, err = utilityImageCheckPresence(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceImageUpdate: called for %s, id: %s", d.Get("name").(string), d.Id())
if d.HasChange("name") {
err := resourceImageRename(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
if d.HasChange("link_to") {
err := resourceImageVirtualLink(ctx, d, m)
if err != nil {
return diag.FromErr(err)
}
}
return resourceImageRead(ctx, d, m)
}
func resourceImageVirtualLink(ctx context.Context, d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceVirtualImageLink: called for %s, id: %s", d.Get("name").(string), d.Id())
c := m.(*controller.ControllerCfg)
req := image.LinkRequest{
ImageID: uint64(d.Get("image_id").(int)),
TargetID: uint64(d.Get("link_to").(int)),
}
_, err := c.CloudAPI().Image().Link(ctx, req)
if err != nil {
return err
}
return nil
}
func ResourceImageVirtual() *schema.Resource {
return &schema.Resource{
SchemaVersion: 2,
CreateContext: resourceImageVirtualCreate,
ReadContext: resourceImageRead,
UpdateContext: resourceImageVirtualUpdate,
DeleteContext: resourceImageDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
Timeouts: &schema.ResourceTimeout{
Create: &constants.Timeout600s,
Read: &constants.Timeout300s,
Update: &constants.Timeout300s,
Delete: &constants.Timeout300s,
Default: &constants.Timeout300s,
},
Schema: resourceImageVirtualSchemaMake(dataSourceImageExtendSchemaMake()),
StateUpgraders: []schema.StateUpgrader{
{
Type: resourceImageVirtualSchemaV1().CoreConfigSchema().ImpliedType(),
Upgrade: resourcePresentToUpgradeV1,
Version: 1,
},
},
}
}

View File

@@ -805,13 +805,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
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",
},
"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",
},
"desc": {
Type: schema.TypeString,

View File

@@ -715,13 +715,13 @@ func resourceK8sCPSchemaMake() 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",
},
"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,

View File

@@ -290,13 +290,13 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
Description: "Number of worker nodes to create.",
},
"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",
},
"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",
},
"cpu": {
Type: schema.TypeInt,

View File

@@ -476,6 +476,9 @@ func flattenCompute(d *schema.ResourceData, computeRec compute.RecordCompute, pc
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID)
d.Set("loader_meta_iso", flattenLoaderMetaIso(computeRec.LoaderMetaIso))
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
d.Set("enabled", false)
if computeRec.Status == status.Enabled {

View File

@@ -1,300 +1,300 @@
/*
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 lb
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
)
func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) {
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)
}
func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) {
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))
}
func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) {
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)
}
func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) {
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))
}
func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
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("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("lb_id", lb.ID)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
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("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("account_id", lb.AccountID)
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
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("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
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("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenNode(node lb.RecordNode) []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 []lb.ItemBinding) []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 []lb.ItemFrontend) []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 []lb.ItemServer) []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 lb.RecordServerSettings) []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 []lb.ItemBackend) []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
}
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lbl.Data))
for _, lb := range lbl.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backend_haip": lb.BackendHAIP,
"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,
"frontend_haip": lb.FrontendHAIP,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"manager_id": lb.ManagerId,
"manager_type": lb.ManagerType,
"image_id": lb.ImageID,
"milestones": lb.Milestones,
"name": lb.Name,
"part_k8s": lb.PartK8s,
"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,
"user_managed": lb.UserManaged,
"vins_id": lb.VINSID,
"lb_id": lb.ID,
"zone_id": lb.ZoneID,
}
res = append(res, temp)
}
return res
}
/*
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 lb
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
)
func flattenLBFrontendBind(d *schema.ResourceData, b *lb.ItemBinding, lbId int64, frontendName string) {
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)
}
func flattenLBFrontend(d *schema.ResourceData, f *lb.ItemFrontend, lbId int64) {
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))
}
func flattenResourceLBBackendServer(d *schema.ResourceData, s *lb.ItemServer, lbId int64, backendName string) {
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)
}
func flattenResourceLBBackend(d *schema.ResourceData, b *lb.ItemBackend, lbId int64) {
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))
}
func flattenResourceLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
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("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("lb_id", lb.ID)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
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("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenLB(d *schema.ResourceData, lb *lb.RecordLB) {
d.Set("account_id", lb.AccountID)
d.Set("ha_mode", lb.HAMode)
d.Set("backend_haip", lb.BackendHAIP)
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("frontend_haip", lb.FrontendHAIP)
d.Set("frontends", flattenFrontends(lb.Frontends))
d.Set("gid", lb.GID)
d.Set("guid", lb.GUID)
d.Set("manager_id", lb.ManagerId)
d.Set("manager_type", lb.ManagerType)
d.Set("image_id", lb.ImageID)
d.Set("milestones", lb.Milestones)
d.Set("name", lb.Name)
d.Set("part_k8s", lb.PartK8s)
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("user_managed", lb.UserManaged)
d.Set("vins_id", lb.VINSID)
d.Set("zone_id", lb.ZoneID)
}
func flattenNode(node lb.RecordNode) []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 []lb.ItemBinding) []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 []lb.ItemFrontend) []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 []lb.ItemServer) []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 lb.RecordServerSettings) []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 []lb.ItemBackend) []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
}
func flattenLBList(lbl *lb.ListLB) []map[string]interface{} {
res := make([]map[string]interface{}, 0, len(lbl.Data))
for _, lb := range lbl.Data {
temp := map[string]interface{}{
"ha_mode": lb.HAMode,
"backend_haip": lb.BackendHAIP,
"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,
"frontend_haip": lb.FrontendHAIP,
"frontends": flattenFrontends(lb.Frontends),
"gid": lb.GID,
"guid": lb.GUID,
"manager_id": lb.ManagerId,
"manager_type": lb.ManagerType,
"image_id": lb.ImageID,
"milestones": lb.Milestones,
"name": lb.Name,
"part_k8s": lb.PartK8s,
"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,
"user_managed": lb.UserManaged,
"vins_id": lb.VINSID,
"lb_id": lb.ID,
"zone_id": lb.ZoneID,
}
res = append(res, temp)
}
return res
}

View File

@@ -1,119 +1,119 @@
/*
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 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["zone_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
}
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: 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["safe"] = &schema.Schema{
Type: schema.TypeBool,
Default: true,
Optional: true,
}
sch["config_reset"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
///4.4.0
sch["ha_mode"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["sysctl_params"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
///
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
return sch
}
/*
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 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["zone_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Computed: true,
}
sch["extnet_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["vins_id"] = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
}
sch["start"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: 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["safe"] = &schema.Schema{
Type: schema.TypeBool,
Default: true,
Optional: true,
}
sch["config_reset"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
///4.4.0
sch["ha_mode"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
sch["sysctl_params"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeMap,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
}
///
sch["permanently"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
}
return sch
}

View File

@@ -1,396 +1,396 @@
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func createLBSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"ha_mode": {
Type: schema.TypeBool,
Computed: true,
},
"backend_haip": {
Type: schema.TypeString,
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,
},
"frontend_haip": {
Type: schema.TypeString,
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,
},
"manager_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_type": {
Type: schema.TypeString,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"part_k8s": {
Type: schema.TypeBool,
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,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
"vins_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}
/*
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 lb
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func createLBSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_id": {
Type: schema.TypeInt,
Computed: true,
},
"ha_mode": {
Type: schema.TypeBool,
Computed: true,
},
"backend_haip": {
Type: schema.TypeString,
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,
},
"frontend_haip": {
Type: schema.TypeString,
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,
},
"manager_id": {
Type: schema.TypeInt,
Computed: true,
},
"manager_type": {
Type: schema.TypeString,
Computed: true,
},
"image_id": {
Type: schema.TypeInt,
Computed: true,
},
"milestones": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"part_k8s": {
Type: schema.TypeBool,
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,
},
"user_managed": {
Type: schema.TypeBool,
Computed: true,
},
"vins_id": {
Type: schema.TypeInt,
Computed: true,
},
}
}

View File

@@ -1,36 +1,36 @@
/*
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.
*/
package locations
type Location struct {
GridID int `json:"gid"`
Id int `json:"id"`
Guid int `json:"guid"`
LocationCode string `json:"locationCode"`
Name string `json:"name"`
NetworkModes []string `json:"network_modes"`
SDNSupport bool `json:"sdn_support"`
Flag string `json:"flag"`
Meta []interface{} `json:"_meta"`
CKey string `json:"_ckey"`
}
type LocationsList []Location
/*
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.
*/
package locations
type Location struct {
GridID int `json:"gid"`
Id int `json:"id"`
Guid int `json:"guid"`
LocationCode string `json:"locationCode"`
Name string `json:"name"`
NetworkModes []string `json:"network_modes"`
SDNSupport bool `json:"sdn_support"`
Flag string `json:"flag"`
Meta []interface{} `json:"_meta"`
CKey string `json:"_ckey"`
}
type LocationsList []Location

View File

@@ -352,8 +352,8 @@ func flattenRgListComputes(lc *rg.ListComputes) []map[string]interface{} {
"status": compute.Status,
"tech_status": compute.TechStatus,
"total_disks_size": compute.TotalDisksSize,
"updated_by": compute.DeletedBy,
"updated_time": compute.DeletedTime,
"updated_by": compute.UpdatedBy,
"updated_time": compute.UpdatedTime,
"user_managed": compute.UserManaged,
"vins_connected": compute.VINSConnected,
}

View File

@@ -128,8 +128,12 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
}
}
}
if defNetType, ok := d.GetOk("def_net_type"); ok {
req.DefNet = defNetType.(string) // NOTE: in API default network type is set by "def_net" parameter
if _, ok := d.GetOk("def_net"); !ok {
if defNetType, ok := d.GetOk("def_net_type"); ok {
req.DefNet = defNetType.(string) // NOTE: in API default network type is set by "def_net" parameter
}
} else {
req.DefNet = "NONE"
}
if owner, ok := d.GetOk("owner"); ok {

View File

@@ -60,7 +60,7 @@ func dataSourceZoneSchemaMake() map[string]*schema.Schema {
},
"auto_start": {
Type: schema.TypeBool,
Required: true,
Computed: true,
},
"guid": {
Type: schema.TypeInt,

View File

@@ -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/cloudapi/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/cloudapi/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
}

View File

@@ -1,62 +1,62 @@
/*
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/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
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.CloudAPI().Zone().Get(ctx, req)
if err != nil {
return nil, err
}
return zoneData, 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"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/controller"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
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.CloudAPI().Zone().Get(ctx, req)
if err != nil {
return nil, err
}
return zoneData, nil
}

View File

@@ -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/cloudapi/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.CloudAPI().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/cloudapi/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.CloudAPI().Zone().List(ctx, req)
if err != nil {
return nil, err
}
return zoneList, nil
}

View File

@@ -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,

View File

@@ -110,6 +110,9 @@ func flattenCompute(d *schema.ResourceData, computeRec *compute.RecordCompute, p
d.Set("network_interface_naming", computeRec.NetworkInterfaceNaming)
d.Set("zone_id", computeRec.ZoneID)
d.Set("os_version", computeRec.OSVersion)
d.Set("cpu_pin", computeRec.CPUPin)
d.Set("numa_affinity", computeRec.NumaAffinity)
d.Set("hp_backed", computeRec.HPBacked)
return nil
}

View File

@@ -3531,22 +3531,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,

View File

@@ -105,8 +105,12 @@ func resourceResgroupCreate(ctx context.Context, d *schema.ResourceData, m inter
req.Owner = owner.(string)
}
if defNetType, ok := d.GetOk("def_net_type"); ok {
req.DefNet = defNetType.(string)
if _, ok := d.GetOk("def_net"); !ok {
if defNetType, ok := d.GetOk("def_net_type"); ok {
req.DefNet = defNetType.(string)
}
} else {
req.DefNet = "NONE"
}
if description, ok := d.GetOk("description"); ok {

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -37,4 +37,3 @@ func DataSourceAccessGroupList() *schema.Resource {
Schema: dataSourceAccessGroupListSchemaMake(),
}
}

View File

@@ -49,4 +49,3 @@ func utilityAccessGroupListCheckPresence(ctx context.Context, d *schema.Resource
return accessGroupList, nil
}

View File

@@ -37,4 +37,3 @@ func DataSourceDefaultSecurityPolicyList() *schema.Resource {
Schema: dataSourceDefaultSecurityPolicyListSchemaMake(),
}
}

View File

@@ -366,4 +366,3 @@ func dataSourceDefaultSecurityPolicyListSchemaMake() map[string]*schema.Schema {
return res
}

View File

@@ -37,4 +37,3 @@ func utilityDefaultSecurityPolicyListCheckPresence(ctx context.Context, d *schem
return defaultSecurityPolicyList, nil
}

View File

@@ -52,7 +52,7 @@ func utilitySegmentListCheckPresence(ctx context.Context, d *schema.ResourceData
if updatedTo, ok := d.GetOk("updated_to"); ok {
req.UpdatedTo = updatedTo.(string)
}
log.Debugf("utilitySegmentListCheckPresence")
segmentList, err := c.SDN().Segments().List(ctx, req)
if err != nil {