4.3.7
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,8 +34,8 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-decort/internal/constants"
|
||||
@@ -47,8 +47,9 @@ func dataSourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
d.SetId(strconv.FormatUint(vins.ID, 10))
|
||||
flattenVinsData(d, *vins)
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
flattenVinsData(d, vins)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -640,7 +641,7 @@ func rulesSchemaMake() map[string]*schema.Schema {
|
||||
}
|
||||
}
|
||||
|
||||
func configSchrmaMake() map[string]*schema.Schema {
|
||||
func natConfigSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"net_mask": {
|
||||
Type: schema.TypeInt,
|
||||
@@ -678,7 +679,7 @@ func natSchemaMake() map[string]*schema.Schema {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: configSchrmaMake(),
|
||||
Schema: natConfigSchemaMake(),
|
||||
},
|
||||
},
|
||||
"devices": {
|
||||
@@ -768,7 +769,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Required: true,
|
||||
Description: "Unique ID of the ViNS. If ViNS ID is specified, then ViNS name, rg_id and account_id are ignored.",
|
||||
},
|
||||
|
||||
"vnf_dev": {
|
||||
Type: schema.TypeList,
|
||||
Computed: true,
|
||||
@@ -776,10 +776,6 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: vnfDevSchemaMake(),
|
||||
},
|
||||
},
|
||||
"_ckey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
@@ -797,6 +793,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: vinsComputeSchemaMake(),
|
||||
},
|
||||
},
|
||||
"created_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"default_gw": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -808,6 +812,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Schema: qosSchemaMake(),
|
||||
},
|
||||
},
|
||||
"deleted_by": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
"desc": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -874,6 +886,14 @@ func dataSourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
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,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func dataSourceVinsExtNetListRead(ctx context.Context, d *schema.ResourceData, m
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsExtNetList(extNetList))
|
||||
|
||||
d.Set("entry_count", extNetList.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ func DataSourceVinsExtNetListchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func dataSourceVinsIpListRead(ctx context.Context, d *schema.ResourceData, m int
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsIpList(ips))
|
||||
|
||||
d.Set("entry_count", ips.EntryCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ func DataSourceVinsIpListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,6 +49,8 @@ func dataSourceVinsNatRuleListRead(ctx context.Context, d *schema.ResourceData,
|
||||
id := uuid.New()
|
||||
d.SetId(id.String())
|
||||
d.Set("items", flattenVinsNatRuleList(natRules))
|
||||
d.Set("entry_count", natRules.EntryCount)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -99,6 +101,10 @@ func DataSourceVinsNatRuleListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
},
|
||||
},
|
||||
"entry_count": {
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
},
|
||||
}
|
||||
return rets
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -49,7 +49,7 @@ func flattenMGMT(mgmt vins.RecordMGMT) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenResources(resources *vins.RecordResources) []map[string]interface{} {
|
||||
func flattenResources(resources vins.RecordResources) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"cpu": resources.CPU,
|
||||
@@ -65,7 +65,7 @@ func flattenConfig(config vins.RecordVNFConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
temp := map[string]interface{}{
|
||||
"mgmt": flattenMGMT(config.MGMT),
|
||||
"resources": flattenResources(&config.Resources),
|
||||
"resources": flattenResources(config.Resources),
|
||||
}
|
||||
res = append(res, temp)
|
||||
return res
|
||||
@@ -84,8 +84,7 @@ func flattenQOS(qos vins.QOS) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenInterfaces(interfaces []vins.ItemVNFInterface) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
|
||||
res := make([]map[string]interface{}, 0, len(interfaces))
|
||||
for _, vnfInterface := range interfaces {
|
||||
temp := map[string]interface{}{
|
||||
"conn_id": vnfInterface.ConnID,
|
||||
@@ -141,7 +140,7 @@ func flattenVNFDev(vnfDev vins.RecordVNFDev) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(computes))
|
||||
for _, compute := range computes {
|
||||
temp := map[string]interface{}{
|
||||
"compute_id": compute.ID,
|
||||
@@ -154,7 +153,7 @@ func flattenComputes(computes vins.ListVINSComputes) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenReservations(reservations vins.ListReservations) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(reservations))
|
||||
for _, reservation := range reservations {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": reservation.ClientType,
|
||||
@@ -275,9 +274,9 @@ func flattenGW(gw vins.RecordGW) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRules(rules vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, rule := range rules.Data {
|
||||
func flattenRules(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"rule_id": rule.ID,
|
||||
"local_ip": rule.LocalIP,
|
||||
@@ -343,9 +342,9 @@ func flattenVNFS(vnfs vins.RecordVNFs) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, rule := range rules.Data {
|
||||
func flattenRuleBlock(rules vins.ListNATRulesConfig) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(rules))
|
||||
for _, rule := range rules {
|
||||
tmp := map[string]interface{}{
|
||||
"int_ip": rule.LocalIP,
|
||||
"int_port": rule.LocalPort,
|
||||
@@ -359,15 +358,18 @@ func flattenRuleBlock(rules vins.ListNATRules) []map[string]interface{} {
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
func flattenVins(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("_ckey", vins.CKey)
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
@@ -384,21 +386,26 @@ func flattenVins(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
d.Set("nat_rule", flattenRuleBlock(vins.VNFs.NAT.Config.Rules))
|
||||
}
|
||||
|
||||
func flattenVinsData(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
func flattenVinsData(d *schema.ResourceData, vins *vins.RecordVINS) {
|
||||
d.Set("vins_id", vins.ID)
|
||||
d.Set("vnf_dev", flattenVNFDev(vins.VNFDev))
|
||||
d.Set("_ckey", vins.CKey)
|
||||
d.Set("account_id", vins.AccountID)
|
||||
d.Set("account_name", vins.AccountName)
|
||||
d.Set("computes", flattenComputes(vins.Computes))
|
||||
d.Set("created_by", vins.CreatedBy)
|
||||
d.Set("created_time", vins.CreatedTime)
|
||||
d.Set("default_gw", vins.DefaultGW)
|
||||
d.Set("default_qos", flattenQOS(vins.DefaultQOS))
|
||||
d.Set("deleted_by", vins.DeletedBy)
|
||||
d.Set("deleted_time", vins.DeletedTime)
|
||||
d.Set("desc", vins.Description)
|
||||
d.Set("gid", vins.GID)
|
||||
d.Set("guid", vins.GUID)
|
||||
@@ -415,14 +422,16 @@ func flattenVinsData(d *schema.ResourceData, vins vins.RecordVINS) {
|
||||
d.Set("rg_name", vins.RGName)
|
||||
d.Set("sec_vnf_dev_id", vins.SecVNFDevID)
|
||||
d.Set("status", vins.Status)
|
||||
d.Set("updated_by", vins.UpdatedBy)
|
||||
d.Set("updated_time", vins.UpdatedTime)
|
||||
d.Set("user_managed", vins.UserManaged)
|
||||
d.Set("vnfs", flattenVNFS(vins.VNFs))
|
||||
d.Set("vxlan_id", vins.VXLANID)
|
||||
}
|
||||
|
||||
func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
for _, audit := range auidts {
|
||||
func flattenVinsAudits(audits vins.ListAudits) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0, len(audits))
|
||||
for _, audit := range audits {
|
||||
temp := map[string]interface{}{
|
||||
"call": audit.Call,
|
||||
"response_time": audit.ResponseTime,
|
||||
@@ -437,7 +446,7 @@ func flattenVinsAudits(auidts vins.ListAudits) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(extNetList.Data))
|
||||
for _, extNet := range extNetList.Data {
|
||||
temp := map[string]interface{}{
|
||||
"default_gw": extNet.DefaultGW,
|
||||
@@ -454,7 +463,7 @@ func flattenVinsExtNetList(extNetList *vins.ListExtNets) []map[string]interface{
|
||||
}
|
||||
|
||||
func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(ips.Data))
|
||||
for _, ip := range ips.Data {
|
||||
temp := map[string]interface{}{
|
||||
"client_type": ip.ClientType,
|
||||
@@ -472,7 +481,7 @@ func flattenVinsIpList(ips *vins.ListIPs) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(vl.Data))
|
||||
for _, v := range vl.Data {
|
||||
temp := map[string]interface{}{
|
||||
"account_id": v.AccountID,
|
||||
@@ -498,7 +507,7 @@ func flattenVinsList(vl *vins.ListVINS) []map[string]interface{} {
|
||||
}
|
||||
|
||||
func flattenVinsNatRuleList(natRules *vins.ListNATRules) []map[string]interface{} {
|
||||
res := make([]map[string]interface{}, 0)
|
||||
res := make([]map[string]interface{}, 0, len(natRules.Data))
|
||||
for _, natRule := range natRules.Data {
|
||||
temp := map[string]interface{}{
|
||||
"id": natRule.ID,
|
||||
|
||||
@@ -129,8 +129,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
req.PreReservationsNum = uint(d.Get("pre_reservations_num").(int))
|
||||
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInRG(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -141,7 +143,6 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
req := vins.CreateInAccountRequest{
|
||||
Name: d.Get("name").(string),
|
||||
AccountID: uint64(accountId.(int)),
|
||||
PreReservationsNum: uint64(d.Get("pre_reservations_num").(int)),
|
||||
}
|
||||
|
||||
if gid, ok := d.GetOk("gid"); ok {
|
||||
@@ -153,7 +154,10 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
if desc, ok := d.GetOk("desc"); ok {
|
||||
req.Description = desc.(string)
|
||||
}
|
||||
|
||||
if preReservationsNum, ok := d.GetOk("pre_reservations_num"); ok {
|
||||
req.PreReservationsNum = uint64(preReservationsNum.(int))
|
||||
}
|
||||
|
||||
id, err := c.CloudAPI().VINS().CreateInAccount(ctx, req)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -214,15 +218,15 @@ func resourceVinsCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
defer resourceVinsRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
|
||||
return append(warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
warnings := dc.Warnings{}
|
||||
|
||||
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -282,14 +286,14 @@ func resourceVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
flattenVins(d, *vinsData)
|
||||
flattenVins(d, vinsData)
|
||||
|
||||
return warnings.Get()
|
||||
}
|
||||
@@ -366,7 +370,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
vinsData, err := utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err := utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -425,7 +429,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
|
||||
if hasChangeState {
|
||||
vinsData, err = utilityVinsCheckPresence(ctx, d, m)
|
||||
vinsData, err = utilityDataVinsCheckPresence(ctx, d, m)
|
||||
if err != nil {
|
||||
d.SetId("")
|
||||
return diag.FromErr(err)
|
||||
@@ -631,8 +635,7 @@ func resourceVinsUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
defer resourceVinsRead(ctx, d, m)
|
||||
return warnings.Get()
|
||||
return append (warnings.Get(), resourceVinsRead(ctx, d, m)...)
|
||||
}
|
||||
|
||||
func resourceVinsDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
@@ -658,7 +661,7 @@ func extNetSchemaMake() map[string]*schema.Schema {
|
||||
return map[string]*schema.Schema{
|
||||
"ext_net_id": {
|
||||
Type: schema.TypeInt,
|
||||
Default: 0,
|
||||
Default: -1,
|
||||
Optional: true,
|
||||
},
|
||||
"ext_net_ip": {
|
||||
@@ -674,6 +677,7 @@ func ipSchemaMake() map[string]*schema.Schema {
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validation.StringInSlice([]string {"DHCP", "VIP", "EXCLUDE"}, false),
|
||||
},
|
||||
"ip_addr": {
|
||||
Type: schema.TypeString,
|
||||
@@ -823,7 +827,6 @@ func resourceVinsSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Default: false,
|
||||
}
|
||||
|
||||
rets["vins_id"] = &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Computed: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -44,8 +44,13 @@ import (
|
||||
|
||||
func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.RecordVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.GetRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.GetRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
vins, err := c.CloudAPI().VINS().Get(ctx, req)
|
||||
@@ -56,17 +61,3 @@ func utilityDataVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
return vins, nil
|
||||
}
|
||||
|
||||
func utilityVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.RecordVINS, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
vinsId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req := vins.GetRequest{
|
||||
VINSID: vinsId,
|
||||
}
|
||||
|
||||
vins, err := c.CloudAPI().VINS().Get(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vins, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (vins.ListAudits, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.AuditsRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.AuditsRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
audits, err := c.CloudAPI().VINS().Audits(ctx, req)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -46,6 +47,13 @@ func utilityVinsExtNetListCheckPresence(ctx context.Context, d *schema.ResourceD
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
extNetList, err := c.CloudAPI().VINS().ExtNetList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsIpListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListIPs, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.IPListRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.IPListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
ips, err := c.CloudAPI().VINS().IPList(ctx, req)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 Digital Energy Cloud Solutions LLC. All Rights Reserved.
|
||||
Authors:
|
||||
Petr Krutov, <petr.krutov@digitalenergy.online>
|
||||
Stanislav Solovev, <spsolovev@digitalenergy.online>
|
||||
@@ -34,6 +34,7 @@ package vins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
@@ -42,8 +43,13 @@ import (
|
||||
|
||||
func utilityVinsNatRuleListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*vins.ListNATRules, error) {
|
||||
c := m.(*controller.ControllerCfg)
|
||||
req := vins.NATRuleListRequest{
|
||||
VINSID: uint64(d.Get("vins_id").(int)),
|
||||
req := vins.NATRuleListRequest{}
|
||||
|
||||
if d.Id() != "" {
|
||||
rgId, _ := strconv.ParseUint(d.Id(), 10, 64)
|
||||
req.VINSID = rgId
|
||||
} else {
|
||||
req.VINSID = uint64(d.Get("vins_id").(int))
|
||||
}
|
||||
|
||||
natRuleList, err := c.CloudAPI().VINS().NATRuleList(ctx, req)
|
||||
|
||||
Reference in New Issue
Block a user