1.3.0
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/flattens"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vins/models"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vins/utilities"
|
||||
)
|
||||
@@ -37,23 +38,23 @@ func VINSResource(ctx context.Context, plan *models.ResourceVINSModel, c *client
|
||||
|
||||
*plan = models.ResourceVINSModel{
|
||||
Name: types.StringValue(recordVins.Name),
|
||||
RGID: plan.RGID,
|
||||
RGID: types.Int64Value(int64(recordVins.RGID)),
|
||||
AccountID: plan.AccountID,
|
||||
|
||||
IPCIDR: plan.IPCIDR,
|
||||
PreReservationsNum: plan.PreReservationsNum,
|
||||
Description: plan.Description,
|
||||
GID: plan.GID,
|
||||
DNS: plan.DNS,
|
||||
GID: types.Int64Value(int64(recordVins.GID)),
|
||||
DNS: flattens.FlattenSimpleTypeToSet(ctx, types.StringType, recordVins.VNFs.DHCP.Config.DNS),
|
||||
|
||||
Enable: plan.Enable,
|
||||
Enable: types.BoolValue(recordVins.Status == "ENABLED"),
|
||||
Permanently: plan.Permanently,
|
||||
Force: plan.Force,
|
||||
Restore: plan.Restore,
|
||||
VnfdevRestart: plan.VnfdevRestart,
|
||||
VnfdevRedeploy: plan.VnfdevRedeploy,
|
||||
|
||||
ExtNet: plan.ExtNet,
|
||||
ExtNet: flattenExtNet(ctx, recordVins),
|
||||
IP: plan.IP,
|
||||
NatRule: plan.NatRule,
|
||||
Timeouts: plan.Timeouts,
|
||||
@@ -160,3 +161,22 @@ func flattenNatRule(ctx context.Context, plan *models.ResourceVINSModel, rules *
|
||||
tflog.Info(ctx, "End flattenRuleIdInNatRule")
|
||||
return res
|
||||
}
|
||||
|
||||
// flattenExtNet flattens ExtNet.
|
||||
// Flatten errors are added to tflog.
|
||||
func flattenExtNet(ctx context.Context, vins *vins.RecordVINS) types.Object {
|
||||
tflog.Info(ctx, "Start flattenExtNet")
|
||||
|
||||
temp := models.ExtNetModel{
|
||||
ExtNetID: types.Int64Value(int64(vins.VNFs.GW.Config.ExtNetID)),
|
||||
ExtNetIP: types.StringValue(vins.VNFs.GW.Config.ExtNetIP),
|
||||
}
|
||||
|
||||
res, err := types.ObjectValueFrom(ctx, models.ItemExtNet, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenExtNet struct to obj", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenExtNet")
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ type DataSourceVINSListModel struct {
|
||||
Page types.Int64 `tfsdk:"page"`
|
||||
SortBy types.String `tfsdk:"sort_by"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
|
||||
// response fields
|
||||
|
||||
@@ -93,6 +93,11 @@ var ItemNatRuleResource = map[string]attr.Type{
|
||||
"rule_id": types.Int64Type,
|
||||
}
|
||||
|
||||
var ItemExtNet = map[string]attr.Type{
|
||||
"ext_net_id": types.Int64Type,
|
||||
"ext_net_ip": types.StringType,
|
||||
}
|
||||
|
||||
// Contains returns true if NatRuleResourceModel contains n as an element. Otherwise it returns false.
|
||||
func (n *NatRuleResourceModel) Contains(natRuleList []NatRuleResourceModel) bool {
|
||||
for _, natRuleElem := range natRuleList {
|
||||
|
||||
@@ -47,7 +47,10 @@ func MakeSchemaDataSourceVINSList() map[string]schema.Attribute {
|
||||
Optional: true,
|
||||
Description: "Page size",
|
||||
},
|
||||
|
||||
"status": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "Status",
|
||||
},
|
||||
// computed attributes
|
||||
"id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
|
||||
@@ -3,6 +3,7 @@ package schemas
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
@@ -59,23 +60,31 @@ func MakeSchemaResourceVINS() map[string]schema.Attribute {
|
||||
|
||||
"enable": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "flag to enable/disable vins",
|
||||
// default is true
|
||||
},
|
||||
"permanently": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "flag to delete vins permanently",
|
||||
// default is false
|
||||
// default is true
|
||||
},
|
||||
"force": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "flag to force delete of non-empty vins",
|
||||
// default is false
|
||||
// default is true
|
||||
},
|
||||
"restore": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "flag to restore vins",
|
||||
// default is false
|
||||
// default is true
|
||||
},
|
||||
"vnfdev_restart": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
|
||||
@@ -40,6 +40,9 @@ func VINSListDataSourceCheckPresence(ctx context.Context, plan *models.DataSourc
|
||||
if !plan.SortBy.IsNull() {
|
||||
listReq.SortBy = plan.SortBy.ValueString()
|
||||
}
|
||||
if !plan.Status.IsNull() {
|
||||
listReq.Status = plan.Status.ValueString()
|
||||
}
|
||||
if !plan.Page.IsNull() {
|
||||
listReq.Page = uint64(plan.Page.ValueInt64())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user