gos_tech_4.4.3 4.2.4
Tim Tkachev 2 years ago
parent 6365f63fc1
commit f731cf246f

@ -1,4 +1,6 @@
## Version 4.2.3 ## Version 4.2.4
## Bug Fixes ## Bug Fixes
- Made "ipcidr" field in decort_vins resource optional - Fixed incorrect network validation in decort_kvmvm resource
- Fixed inability to remove all networks at once in decort_kvmvm resource
- Deleted "check__ips" (duplicate) field in decort_extnet data source

@ -8,7 +8,7 @@ ZIPDIR = ./zip
BINARY=${NAME}.exe BINARY=${NAME}.exe
WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH} WORKPATH= ./examples/terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAMESPACE}/${VERSION}/${OS_ARCH}
MAINPATH = ./cmd/decort/ MAINPATH = ./cmd/decort/
VERSION=4.2.3 VERSION=4.2.4
#OS_ARCH=darwin_amd64 #OS_ARCH=darwin_amd64
OS_ARCH=windows_amd64 OS_ARCH=windows_amd64
#OS_ARCH=linux_amd64 #OS_ARCH=linux_amd64

@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -71,13 +72,6 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
}, },
Description: "meta", Description: "meta",
}, },
"check__ips": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"check_ips": { "check_ips": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,

@ -9,7 +9,6 @@ import (
func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) { func flattenExtnet(d *schema.ResourceData, e *extnet.RecordExtNet) {
d.Set("ckey", e.CKey) d.Set("ckey", e.CKey)
d.Set("meta", flattens.FlattenMeta(e.Meta)) d.Set("meta", flattens.FlattenMeta(e.Meta))
d.Set("check__ips", e.CheckIPs)
d.Set("check_ips", e.CheckIps) d.Set("check_ips", e.CheckIps)
d.Set("default", e.Default) d.Set("default", e.Default)
d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS)) d.Set("default_qos", flattenExtnetDefaultQos(e.DefaultQOS))

@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -36,8 +37,8 @@ import (
"bytes" "bytes"
"hash/fnv" "hash/fnv"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/statefuncs"
"sort" "sort"

@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -36,6 +37,7 @@ import (
"context" "context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
log "github.com/sirupsen/logrus"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg" "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
@ -91,43 +93,35 @@ func existExtNetIdInList(extId uint64, extList extnet.ListExtNets) bool {
return false return false
} }
func existVinsId(ctx context.Context, d *schema.ResourceData, m interface{}) (int, bool) { func existVinsId(ctx context.Context, m interface{}, id int) (int, bool) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := vins.ListRequest{IncludeDeleted: false} req := vins.ListRequest{IncludeDeleted: false}
vinsList, err := c.CloudAPI().VINS().List(ctx, req) vinsList, err := c.CloudAPI().VINS().List(ctx, req)
if err != nil { if err != nil {
log.Debugf("Unable to retrieve ViNS list, %s", err)
return 0, false return 0, false
} }
networks := d.Get("network").(*schema.Set).List() if !existVinsIdInList(uint64(id), vinsList) {
return id, false
for _, networkInterface := range networks {
networkItem := networkInterface.(map[string]interface{})
if !existVinsIdInList(uint64(networkItem["net_id"].(int)), vinsList) {
return networkItem["net_id"].(int), false
}
} }
return 0, true return 0, true
} }
func existExtNetId(ctx context.Context, d *schema.ResourceData, m interface{}) (int, bool) { func existExtNetId(ctx context.Context, m interface{}, id int) (int, bool) {
c := m.(*controller.ControllerCfg) c := m.(*controller.ControllerCfg)
req := extnet.ListRequest{} req := extnet.ListRequest{}
extNetList, err := c.CloudAPI().ExtNet().List(ctx, req) extNetList, err := c.CloudAPI().ExtNet().List(ctx, req)
if err != nil { if err != nil {
log.Debugf("Unable to retrieve extnet list, %s", err)
return 0, false return 0, false
} }
networks := d.Get("network").(*schema.Set).List() if !existExtNetIdInList(uint64(id), extNetList) {
return id, false
for _, networkInterface := range networks {
networkItem := networkInterface.(map[string]interface{})
if !existExtNetIdInList(uint64(networkItem["net_id"].(int)), extNetList) {
return networkItem["net_id"].(int), false
}
} }
return 0, true return 0, true

@ -4,6 +4,7 @@ Authors:
Petr Krutov, <petr.krutov@digitalenergy.online> Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online> Stanislav Solovev, <spsolovev@digitalenergy.online>
Kasim Baybikov, <kmbaybikov@basistech.ru> Kasim Baybikov, <kmbaybikov@basistech.ru>
Tim Tkachev, <tvtkachev@basistech.ru>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -77,14 +78,22 @@ func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interf
} }
if network, ok := d.GetOk("network"); ok { if network, ok := d.GetOk("network"); ok {
networkData := network.(*schema.Set).List()[0].(map[string]interface{}) networkList := network.(*schema.Set).List()
if networkData["net_type"].(string) == "VINS" { for _, elem := range networkList {
if vinsId, ok := existVinsId(ctx, d, m); !ok { networkData := elem.(map[string]interface{})
return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
} switch networkData["net_type"].(string) {
} else if networkData["net_type"].(string) == "EXTNET" { case "VINS":
if extNetId, ok := existExtNetId(ctx, d, m); !ok { if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId) return diag.Errorf("resourceComputeCreate: can't create compute because vins ID %d is not allowed or does not exist", vinsId)
}
case "EXTNET":
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeCreate: can't create compute because extnet ID %d is not allowed or does not exist", extNetId)
}
default:
continue
} }
} }
} }
@ -557,14 +566,22 @@ func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interf
} }
if network, ok := d.GetOk("network"); ok { if network, ok := d.GetOk("network"); ok {
networkData := network.(*schema.Set).List()[0].(map[string]interface{}) networkList := network.(*schema.Set).List()
if networkData["net_type"].(string) == "VINS" { for _, elem := range networkList {
if vinsId, ok := existVinsId(ctx, d, m); !ok { networkData := elem.(map[string]interface{})
return diag.Errorf("resourceComputeUpdate: can't create update because vins ID %d is not allowed or does not exist", vinsId)
} switch networkData["net_type"].(string) {
} else if networkData["net_type"].(string) == "EXTNET" { case "VINS":
if extNetId, ok := existExtNetId(ctx, d, m); !ok { if vinsId, ok := existVinsId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeUpdate: can't create update because extnet ID %d is not allowed or does not exist", extNetId) return diag.Errorf("resourceComputeUpdate: can't update compute because vins ID %d is not allowed or does not exist", vinsId)
}
case "EXTNET":
if extNetId, ok := existExtNetId(ctx, m, networkData["net_id"].(int)); !ok {
return diag.Errorf("resourceComputeUpdate: can't update compute because extnet ID %d is not allowed or does not exist", extNetId)
}
default:
continue
} }
} }
} }
@ -1704,7 +1721,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
"network": { "network": {
Type: schema.TypeSet, Type: schema.TypeSet,
Computed: true,
Optional: true, Optional: true,
MinItems: 1, MinItems: 1,
MaxItems: constants.MaxNetworksPerCompute, MaxItems: constants.MaxNetworksPerCompute,
@ -1714,18 +1730,6 @@ func ResourceComputeSchemaMake() map[string]*schema.Schema {
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.",
}, },
/*
"ssh_keys": {
Type: schema.TypeList,
Optional: true,
MaxItems: MaxSshKeysPerCompute,
Elem: &schema.Resource{
Schema: sshSubresourceSchemaMake(),
},
Description: "SSH keys to authorize on this compute instance.",
},
*/
"tags": { "tags": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,

Loading…
Cancel
Save