1.3.0
This commit is contained in:
@@ -6,12 +6,6 @@ const LimitMaxVinsPerResgroup = 4
|
||||
// MaxSshKeysPerCompute sets maximum number of user:ssh_key pairs to authorize when creating new compute
|
||||
const MaxSshKeysPerCompute = 12
|
||||
|
||||
// MaxExtraDisksPerCompute sets maximum number of extra disks that can be added when creating new compute
|
||||
const MaxExtraDisksPerCompute = 12
|
||||
|
||||
// MaxNetworksPerCompute sets maximum number of vNICs per compute
|
||||
const MaxNetworksPerCompute = 8
|
||||
|
||||
// MaxCpusPerCompute sets maximum number of vCPUs per compute
|
||||
const MaxCpusPerCompute = 128
|
||||
|
||||
|
||||
@@ -17,3 +17,12 @@ func FlattenSimpleTypeToList(ctx context.Context, elementType attr.Type, element
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// FlattenSimpleTypeToSet convert a slice of simple type to a types.Set
|
||||
func FlattenSimpleTypeToSet(ctx context.Context, elementType attr.Type, elements any) types.Set {
|
||||
res, diags := types.SetValueFrom(ctx, elementType, elements)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error FlattenSimpleTypeToSet", diags))
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (d *dataSourceAccountListDeleted) Schema(ctx context.Context, _ datasource.
|
||||
}
|
||||
|
||||
func (d *dataSourceAccountListDeleted) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
|
||||
resp.TypeName = req.ProviderTypeName + "_account_list_deleted"
|
||||
resp.TypeName = req.ProviderTypeName + "_account_deleted_list"
|
||||
}
|
||||
|
||||
// Configure adds the provider configured client to the data source.
|
||||
@@ -51,6 +51,7 @@ func AccountDataSource(ctx context.Context, state *models.DataSourceAccountModel
|
||||
DeactivationTime: types.Float64Value(recordAccount.DeactivationTime),
|
||||
DeletedBy: types.StringValue(recordAccount.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordAccount.DeletedTime)),
|
||||
Desc: types.StringValue(recordAccount.Description),
|
||||
DisplayName: types.StringValue(recordAccount.DisplayName),
|
||||
GUID: types.Int64Value(int64(recordAccount.GUID)),
|
||||
Machines: flattenMachines(ctx, recordAccount.Machines),
|
||||
|
||||
@@ -52,6 +52,7 @@ func AccountListDataSource(ctx context.Context, state *models.DataSourceAccountL
|
||||
AccountName: types.StringValue(item.Name),
|
||||
Status: types.StringValue(item.Status),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
Desc: types.StringValue(item.Description),
|
||||
}
|
||||
i.ComputeFeatures, diags = types.ListValueFrom(ctx, types.StringType, item.ComputeFeatures)
|
||||
if diags.HasError() {
|
||||
|
||||
@@ -48,6 +48,7 @@ func AccountListDeletedDataSource(ctx context.Context, state *models.DataSourceA
|
||||
i := models.ItemAccountListDeletedModel{
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Desc: types.StringValue(item.Description),
|
||||
AccountID: types.Int64Value(int64(item.ID)),
|
||||
AccountName: types.StringValue(item.Name),
|
||||
Status: types.StringValue(item.Status),
|
||||
|
||||
@@ -90,6 +90,7 @@ func AccountRGListDataSource(ctx context.Context, state *models.DataSourceAccoun
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Desc: types.StringValue(item.Description),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/flattens"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
@@ -47,13 +48,13 @@ func AccountResource(ctx context.Context, state *models.ResourceAccountModel, c
|
||||
*state = models.ResourceAccountModel{
|
||||
// request fields
|
||||
AccountName: types.StringValue(recordAccount.Name),
|
||||
Username: state.Username,
|
||||
EmailAddress: state.EmailAddress,
|
||||
SendAccessEmails: state.SendAccessEmails,
|
||||
Users: state.Users,
|
||||
SendAccessEmails: types.BoolValue(recordAccount.SendAccessEmails),
|
||||
Users: flattenUsers(ctx, recordAccount.ACL),
|
||||
Restore: state.Restore,
|
||||
Permanently: state.Permanently,
|
||||
Desc: types.StringValue(recordAccount.Description),
|
||||
Enable: state.Enable,
|
||||
Reason: state.Reason,
|
||||
ResourceLimits: flattenResourceLimitsInAccountResource(ctx, recordAccount.ResourceLimits, state),
|
||||
Timeouts: state.Timeouts,
|
||||
|
||||
@@ -67,6 +68,7 @@ func AccountResource(ctx context.Context, state *models.ResourceAccountModel, c
|
||||
Company: types.StringValue(recordAccount.Company),
|
||||
CompanyURL: types.StringValue(recordAccount.CompanyURL),
|
||||
Computes: flattenComputes(ctx, recordAccount.Computes),
|
||||
ComputeFeatures: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordAccount.ComputeFeatures),
|
||||
CPUAllocationParameter: types.StringValue(recordAccount.CPUAllocationParameter),
|
||||
CPUAllocationRatio: types.Float64Value(recordAccount.CPUAllocationRatio),
|
||||
CreatedBy: types.StringValue(recordAccount.CreatedBy),
|
||||
@@ -74,23 +76,22 @@ func AccountResource(ctx context.Context, state *models.ResourceAccountModel, c
|
||||
DeactivationTime: types.Float64Value(recordAccount.DeactivationTime),
|
||||
DeletedBy: types.StringValue(recordAccount.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordAccount.DeletedTime)),
|
||||
DisplayName: types.StringValue(recordAccount.DisplayName),
|
||||
GUID: types.Int64Value(int64(recordAccount.GUID)),
|
||||
Machines: flattenMachines(ctx, recordAccount.Machines),
|
||||
Status: types.StringValue(recordAccount.Status),
|
||||
UpdatedTime: types.Int64Value(int64(recordAccount.UpdatedTime)),
|
||||
Version: types.Int64Value(int64(recordAccount.Version)),
|
||||
VINSes: types.Int64Value(int64(recordAccount.VINSes)),
|
||||
//Description: types.StringValue(recordAccount.Description),
|
||||
DisplayName: types.StringValue(recordAccount.DisplayName),
|
||||
GUID: types.Int64Value(int64(recordAccount.GUID)),
|
||||
Machines: flattenMachines(ctx, recordAccount.Machines),
|
||||
Status: types.StringValue(recordAccount.Status),
|
||||
UpdatedTime: types.Int64Value(int64(recordAccount.UpdatedTime)),
|
||||
Version: types.Int64Value(int64(recordAccount.Version)),
|
||||
VINS: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordAccount.VINS),
|
||||
VINSes: types.Int64Value(int64(recordAccount.VINSes)),
|
||||
}
|
||||
|
||||
state.VINS, diags = types.ListValueFrom(ctx, types.Int64Type, recordAccount.VINS)
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.AccountResource: cannot flatten recordAccount.VINS to state.VINS", diags))
|
||||
}
|
||||
|
||||
state.ComputeFeatures, diags = types.ListValueFrom(ctx, types.StringType, recordAccount.ComputeFeatures)
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.AccountResource: cannot flatten recordAccount.ComputeFeatures to state.ComputeFeatures", diags))
|
||||
if state.Enable == types.BoolNull() {
|
||||
state.Enable = types.BoolValue(false)
|
||||
if recordAccount.Status == "CONFIRMED" {
|
||||
state.Enable = types.BoolValue(true)
|
||||
}
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "flattens.AccountResource: after flatten", map[string]any{"account_id": state.Id.ValueString()})
|
||||
@@ -137,3 +138,30 @@ func flattenResourceLimitsInAccountResource(ctx context.Context, limits account.
|
||||
tflog.Info(ctx, "End flattenResourceLimitsInAccountResource")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenUsers(ctx context.Context, aclList []account.RecordACL) types.Set {
|
||||
tflog.Info(ctx, "Start flattenUsers")
|
||||
tempSlice := make([]types.Object, 0, len(aclList))
|
||||
for i, item := range aclList {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
temp := models.UsersModel{
|
||||
UserID: types.StringValue(item.UgroupID),
|
||||
AccessType: types.StringValue(item.Rights),
|
||||
}
|
||||
obj, diags := types.ObjectValueFrom(ctx, models.ItemUsersResource, temp)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenUsers struct to obj", diags))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, diags := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemUsersResource}, tempSlice)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenUsers", diags))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenUsers")
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type DataSourceAccountModel struct {
|
||||
DeactivationTime types.Float64 `tfsdk:"deactivation_time"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
DisplayName types.String `tfsdk:"displayname"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
Machines types.Object `tfsdk:"machines"`
|
||||
|
||||
@@ -31,6 +31,7 @@ type ItemAccountListModel struct {
|
||||
Status types.String `tfsdk:"status"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
ComputeFeatures types.List `tfsdk:"compute_features"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
}
|
||||
|
||||
type RecordACLModel struct {
|
||||
|
||||
@@ -25,6 +25,7 @@ type ItemAccountListDeletedModel struct {
|
||||
ACL []RecordACLModel `tfsdk:"acl"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
|
||||
@@ -31,6 +31,7 @@ type ItemAccountRGModel struct {
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
RGName types.String `tfsdk:"rg_name"`
|
||||
|
||||
@@ -9,17 +9,16 @@ import (
|
||||
type ResourceAccountModel struct {
|
||||
// request fields - required
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
|
||||
// request fields - optional
|
||||
EmailAddress types.String `tfsdk:"emailaddress"`
|
||||
SendAccessEmails types.Bool `tfsdk:"send_access_emails"`
|
||||
Users types.List `tfsdk:"users"`
|
||||
Users types.Set `tfsdk:"users"`
|
||||
Restore types.Bool `tfsdk:"restore"`
|
||||
Permanently types.Bool `tfsdk:"permanently"`
|
||||
Enable types.Bool `tfsdk:"enable"`
|
||||
ResourceLimits types.Object `tfsdk:"resource_limits"`
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
|
||||
// response fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
@@ -42,6 +41,7 @@ type ResourceAccountModel struct {
|
||||
DisplayName types.String `tfsdk:"displayname"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
Machines types.Object `tfsdk:"machines"`
|
||||
Reason types.String `tfsdk:"reason"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
Version types.Int64 `tfsdk:"version"`
|
||||
@@ -54,6 +54,11 @@ type UsersModel struct {
|
||||
AccessType types.String `tfsdk:"access_type"`
|
||||
}
|
||||
|
||||
var ItemUsersResource = map[string]attr.Type{
|
||||
"user_id": types.StringType,
|
||||
"access_type": types.StringType,
|
||||
}
|
||||
|
||||
type ResourceLimitsInAccountResourceModel struct {
|
||||
CUC types.Float64 `tfsdk:"cu_c"`
|
||||
CUD types.Float64 `tfsdk:"cu_d"`
|
||||
|
||||
@@ -137,7 +137,7 @@ func (r *resourceAccount) Update(ctx context.Context, req resource.UpdateRequest
|
||||
|
||||
// enable/disable account
|
||||
if !plan.Enable.Equal(state.Enable) && !plan.Enable.IsNull() {
|
||||
resp.Diagnostics.Append(utilities.EnableDisableAccount(ctx, uint64(accountId), plan.Enable.ValueBool(), r.client)...)
|
||||
resp.Diagnostics.Append(utilities.EnableDisableAccount(ctx, uint64(accountId), &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceAccount: Error enabling/disabling account")
|
||||
return
|
||||
@@ -204,9 +204,6 @@ func (r *resourceAccount) Delete(ctx context.Context, req resource.DeleteRequest
|
||||
defer cancel()
|
||||
|
||||
permanently := state.Permanently.ValueBool()
|
||||
if state.Permanently.IsNull() {
|
||||
permanently = true
|
||||
} // default true
|
||||
|
||||
// Delete existing resource group
|
||||
delReq := account.DeleteRequest{
|
||||
|
||||
@@ -73,6 +73,9 @@ func MakeSchemaDataSourceAccount() map[string]schema.Attribute {
|
||||
"deleted_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -83,6 +83,9 @@ func MakeSchemaDataSourceAccountList() map[string]schema.Attribute {
|
||||
"account_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"account_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -72,6 +72,9 @@ func MakeSchemaDataSourceAccountListDeleted() map[string]schema.Attribute {
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -201,6 +201,9 @@ func MakeSchemaDataSourceAccountRGList() map[string]schema.Attribute {
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ package schemas
|
||||
|
||||
import (
|
||||
"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/types"
|
||||
@@ -14,21 +15,19 @@ func MakeSchemaResourceAccount() map[string]schema.Attribute {
|
||||
Required: true,
|
||||
Description: "name of the account",
|
||||
},
|
||||
"username": schema.StringAttribute{
|
||||
Required: true,
|
||||
Description: "username of owner the account",
|
||||
},
|
||||
|
||||
// optional attributes
|
||||
"emailaddress": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "email",
|
||||
},
|
||||
"send_access_emails": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
Description: "if true send emails when a user is granted access to resources",
|
||||
},
|
||||
"users": schema.ListNestedAttribute{
|
||||
"desc": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "description of the account",
|
||||
},
|
||||
"users": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
@@ -43,16 +42,25 @@ func MakeSchemaResourceAccount() map[string]schema.Attribute {
|
||||
},
|
||||
"restore": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "restore a deleted account",
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"permanently": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "whether to completely delete the account",
|
||||
// default is false
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"enable": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "enable/disable account",
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"reason": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "reason to disable",
|
||||
},
|
||||
"resource_limits": schema.SingleNestedAttribute{
|
||||
Optional: true,
|
||||
|
||||
@@ -120,10 +120,11 @@ func RestoreAccount(ctx context.Context, accountId uint64, c *client.Client) dia
|
||||
|
||||
// EnableDisableAccount performs account Enable/Disable request.
|
||||
// Returns error in case of failures.
|
||||
func EnableDisableAccount(ctx context.Context, accountId uint64, enable bool, c *client.Client) diag.Diagnostics {
|
||||
func EnableDisableAccount(ctx context.Context, accountId uint64, plan *models.ResourceAccountModel, c *client.Client) diag.Diagnostics {
|
||||
tflog.Info(ctx, "Start EnableDisableAccount", map[string]any{"account_id": accountId})
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
enable := plan.Enable.ValueBool()
|
||||
|
||||
if enable {
|
||||
tflog.Info(ctx, "EnableDisableAccount: before calling CloudAPI().Account().Enable", map[string]any{"account_id": accountId})
|
||||
@@ -141,7 +142,8 @@ func EnableDisableAccount(ctx context.Context, accountId uint64, enable bool, c
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "EnableDisableAccount: before calling CloudAPI().Account().Disable", map[string]any{"account_id": accountId})
|
||||
res, err := c.CloudAPI().Account().Disable(ctx, account.DisableEnableRequest{AccountID: accountId})
|
||||
reason := plan.Reason.ValueString()
|
||||
res, err := c.CloudAPI().Account().Disable(ctx, account.DisableEnableRequest{AccountID: accountId, Reason: reason})
|
||||
if err != nil {
|
||||
diags.AddError(
|
||||
"EnableDisableAccount: cannot disable account",
|
||||
@@ -172,6 +174,12 @@ func UpdateAccount(ctx context.Context, accountId uint64, plan, state *models.Re
|
||||
updateNeeded = true
|
||||
}
|
||||
|
||||
// check if description was changed
|
||||
if !plan.Desc.Equal(state.Desc) {
|
||||
updateReq.Description = plan.Desc.ValueString()
|
||||
updateNeeded = true
|
||||
}
|
||||
|
||||
// check if resource_limits were changed
|
||||
if !plan.ResourceLimits.Equal(state.ResourceLimits) && !plan.ResourceLimits.IsUnknown() {
|
||||
tflog.Info(ctx, "UpdateAccount: new ResourceLimits specified", map[string]any{"account_id": accountId})
|
||||
|
||||
@@ -83,6 +83,7 @@ func BServiceGroupDataSource(ctx context.Context, state *models.RecordGroupModel
|
||||
ID: types.Int64Value(int64(v.ID)),
|
||||
IPAddresses: flattens.FlattenSimpleTypeToList(ctx, types.StringType, ipAddresses),
|
||||
Name: types.StringValue(v.Name),
|
||||
Chipset: types.StringValue(v.Chipset),
|
||||
OSUsers: osUsers,
|
||||
}
|
||||
computesList = append(computesList, temp)
|
||||
|
||||
@@ -57,6 +57,7 @@ func BServiceGroupResource(ctx context.Context, plan *models.ResourceRecordGroup
|
||||
RAM: types.Int64Value(int64(recordResourceGroup.RAM)),
|
||||
Disk: types.Int64Value(int64(recordResourceGroup.Disk)),
|
||||
ImageID: types.Int64Value(int64(recordResourceGroup.ImageID)),
|
||||
Chipset: plan.Chipset,
|
||||
Driver: types.StringValue(recordResourceGroup.Driver),
|
||||
SEPID: types.Int64Value(int64(recordResourceGroup.SEPID)),
|
||||
SepPool: types.StringValue(recordResourceGroup.PoolName),
|
||||
@@ -112,6 +113,7 @@ func flattenGroupComputes(ctx context.Context, items bservice.ListGroupComputes)
|
||||
ID: types.Int64Value(int64(v.ID)),
|
||||
Name: types.StringValue(v.Name),
|
||||
IPAddresses: flattens.FlattenSimpleTypeToList(ctx, types.StringType, v.IPAddresses),
|
||||
Chipset: types.StringValue(v.Chipset),
|
||||
OSUsers: flattenOSuser(ctx, v.OSUsers),
|
||||
}
|
||||
obj, diags := types.ObjectValueFrom(ctx, models.ResourceItemGroupCompute, temp)
|
||||
|
||||
@@ -48,6 +48,7 @@ type ItemGroupComputeModel struct {
|
||||
ID types.Int64 `tfsdk:"id"`
|
||||
IPAddresses types.List `tfsdk:"ip_addresses"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
OSUsers []ItemOSUserModel `tfsdk:"os_users"`
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ type ResourceRecordGroupModel struct {
|
||||
SepPool types.String `tfsdk:"sep_pool"`
|
||||
CloudInit types.String `tfsdk:"cloud_init"`
|
||||
Role types.String `tfsdk:"role"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
TimeoutStart types.Int64 `tfsdk:"timeout_start"`
|
||||
VINSes types.List `tfsdk:"vinses"`
|
||||
ExtNets types.List `tfsdk:"extnets"`
|
||||
@@ -61,6 +62,7 @@ type ResourceItemGroupComputeModel struct {
|
||||
ID types.Int64 `tfsdk:"id"`
|
||||
IPAddresses types.List `tfsdk:"ip_addresses"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
OSUsers types.List `tfsdk:"os_users"`
|
||||
}
|
||||
|
||||
@@ -68,6 +70,7 @@ var ResourceItemGroupCompute = map[string]attr.Type{
|
||||
"id": types.Int64Type,
|
||||
"ip_addresses": types.ListType{ElemType: types.StringType},
|
||||
"name": types.StringType,
|
||||
"chipset": types.StringType,
|
||||
"os_users": types.ListType{ElemType: types.ObjectType{AttrTypes: ResourceItemOSUser}},
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ func MakeSchemaDataSourceBServiceGroup() map[string]schema.Attribute {
|
||||
"name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"chipset": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"os_users": schema.ListNestedAttribute{
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
|
||||
@@ -2,6 +2,7 @@ package schemas
|
||||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
@@ -24,15 +25,23 @@ func MakeSchemaResourceBService() map[string]schema.Attribute {
|
||||
},
|
||||
"permanently": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"enable": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"restore": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"start": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"service_id": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
|
||||
"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"
|
||||
@@ -42,6 +43,13 @@ func MakeSchemaResourceBServiceGroup() map[string]schema.Attribute {
|
||||
"driver": schema.StringAttribute{
|
||||
Required: true,
|
||||
},
|
||||
"chipset": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOf("i440fx", "Q35"),
|
||||
},
|
||||
Description: "Type of the emulated system, Q35 or i440fx",
|
||||
},
|
||||
"sep_id": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
@@ -79,12 +87,18 @@ func MakeSchemaResourceBServiceGroup() map[string]schema.Attribute {
|
||||
},
|
||||
"start": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"force_stop": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"force_update": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"parents": schema.ListAttribute{
|
||||
Optional: true,
|
||||
@@ -119,6 +133,10 @@ func MakeSchemaResourceBServiceGroup() map[string]schema.Attribute {
|
||||
"name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"chipset": schema.StringAttribute{
|
||||
Computed: true,
|
||||
Description: "Type of the emulated system, Q35 or i440fx",
|
||||
},
|
||||
"os_users": schema.ListNestedAttribute{
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
|
||||
@@ -48,6 +48,12 @@ func BServiceGroupResourceCreate(ctx context.Context, plan *models.ResourceRecor
|
||||
req.SEPID = uint64(plan.SEPID.ValueInt64())
|
||||
}
|
||||
|
||||
if plan.Chipset.IsNull() {
|
||||
req.Chipset = "i440fx"
|
||||
} else {
|
||||
req.Chipset = plan.Chipset.ValueString()
|
||||
}
|
||||
|
||||
if !plan.SepPool.IsNull() {
|
||||
req.SEPPool = plan.SepPool.ValueString()
|
||||
}
|
||||
@@ -131,6 +137,12 @@ func BServiceGroupResize(ctx context.Context, plan *models.ResourceRecordGroupMo
|
||||
Mode: plan.Mode.ValueString(),
|
||||
}
|
||||
|
||||
if plan.Chipset.IsNull() {
|
||||
req.Chipset = "i440fx"
|
||||
} else {
|
||||
req.Chipset = plan.Chipset.ValueString()
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "BServiceGroupResize: before calling CloudAPI().BService().GroupResize", map[string]any{"req": req})
|
||||
_, err = c.CloudAPI().BService().GroupResize(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -39,18 +39,23 @@ func DiskDataSource(ctx context.Context, state *models.DataSourceDiskModel, c *c
|
||||
Timeouts: state.Timeouts,
|
||||
|
||||
// computed fields
|
||||
Id: types.StringValue(id.String()),
|
||||
ID: types.StringValue(id.String()),
|
||||
AccountID: types.Int64Value(int64(recordDisk.AccountID)),
|
||||
AccountName: types.StringValue(recordDisk.AccountName),
|
||||
ACL: types.StringValue(string(diskAcl)),
|
||||
Computes: flattenComputes(ctx, recordDisk.Computes),
|
||||
CreatedBy: types.StringValue(recordDisk.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(recordDisk.CreatedTime)),
|
||||
DeletedBy: types.StringValue(recordDisk.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordDisk.DeletedTime)),
|
||||
Description: types.StringValue(recordDisk.Description),
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
DeviceName: types.StringValue(recordDisk.DeviceName),
|
||||
GID: types.Int64Value(int64(recordDisk.GID)),
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
MachineID: types.Int64Value(int64(recordDisk.MachineID)),
|
||||
MachineName: types.StringValue(recordDisk.MachineName),
|
||||
Milestones: types.Int64Value(int64(recordDisk.Milestones)),
|
||||
Name: types.StringValue(recordDisk.Name),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
@@ -64,20 +69,23 @@ func DiskDataSource(ctx context.Context, state *models.DataSourceDiskModel, c *c
|
||||
SepID: types.Int64Value(int64(recordDisk.SepID)),
|
||||
SepType: types.StringValue(recordDisk.SepType),
|
||||
Shareable: types.BoolValue(recordDisk.Shareable),
|
||||
SizeAvailable: types.Float64Value(recordDisk.SizeAvailable),
|
||||
SizeMax: types.Int64Value(int64(recordDisk.SizeMax)),
|
||||
SizeUsed: types.Float64Value(recordDisk.SizeUsed),
|
||||
Snapshots: flattenSnapshots(ctx, recordDisk.Snapshots),
|
||||
Status: types.StringValue(recordDisk.Status),
|
||||
TechStatus: types.StringValue(recordDisk.TechStatus),
|
||||
Type: types.StringValue(recordDisk.Type),
|
||||
UpdatedBy: types.StringValue(recordDisk.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(recordDisk.UpdatedTime)),
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
state.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
|
||||
state.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskDataSource: cannot flatten recordDisk.Images to state.Images", diags))
|
||||
}
|
||||
state.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
state.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskDataSource: cannot flatten recordDisk.PresentTo to state.PresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func DiskListDataSource(ctx context.Context, state *models.DataSourceDiskListMod
|
||||
Timeouts: state.Timeouts,
|
||||
|
||||
// computed fields
|
||||
Id: types.StringValue(id.String()),
|
||||
ID: types.StringValue(id.String()),
|
||||
EntryCount: types.Int64Value(int64(diskList.EntryCount)),
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ func DiskListDataSource(ctx context.Context, state *models.DataSourceDiskListMod
|
||||
AccountName: types.StringValue(recordDisk.AccountName),
|
||||
ACL: types.StringValue(string(diskAcl)),
|
||||
Computes: flattenComputes(ctx, recordDisk.Computes),
|
||||
CreatedBy: types.StringValue(recordDisk.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(recordDisk.CreatedTime)),
|
||||
DeletedBy: types.StringValue(recordDisk.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordDisk.DeletedTime)),
|
||||
Description: types.StringValue(recordDisk.Description),
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
@@ -68,6 +70,9 @@ func DiskListDataSource(ctx context.Context, state *models.DataSourceDiskListMod
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
DiskId: types.Int64Value(int64(recordDisk.ID)),
|
||||
DiskName: types.StringValue(recordDisk.Name),
|
||||
MachineID: types.Int64Value(int64(recordDisk.MachineID)),
|
||||
MachineName: types.StringValue(recordDisk.MachineName),
|
||||
Milestones: types.Int64Value(int64(recordDisk.Milestones)),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
|
||||
@@ -80,20 +85,23 @@ func DiskListDataSource(ctx context.Context, state *models.DataSourceDiskListMod
|
||||
SepID: types.Int64Value(int64(recordDisk.SepID)),
|
||||
SepType: types.StringValue(recordDisk.SepType),
|
||||
Shareable: types.BoolValue(recordDisk.Shareable),
|
||||
SizeAvailable: types.Float64Value(recordDisk.SizeAvailable),
|
||||
SizeMax: types.Int64Value(int64(recordDisk.SizeMax)),
|
||||
SizeUsed: types.Float64Value(recordDisk.SizeUsed),
|
||||
Snapshots: flattenSnapshots(ctx, recordDisk.Snapshots),
|
||||
Status: types.StringValue(recordDisk.Status),
|
||||
TechStatus: types.StringValue(recordDisk.TechStatus),
|
||||
Type: types.StringValue(recordDisk.Type),
|
||||
UpdatedBy: types.StringValue(recordDisk.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(recordDisk.UpdatedTime)),
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskListDataSource: cannot flatten recordDisk.Images to d.Images", diags))
|
||||
}
|
||||
d.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
d.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskListDataSource: cannot flatten recordDisk.PresentTo to d.PresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func DiskListDeletedDataSource(ctx context.Context, state *models.DataSourceDisk
|
||||
Timeouts: state.Timeouts,
|
||||
|
||||
// computed fields
|
||||
Id: types.StringValue(id.String()),
|
||||
ID: types.StringValue(id.String()),
|
||||
EntryCount: types.Int64Value(int64(diskList.EntryCount)),
|
||||
}
|
||||
|
||||
@@ -56,7 +56,9 @@ func DiskListDeletedDataSource(ctx context.Context, state *models.DataSourceDisk
|
||||
AccountName: types.StringValue(recordDisk.AccountName),
|
||||
ACL: types.StringValue(string(diskAcl)),
|
||||
Computes: flattenComputes(ctx, recordDisk.Computes),
|
||||
CreatedBy: types.StringValue(recordDisk.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(recordDisk.CreatedTime)),
|
||||
DeletedBy: types.StringValue(recordDisk.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordDisk.DeletedTime)),
|
||||
Description: types.StringValue(recordDisk.Description),
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
@@ -65,6 +67,7 @@ func DiskListDeletedDataSource(ctx context.Context, state *models.DataSourceDisk
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
DiskId: types.Int64Value(int64(recordDisk.ID)),
|
||||
DiskName: types.StringValue(recordDisk.Name),
|
||||
Milestones: types.Int64Value(int64(recordDisk.Milestones)),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
|
||||
@@ -77,20 +80,23 @@ func DiskListDeletedDataSource(ctx context.Context, state *models.DataSourceDisk
|
||||
SepID: types.Int64Value(int64(recordDisk.SepID)),
|
||||
SepType: types.StringValue(recordDisk.SepType),
|
||||
Shareable: types.BoolValue(recordDisk.Shareable),
|
||||
SizeAvailable: types.Float64Value(recordDisk.SizeAvailable),
|
||||
SizeMax: types.Int64Value(int64(recordDisk.SizeMax)),
|
||||
SizeUsed: types.Float64Value(recordDisk.SizeUsed),
|
||||
Snapshots: flattenSnapshots(ctx, recordDisk.Snapshots),
|
||||
Status: types.StringValue(recordDisk.Status),
|
||||
TechStatus: types.StringValue(recordDisk.TechStatus),
|
||||
Type: types.StringValue(recordDisk.Type),
|
||||
UpdatedBy: types.StringValue(recordDisk.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(recordDisk.UpdatedTime)),
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskListDeletedDataSource: cannot flatten recordDisk.Images to d.Images", diags))
|
||||
}
|
||||
d.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
d.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskListDeletedDataSource: cannot flatten recordDisk.PresentTo to d.PresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func DiskListUnattachedDataSource(ctx context.Context, state *models.DataSourceD
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
|
||||
d.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskListUnattachedDataSource: cannot flatten recordDisk.Images to d.Images", diags))
|
||||
}
|
||||
|
||||
@@ -47,14 +47,13 @@ func DiskReplicationDataSource(ctx context.Context, state *models.RecordDiskMode
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
GID: types.Int64Value(int64(recordDisk.GID)),
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordDisk.Images),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordDisk.Images),
|
||||
Name: types.StringValue(recordDisk.Name),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
|
||||
PCISlot: types.Int64Value(int64(recordDisk.PCISlot)),
|
||||
Pool: types.StringValue(recordDisk.Pool),
|
||||
PresentTo: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordDisk.PresentTo),
|
||||
PurgeTime: types.Int64Value(int64(recordDisk.PurgeTime)),
|
||||
Replication: &models.ItemReplicationModel{},
|
||||
ResID: types.StringValue(recordDisk.ResID),
|
||||
@@ -73,6 +72,11 @@ func DiskReplicationDataSource(ctx context.Context, state *models.RecordDiskMode
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
state.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskDataSource: cannot flatten recordDisk.PresentTo to state.PresentTo", diags))
|
||||
}
|
||||
|
||||
iotune := models.DiskReplicationIOTune{
|
||||
ReadBytesSec: types.Int64Value(int64(recordDisk.IOTune.ReadBytesSec)),
|
||||
ReadBytesSecMax: types.Int64Value(int64(recordDisk.IOTune.ReadBytesSecMax)),
|
||||
|
||||
@@ -23,7 +23,7 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
diskId, err := strconv.ParseUint(plan.Id.ValueString(), 10, 64)
|
||||
diskId, err := strconv.ParseUint(plan.ID.ValueString(), 10, 64)
|
||||
if err != nil {
|
||||
diags.AddError("flattens.DiskResource: Cannot parse disk ID from state", err.Error())
|
||||
return diags
|
||||
@@ -43,13 +43,11 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
|
||||
AccountID: types.Int64Value(int64(recordDisk.AccountID)),
|
||||
DiskName: types.StringValue(recordDisk.Name),
|
||||
SizeMax: types.Int64Value(int64(recordDisk.SizeMax)),
|
||||
GID: types.Int64Value(int64(recordDisk.GID)),
|
||||
|
||||
// optional fields
|
||||
Description: plan.Description,
|
||||
Pool: plan.Pool,
|
||||
SEPID: plan.SEPID,
|
||||
Type: plan.Type,
|
||||
Description: types.StringValue(recordDisk.Description),
|
||||
Pool: types.StringValue(recordDisk.Pool),
|
||||
SEPID: types.Int64Value(int64(recordDisk.SepID)),
|
||||
Detach: plan.Detach,
|
||||
Permanently: plan.Permanently,
|
||||
Shareable: plan.Shareable,
|
||||
@@ -57,16 +55,21 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
|
||||
|
||||
// computed fields
|
||||
LastUpdated: plan.LastUpdated,
|
||||
Id: types.StringValue(strconv.Itoa(int(recordDisk.ID))),
|
||||
DiskId: types.Int64Value(int64(recordDisk.ID)),
|
||||
ID: types.StringValue(strconv.Itoa(int(recordDisk.ID))),
|
||||
DiskID: types.Int64Value(int64(recordDisk.ID)),
|
||||
AccountName: types.StringValue(recordDisk.AccountName),
|
||||
ACL: types.StringValue(string(diskAcl)),
|
||||
Computes: flattenComputes(ctx, recordDisk.Computes),
|
||||
CreatedBy: types.StringValue(recordDisk.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(recordDisk.CreatedTime)),
|
||||
DeletedBy: types.StringValue(recordDisk.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(recordDisk.DeletedTime)),
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
DeviceName: types.StringValue(recordDisk.DeviceName),
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
MachineID: types.Int64Value(int64(recordDisk.MachineID)),
|
||||
MachineName: types.StringValue(recordDisk.MachineName),
|
||||
GID: types.Int64Value(int64(recordDisk.GID)),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
|
||||
@@ -80,14 +83,17 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
|
||||
Snapshots: flattenSnapshots(ctx, recordDisk.Snapshots),
|
||||
Status: types.StringValue(recordDisk.Status),
|
||||
TechStatus: types.StringValue(recordDisk.TechStatus),
|
||||
Type: types.StringValue(recordDisk.Type),
|
||||
UpdatedBy: types.StringValue(recordDisk.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(recordDisk.UpdatedTime)),
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
plan.Images, diags = types.ListValueFrom(ctx, types.StringType, recordDisk.Images)
|
||||
plan.Images, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskResource: cannot flatten recordDisk.Images to plan.Images", diags))
|
||||
}
|
||||
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskResource: cannot flatten recordDisk.PresentTo to plan.PresentTo", diags))
|
||||
}
|
||||
@@ -129,7 +135,7 @@ func DiskResource(ctx context.Context, plan *models.ResourceDiskModel, c *client
|
||||
}
|
||||
plan.IOTune = obj
|
||||
|
||||
tflog.Info(ctx, "flattens.DiskResource: after flatten", map[string]any{"disk_id": plan.Id.ValueString()})
|
||||
tflog.Info(ctx, "flattens.DiskResource: after flatten", map[string]any{"disk_id": plan.ID.ValueString()})
|
||||
|
||||
tflog.Info(ctx, "End flattens.DiskResource")
|
||||
return nil
|
||||
|
||||
@@ -57,13 +57,12 @@ func DiskReplicationResource(ctx context.Context, state *models.ResourceRecordDi
|
||||
DestructionTime: types.Int64Value(int64(recordDisk.DestructionTime)),
|
||||
GID: types.Int64Value(int64(recordDisk.GID)),
|
||||
ImageID: types.Int64Value(int64(recordDisk.ImageID)),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordDisk.Images),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordDisk.Images),
|
||||
Order: types.Int64Value(int64(recordDisk.Order)),
|
||||
Params: types.StringValue(recordDisk.Params),
|
||||
ParentID: types.Int64Value(int64(recordDisk.ParentID)),
|
||||
PCISlot: types.Int64Value(int64(recordDisk.PCISlot)),
|
||||
Pool: types.StringValue(recordDisk.Pool),
|
||||
PresentTo: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordDisk.PresentTo),
|
||||
PurgeTime: types.Int64Value(int64(recordDisk.PurgeTime)),
|
||||
ResID: types.StringValue(recordDisk.ResID),
|
||||
ResName: types.StringValue(recordDisk.ResName),
|
||||
@@ -80,6 +79,11 @@ func DiskReplicationResource(ctx context.Context, state *models.ResourceRecordDi
|
||||
VMID: types.Int64Value(int64(recordDisk.VMID)),
|
||||
}
|
||||
|
||||
state.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, recordDisk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("flattens.DiskDataSource: cannot flatten recordDisk.PresentTo to state.PresentTo", diags))
|
||||
}
|
||||
|
||||
iotune := models.ResourceDiskReplicationIOTuneModel{
|
||||
ReadBytesSec: types.Int64Value(int64(recordDisk.IOTune.ReadBytesSec)),
|
||||
ReadBytesSecMax: types.Int64Value(int64(recordDisk.IOTune.ReadBytesSecMax)),
|
||||
|
||||
@@ -22,12 +22,6 @@ func resourceDiskCreateInputChecks(ctx context.Context, plan *models.ResourceDis
|
||||
diags.AddError(fmt.Sprintf("Cannot get info about account with ID %v", accountId), err.Error())
|
||||
}
|
||||
|
||||
gid := uint64(plan.GID.ValueInt64())
|
||||
tflog.Info(ctx, "resourceDiskCreateInputChecks: exist gid check", map[string]any{"gid": gid})
|
||||
err = ic.ExistGID(ctx, gid, c)
|
||||
if err != nil {
|
||||
diags.AddError(fmt.Sprintf("Cannot get info about GID %v", gid), err.Error())
|
||||
}
|
||||
return diags
|
||||
}
|
||||
|
||||
@@ -62,7 +56,7 @@ func resourceDiskUpdateInputChecks(ctx context.Context, plan, state *models.Reso
|
||||
fmt.Sprintf("cannot change description from %s to %s for disk id %s",
|
||||
state.Description.ValueString(),
|
||||
plan.Description.ValueString(),
|
||||
plan.Id.ValueString()))
|
||||
plan.ID.ValueString()))
|
||||
}
|
||||
|
||||
// check pool
|
||||
@@ -72,7 +66,7 @@ func resourceDiskUpdateInputChecks(ctx context.Context, plan, state *models.Reso
|
||||
fmt.Sprintf("cannot change pool from %s to %s for disk id %s",
|
||||
state.Pool.ValueString(),
|
||||
plan.Pool.ValueString(),
|
||||
plan.Id.ValueString()))
|
||||
plan.ID.ValueString()))
|
||||
}
|
||||
|
||||
// check sep_id
|
||||
@@ -82,17 +76,7 @@ func resourceDiskUpdateInputChecks(ctx context.Context, plan, state *models.Reso
|
||||
fmt.Sprintf("cannot change sep_id from %d to %d for disk id %s",
|
||||
state.SEPID.ValueInt64(),
|
||||
plan.SEPID.ValueInt64(),
|
||||
plan.Id.ValueString()))
|
||||
}
|
||||
|
||||
// check type
|
||||
if !plan.Type.Equal(state.Type) && !plan.Type.IsUnknown() {
|
||||
diags.AddError(
|
||||
"resourceDiskUpdateInputChecks: type change is not allowed",
|
||||
fmt.Sprintf("cannot change type from %s to %s for disk id %s",
|
||||
state.Type.ValueString(),
|
||||
plan.Type.ValueString(),
|
||||
plan.Id.ValueString()))
|
||||
plan.ID.ValueString()))
|
||||
}
|
||||
|
||||
return diags
|
||||
|
||||
@@ -11,12 +11,14 @@ type DataSourceDiskModel struct {
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
|
||||
// response fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
ID types.String `tfsdk:"id"`
|
||||
ACL types.String `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
Computes types.List `tfsdk:"computes"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
DeviceName types.String `tfsdk:"devicename"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
@@ -25,13 +27,16 @@ type DataSourceDiskModel struct {
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Images types.List `tfsdk:"images"`
|
||||
IOTune types.Object `tfsdk:"iotune"`
|
||||
MachineID types.Int64 `tfsdk:"machine_id"`
|
||||
MachineName types.String `tfsdk:"machine_name"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Name types.String `tfsdk:"disk_name"`
|
||||
Order types.Int64 `tfsdk:"order"`
|
||||
Params types.String `tfsdk:"params"`
|
||||
ParentID types.Int64 `tfsdk:"parent_id"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
@@ -39,11 +44,14 @@ type DataSourceDiskModel struct {
|
||||
SepType types.String `tfsdk:"sep_type"`
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
Shareable types.Bool `tfsdk:"shareable"`
|
||||
SizeAvailable types.Float64 `tfsdk:"size_available"`
|
||||
SizeMax types.Int64 `tfsdk:"size_max"`
|
||||
SizeUsed types.Float64 `tfsdk:"size_used"`
|
||||
Snapshots types.List `tfsdk:"snapshots"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
Type types.String `tfsdk:"type"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
VMID types.Int64 `tfsdk:"vmid"`
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ type DataSourceDiskListModel struct {
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
|
||||
// response fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
ID types.String `tfsdk:"id"`
|
||||
Items []ItemDiskModel `tfsdk:"items"`
|
||||
EntryCount types.Int64 `tfsdk:"entry_count"`
|
||||
}
|
||||
@@ -33,7 +33,9 @@ type ItemDiskModel struct {
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
ACL types.String `tfsdk:"acl"`
|
||||
Computes types.List `tfsdk:"computes"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
DestructionTime types.Int64 `tfsdk:"destruction_time"`
|
||||
@@ -46,12 +48,13 @@ type ItemDiskModel struct {
|
||||
MachineName types.String `tfsdk:"machine_name"`
|
||||
DiskId types.Int64 `tfsdk:"disk_id"`
|
||||
DiskName types.String `tfsdk:"disk_name"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Order types.Int64 `tfsdk:"order"`
|
||||
Params types.String `tfsdk:"params"`
|
||||
ParentID types.Int64 `tfsdk:"parent_id"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
@@ -59,11 +62,14 @@ type ItemDiskModel struct {
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
SepType types.String `tfsdk:"sep_type"`
|
||||
Shareable types.Bool `tfsdk:"shareable"`
|
||||
SizeAvailable types.Float64 `tfsdk:"size_available"`
|
||||
SizeMax types.Int64 `tfsdk:"size_max"`
|
||||
SizeUsed types.Float64 `tfsdk:"size_used"`
|
||||
Snapshots types.List `tfsdk:"snapshots"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
Type types.String `tfsdk:"type"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
VMID types.Int64 `tfsdk:"vmid"`
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type DataSourceDiskListDeletedModel struct {
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
|
||||
// response fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
ID types.String `tfsdk:"id"`
|
||||
Items []ItemDiskModel `tfsdk:"items"`
|
||||
EntryCount types.Int64 `tfsdk:"entry_count"`
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ type RecordDiskModel struct {
|
||||
ParentID types.Int64 `tfsdk:"parent_id"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
Replication *ItemReplicationModel `tfsdk:"replication"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
|
||||
@@ -11,7 +11,6 @@ type ResourceDiskModel struct {
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
DiskName types.String `tfsdk:"disk_name"`
|
||||
SizeMax types.Int64 `tfsdk:"size_max"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
|
||||
// request fields - optional
|
||||
Description types.String `tfsdk:"desc"`
|
||||
@@ -25,23 +24,28 @@ type ResourceDiskModel struct {
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
|
||||
// response fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
ID types.String `tfsdk:"id"`
|
||||
LastUpdated types.String `tfsdk:"last_updated"`
|
||||
ACL types.String `tfsdk:"acl"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
Computes types.List `tfsdk:"computes"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
DeviceName types.String `tfsdk:"devicename"`
|
||||
DestructionTime types.Int64 `tfsdk:"destruction_time"`
|
||||
DiskId types.Int64 `tfsdk:"disk_id"`
|
||||
DiskID types.Int64 `tfsdk:"disk_id"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Images types.List `tfsdk:"images"`
|
||||
MachineID types.Int64 `tfsdk:"machine_id"`
|
||||
MachineName types.String `tfsdk:"machine_name"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
Order types.Int64 `tfsdk:"order"`
|
||||
Params types.String `tfsdk:"params"`
|
||||
ParentID types.Int64 `tfsdk:"parent_id"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
@@ -51,6 +55,8 @@ type ResourceDiskModel struct {
|
||||
Snapshots types.List `tfsdk:"snapshots"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
VMID types.Int64 `tfsdk:"vmid"`
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ type ResourceRecordDiskReplicationModel struct {
|
||||
ParentID types.Int64 `tfsdk:"parent_id"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
Replication types.Object `tfsdk:"replication"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
|
||||
@@ -51,7 +51,6 @@ func (r *resourceDisk) Create(ctx context.Context, req resource.CreateRequest, r
|
||||
"account_id": plan.AccountID.ValueInt64(),
|
||||
"disk_name": plan.DiskName.ValueString(),
|
||||
"size_max": plan.SizeMax.ValueInt64(),
|
||||
"gid": plan.GID.ValueInt64(),
|
||||
}
|
||||
tflog.Info(ctx, "Create resourceDisk: got plan successfully", contextCreateMap)
|
||||
tflog.Info(ctx, "Create resourceDisk: start creating", contextCreateMap)
|
||||
@@ -67,7 +66,6 @@ func (r *resourceDisk) Create(ctx context.Context, req resource.CreateRequest, r
|
||||
"account_id": plan.AccountID.ValueInt64(),
|
||||
"disk_name": plan.DiskName.ValueString(),
|
||||
"size_max": plan.SizeMax.ValueInt64(),
|
||||
"gid": plan.GID.ValueInt64(),
|
||||
"createTimeout": createTimeout})
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, createTimeout)
|
||||
@@ -93,7 +91,7 @@ func (r *resourceDisk) Create(ctx context.Context, req resource.CreateRequest, r
|
||||
)
|
||||
return
|
||||
}
|
||||
plan.Id = types.StringValue(strconv.Itoa(int(diskId)))
|
||||
plan.ID = types.StringValue(strconv.Itoa(int(diskId)))
|
||||
tflog.Info(ctx, "Create resourceDisk: disk created", map[string]any{"diskId": diskId, "disk_name": plan.DiskName.ValueString()})
|
||||
|
||||
// additional settings after disk creation: in case of failures, warnings are added to resp.Diagnostics,
|
||||
@@ -137,7 +135,7 @@ func (r *resourceDisk) Read(ctx context.Context, req resource.ReadRequest, resp
|
||||
tflog.Error(ctx, "Read resourceDisk: Error get state")
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Read resourceDisk: got state successfully", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "Read resourceDisk: got state successfully", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
|
||||
// Set timeouts
|
||||
readTimeout, diags := state.Timeouts.Read(ctx, constants.Timeout300s)
|
||||
@@ -147,7 +145,7 @@ func (r *resourceDisk) Read(ctx context.Context, req resource.ReadRequest, resp
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Read resourceDisk: set timeouts successfully", map[string]any{
|
||||
"disk_id": state.Id.ValueString(),
|
||||
"disk_id": state.ID.ValueString(),
|
||||
"readTimeout": readTimeout})
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, readTimeout)
|
||||
@@ -185,7 +183,7 @@ func (r *resourceDisk) Update(ctx context.Context, req resource.UpdateRequest, r
|
||||
tflog.Error(ctx, "Update resourceDisk: Error receiving the plan")
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Update resourceDisk: got plan successfully", map[string]any{"disk_id": plan.Id.ValueString()})
|
||||
tflog.Info(ctx, "Update resourceDisk: got plan successfully", map[string]any{"disk_id": plan.ID.ValueString()})
|
||||
|
||||
// Retrieve values from state
|
||||
var state models.ResourceDiskModel
|
||||
@@ -194,7 +192,7 @@ func (r *resourceDisk) Update(ctx context.Context, req resource.UpdateRequest, r
|
||||
tflog.Error(ctx, "Update resourceDisk: Error receiving the state")
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Update resourceDisk: got state successfully", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "Update resourceDisk: got state successfully", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
|
||||
// Set timeouts
|
||||
updateTimeout, diags := plan.Timeouts.Update(ctx, constants.Timeout300s)
|
||||
@@ -204,22 +202,22 @@ func (r *resourceDisk) Update(ctx context.Context, req resource.UpdateRequest, r
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Update resourceDisk: set timeouts successfully", map[string]any{
|
||||
"disk_id": state.Id.ValueString(),
|
||||
"disk_id": state.ID.ValueString(),
|
||||
"updateTimeout": updateTimeout})
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, updateTimeout)
|
||||
defer cancel()
|
||||
|
||||
// Checking if inputs are valid
|
||||
tflog.Info(ctx, "Update resourceDisk: starting input checks", map[string]any{"disk_id": plan.Id.ValueString()})
|
||||
tflog.Info(ctx, "Update resourceDisk: starting input checks", map[string]any{"disk_id": plan.ID.ValueString()})
|
||||
resp.Diagnostics.Append(resourceDiskUpdateInputChecks(ctx, &plan, &state, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceDisk: Error input checks")
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Update resourceDisk: input checks successful", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "Update resourceDisk: input checks successful", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
|
||||
diskId, err := strconv.Atoi(state.Id.ValueString())
|
||||
diskId, err := strconv.Atoi(state.ID.ValueString())
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Update resourceDisk: Cannot parse disk ID from state", err.Error())
|
||||
return
|
||||
@@ -261,7 +259,7 @@ func (r *resourceDisk) Update(ctx context.Context, req resource.UpdateRequest, r
|
||||
}
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Update resourceDisk: disk update is completed", map[string]any{"disk_id": plan.Id.ValueString()})
|
||||
tflog.Info(ctx, "Update resourceDisk: disk update is completed", map[string]any{"disk_id": plan.ID.ValueString()})
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
resp.Diagnostics.Append(flattens.DiskResource(ctx, &plan, r.client)...)
|
||||
@@ -288,7 +286,7 @@ func (r *resourceDisk) Delete(ctx context.Context, req resource.DeleteRequest, r
|
||||
tflog.Error(ctx, "Delete resourceDisk: Error get state")
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Delete resourceDisk: got state successfully", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "Delete resourceDisk: got state successfully", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
|
||||
// Set timeouts
|
||||
deleteTimeout, diags := state.Timeouts.Delete(ctx, constants.Timeout300s)
|
||||
@@ -298,7 +296,7 @@ func (r *resourceDisk) Delete(ctx context.Context, req resource.DeleteRequest, r
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Delete resourceDisk: set timeouts successfully", map[string]any{
|
||||
"disk_id": state.Id.ValueString(),
|
||||
"disk_id": state.ID.ValueString(),
|
||||
"deleteTimeout": deleteTimeout})
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, deleteTimeout)
|
||||
@@ -306,7 +304,7 @@ func (r *resourceDisk) Delete(ctx context.Context, req resource.DeleteRequest, r
|
||||
|
||||
// Delete existing resource group
|
||||
delReq := disks.DeleteRequest{
|
||||
DiskID: uint64(state.DiskId.ValueInt64()),
|
||||
DiskID: uint64(state.DiskID.ValueInt64()),
|
||||
Detach: state.Detach.ValueBool(), // default false
|
||||
Permanently: state.Permanently.ValueBool(), // default false
|
||||
}
|
||||
@@ -318,7 +316,7 @@ func (r *resourceDisk) Delete(ctx context.Context, req resource.DeleteRequest, r
|
||||
return
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End delete resourceDisk", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "End delete resourceDisk", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
|
||||
@@ -38,9 +38,15 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -61,7 +67,7 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -110,6 +116,15 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
"disk_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"machine_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"machine_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"order": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -125,7 +140,7 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -150,6 +165,9 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
"shareable": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": schema.Float64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -190,6 +208,12 @@ func MakeSchemaDataSourceDisk() map[string]schema.Attribute {
|
||||
"type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -91,9 +91,15 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -117,7 +123,7 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -169,6 +175,9 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
"machine_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"disk_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -187,7 +196,7 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -212,6 +221,9 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
"shareable": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": schema.Float64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -252,6 +264,12 @@ func MakeSchemaDataSourceDiskList() map[string]schema.Attribute {
|
||||
"type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -79,9 +79,15 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -105,7 +111,7 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -157,6 +163,9 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
"machine_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"milestones": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"disk_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -175,7 +184,7 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -200,6 +209,9 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
"shareable": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": schema.Float64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -240,6 +252,12 @@ func MakeSchemaDataSourceDiskListDeleted() map[string]schema.Attribute {
|
||||
"type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -109,7 +109,7 @@ func MakeSchemaDataSourceDiskListUnattached() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
|
||||
@@ -66,7 +66,7 @@ func MakeSchemaDataSourceDiskReplication() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -130,7 +130,7 @@ func MakeSchemaDataSourceDiskReplication() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
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"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
)
|
||||
|
||||
@@ -24,10 +23,6 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
Required: true,
|
||||
Description: "size in GB, default is 10",
|
||||
},
|
||||
"gid": schema.Int64Attribute{
|
||||
Required: true,
|
||||
Description: "ID of the grid (platform)",
|
||||
},
|
||||
|
||||
// optional attributes
|
||||
"desc": schema.StringAttribute{
|
||||
@@ -46,23 +41,21 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
Description: "Storage endpoint provider ID to create disk",
|
||||
},
|
||||
"type": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOf("B", "D", "T"), // case is not ignored
|
||||
},
|
||||
Computed: true,
|
||||
Description: "(B;D;T) B=Boot;D=Data;T=Temp",
|
||||
// default is D
|
||||
},
|
||||
"detach": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Detaching the disk from compute",
|
||||
// default is false
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"permanently": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Whether to completely delete the disk, works only with non attached disks",
|
||||
// default is false
|
||||
Default: booldefault.StaticBool(true),
|
||||
},
|
||||
"shareable": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
@@ -170,9 +163,15 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"created_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -187,12 +186,22 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"gid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
Description: "ID of the grid (platform)",
|
||||
},
|
||||
"last_updated": schema.StringAttribute{
|
||||
Computed: true,
|
||||
Description: "Timestamp of the last Terraform update of the disk resource.",
|
||||
},
|
||||
"machine_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"machine_name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"order": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -205,7 +214,7 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
"pci_slot": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -258,6 +267,12 @@ func MakeSchemaResourceDisk() map[string]schema.Attribute {
|
||||
"tech_status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_by": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"updated_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -97,7 +97,7 @@ func MakeSchemaResourceDiskReplication() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -158,7 +158,7 @@ func MakeSchemaResourceDiskReplication() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
|
||||
@@ -17,16 +17,16 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/disks/models"
|
||||
)
|
||||
|
||||
// DiskCheckPresence checks if disk with diskId exists
|
||||
func DiskCheckPresence(ctx context.Context, diskId uint64, c *client.Client) (*disks.RecordDisk, error) {
|
||||
tflog.Info(ctx, fmt.Sprintf("Get info about disk with ID - %v", diskId))
|
||||
// DiskCheckPresence checks if disk with diskID exists
|
||||
func DiskCheckPresence(ctx context.Context, diskID uint64, c *client.Client) (*disks.RecordDisk, error) {
|
||||
tflog.Info(ctx, fmt.Sprintf("Get info about disk with ID - %v", diskID))
|
||||
|
||||
diskRecord, err := c.CloudAPI().Disks().Get(ctx, disks.GetRequest{DiskID: diskId})
|
||||
diskRecord, err := c.CloudAPI().Disks().Get(ctx, disks.GetRequest{DiskID: diskID})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get info about disk with error: %w", err)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "DiskCheckPresence resourceDisk: response from CloudAPI().Disks().Get", map[string]any{"disk_id": diskId, "response": diskRecord})
|
||||
tflog.Info(ctx, "DiskCheckPresence resourceDisk: response from CloudAPI().Disks().Get", map[string]any{"disk_id": diskID, "response": diskRecord})
|
||||
|
||||
return diskRecord, err
|
||||
}
|
||||
@@ -37,7 +37,6 @@ func CreateRequestResourceDisk(ctx context.Context, plan *models.ResourceDiskMod
|
||||
"account_id": plan.AccountID.ValueInt64(),
|
||||
"disk_name": plan.DiskName.ValueString(),
|
||||
"size_max": plan.SizeMax.ValueInt64(),
|
||||
"gid": plan.GID.ValueInt64(),
|
||||
})
|
||||
|
||||
// set up required parameters in disk create request
|
||||
@@ -45,14 +44,8 @@ func CreateRequestResourceDisk(ctx context.Context, plan *models.ResourceDiskMod
|
||||
AccountID: uint64(plan.AccountID.ValueInt64()),
|
||||
Name: plan.DiskName.ValueString(),
|
||||
Size: uint64(plan.SizeMax.ValueInt64()),
|
||||
GID: uint64(plan.GID.ValueInt64()),
|
||||
}
|
||||
|
||||
if plan.Type.IsUnknown() {
|
||||
createReq.Type = "D" // default value
|
||||
} else {
|
||||
createReq.Type = plan.Type.ValueString()
|
||||
}
|
||||
if !plan.SEPID.IsUnknown() {
|
||||
createReq.SEPID = uint64(plan.SEPID.ValueInt64())
|
||||
}
|
||||
@@ -68,16 +61,16 @@ func CreateRequestResourceDisk(ctx context.Context, plan *models.ResourceDiskMod
|
||||
|
||||
// LimitIOCreateDisk sets IO limits that user specified in iotune field for created resource.
|
||||
// In case of failure returns warnings.
|
||||
func LimitIOCreateDisk(ctx context.Context, diskId uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
func LimitIOCreateDisk(ctx context.Context, diskID uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
limitIOReq := disks.LimitIORequest{
|
||||
DiskID: diskId,
|
||||
DiskID: diskID,
|
||||
}
|
||||
|
||||
var iotunePlan models.IOTuneModel
|
||||
// plan.IOTune is not null as it was checked before call
|
||||
tflog.Info(ctx, "LimitIOCreateDisk: new iotune specified", map[string]any{"disk_id": diskId})
|
||||
tflog.Info(ctx, "LimitIOCreateDisk: new iotune specified", map[string]any{"disk_id": diskID})
|
||||
diags.Append(plan.IOTune.As(ctx, &iotunePlan, basetypes.ObjectAsOptions{})...)
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, "LimitIOCreateDisk: cannot populate iotune with plan.IOTune object element")
|
||||
@@ -103,7 +96,7 @@ func LimitIOCreateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
limitIOReq.WriteIOPSSecMax = uint64(iotunePlan.WriteIOPSSecMax.ValueInt64())
|
||||
|
||||
tflog.Info(ctx, "LimitIOCreateDisk: before calling CloudAPI().Disks().LimitIO", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"limitIOReq": limitIOReq})
|
||||
res, err := c.CloudAPI().Disks().LimitIO(ctx, limitIOReq)
|
||||
if err != nil {
|
||||
@@ -111,7 +104,7 @@ func LimitIOCreateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
err.Error())
|
||||
}
|
||||
tflog.Info(ctx, "LimitIOCreateDisk: response from CloudAPI().Disks().LimitIO", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"response": res})
|
||||
|
||||
return diags
|
||||
@@ -119,17 +112,17 @@ func LimitIOCreateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
|
||||
// ShareableCreateDisk shares disk.
|
||||
// In case of failure returns warnings.
|
||||
func ShareableCreateDisk(ctx context.Context, diskId uint64, c *client.Client) diag.Diagnostics {
|
||||
func ShareableCreateDisk(ctx context.Context, diskID uint64, c *client.Client) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
tflog.Info(ctx, "ShareableCreateDisk: before calling CloudAPI().Disks().Share", map[string]any{"disk_id": diskId})
|
||||
res, err := c.CloudAPI().Disks().Share(ctx, disks.ShareRequest{DiskID: diskId})
|
||||
tflog.Info(ctx, "ShareableCreateDisk: before calling CloudAPI().Disks().Share", map[string]any{"disk_id": diskID})
|
||||
res, err := c.CloudAPI().Disks().Share(ctx, disks.ShareRequest{DiskID: diskID})
|
||||
if err != nil {
|
||||
diags.AddWarning("ShareableCreateDisk: Unable to share Disk",
|
||||
err.Error())
|
||||
}
|
||||
tflog.Info(ctx, "ShareableCreateDisk: response from CloudAPI().Disks().Share", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"response": res})
|
||||
|
||||
return diags
|
||||
@@ -139,17 +132,17 @@ func ShareableCreateDisk(ctx context.Context, diskId uint64, c *client.Client) d
|
||||
// Deleted status.
|
||||
// In case of failure returns errors.
|
||||
func DiskReadStatus(ctx context.Context, state *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
tflog.Info(ctx, "DiskReadStatus: Read status disk with ID", map[string]any{"disk_id": state.Id.ValueString()})
|
||||
tflog.Info(ctx, "DiskReadStatus: Read status disk with ID", map[string]any{"disk_id": state.ID.ValueString()})
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
diskId, err := strconv.ParseUint(state.Id.ValueString(), 10, 64)
|
||||
diskID, err := strconv.ParseUint(state.ID.ValueString(), 10, 64)
|
||||
if err != nil {
|
||||
diags.AddError("DiskReadStatus: Cannot parse disk ID from state", err.Error())
|
||||
return diags
|
||||
}
|
||||
|
||||
recordDisk, err := DiskCheckPresence(ctx, diskId, c)
|
||||
recordDisk, err := DiskCheckPresence(ctx, diskID, c)
|
||||
if err != nil {
|
||||
diags.AddError("DiskReadStatus: Unable to Read Disk before status check", err.Error())
|
||||
return diags
|
||||
@@ -168,17 +161,17 @@ func DiskReadStatus(ctx context.Context, state *models.ResourceDiskModel, c *cli
|
||||
tflog.Info(ctx, "DiskReadStatus: disk with status.Deleted is being read, attempt to restore it", map[string]any{
|
||||
"disk_id": recordDisk.ID,
|
||||
"status": recordDisk.Status})
|
||||
diags.Append(RestoreDisk(ctx, diskId, c)...)
|
||||
diags.Append(RestoreDisk(ctx, diskID, c)...)
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, "DiskReadStatus: cannot restore disk")
|
||||
return diags
|
||||
}
|
||||
tflog.Info(ctx, "DiskReadStatus: disk restored successfully", map[string]any{"disk_id": diskId})
|
||||
tflog.Info(ctx, "DiskReadStatus: disk restored successfully", map[string]any{"disk_id": diskID})
|
||||
state.LastUpdated = types.StringValue(time.Now().Format(time.RFC850))
|
||||
case status.Destroyed, status.Purged:
|
||||
diags.AddError(
|
||||
"DiskReadStatus: Disk is in status Destroyed or Purged",
|
||||
fmt.Sprintf("the resource with disk_id %d cannot be read because it has been destroyed or purged", diskId),
|
||||
fmt.Sprintf("the resource with disk_id %d cannot be read because it has been destroyed or purged", diskID),
|
||||
)
|
||||
return diags
|
||||
}
|
||||
@@ -188,14 +181,14 @@ func DiskReadStatus(ctx context.Context, state *models.ResourceDiskModel, c *cli
|
||||
|
||||
// RestoreDisk performs disk Restore request.
|
||||
// Returns error in case of failures.
|
||||
func RestoreDisk(ctx context.Context, diskId uint64, c *client.Client) diag.Diagnostics {
|
||||
func RestoreDisk(ctx context.Context, diskID uint64, c *client.Client) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
restoreReq := disks.RestoreRequest{
|
||||
DiskID: diskId,
|
||||
DiskID: diskID,
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "RestoreDisk: before calling CloudAPI().Disks().Restore", map[string]any{"diskId": diskId, "req": restoreReq})
|
||||
tflog.Info(ctx, "RestoreDisk: before calling CloudAPI().Disks().Restore", map[string]any{"diskID": diskID, "req": restoreReq})
|
||||
|
||||
res, err := c.CloudAPI().Disks().Restore(ctx, restoreReq)
|
||||
if err != nil {
|
||||
@@ -205,18 +198,18 @@ func RestoreDisk(ctx context.Context, diskId uint64, c *client.Client) diag.Diag
|
||||
)
|
||||
return diags
|
||||
}
|
||||
tflog.Info(ctx, "RestoreDisk: response from CloudAPI().Disks().Restore", map[string]any{"disk_id": diskId, "response": res})
|
||||
tflog.Info(ctx, "RestoreDisk: response from CloudAPI().Disks().Restore", map[string]any{"disk_id": diskID, "response": res})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SizeMaxUpdateDisk resizes disk.
|
||||
// Returns error in case of failures.
|
||||
func SizeMaxUpdateDisk(ctx context.Context, diskId uint64, plan, state *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
func SizeMaxUpdateDisk(ctx context.Context, diskID uint64, plan, state *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
resizeReq := disks.ResizeRequest{
|
||||
DiskID: diskId,
|
||||
DiskID: diskID,
|
||||
}
|
||||
|
||||
// check if resize request is valid
|
||||
@@ -224,7 +217,7 @@ func SizeMaxUpdateDisk(ctx context.Context, diskId uint64, plan, state *models.R
|
||||
diags.AddError(
|
||||
"SizeMaxUpdateDisk: reducing disk size is not allowed",
|
||||
fmt.Sprintf("disk with id %s has state size %d, plan size %d",
|
||||
plan.Id.ValueString(),
|
||||
plan.ID.ValueString(),
|
||||
state.SizeMax.ValueInt64(),
|
||||
plan.SizeMax.ValueInt64()))
|
||||
return diags
|
||||
@@ -233,7 +226,7 @@ func SizeMaxUpdateDisk(ctx context.Context, diskId uint64, plan, state *models.R
|
||||
resizeReq.Size = uint64(plan.SizeMax.ValueInt64())
|
||||
|
||||
tflog.Info(ctx, "SizeMaxUpdateDisk: before calling CloudAPI().Disks().Resize2", map[string]any{
|
||||
"disk_id": plan.Id.ValueString(),
|
||||
"disk_id": plan.ID.ValueString(),
|
||||
"size_max_state": state.SizeMax.ValueInt64(),
|
||||
"size_max_plan": plan.SizeMax.ValueInt64(),
|
||||
"req": resizeReq,
|
||||
@@ -247,7 +240,7 @@ func SizeMaxUpdateDisk(ctx context.Context, diskId uint64, plan, state *models.R
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "SizeMaxUpdateDisk: response from CloudAPI().Disks().Resize2", map[string]any{
|
||||
"disk_id": plan.Id.ValueString(),
|
||||
"disk_id": plan.ID.ValueString(),
|
||||
"response": res})
|
||||
|
||||
return nil
|
||||
@@ -255,16 +248,16 @@ func SizeMaxUpdateDisk(ctx context.Context, diskId uint64, plan, state *models.R
|
||||
|
||||
// NameUpdateDisk renames disk.
|
||||
// Returns error in case of failures.
|
||||
func NameUpdateDisk(ctx context.Context, diskId uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
func NameUpdateDisk(ctx context.Context, diskID uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
renameReq := disks.RenameRequest{
|
||||
DiskID: diskId,
|
||||
DiskID: diskID,
|
||||
Name: plan.DiskName.ValueString(),
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "NameUpdateDisk: before calling CloudAPI().Disks().Rename", map[string]any{
|
||||
"disk_id": plan.Id.ValueString(),
|
||||
"disk_id": plan.ID.ValueString(),
|
||||
"disk_name_plan": plan.DiskName.ValueString(),
|
||||
"req": renameReq,
|
||||
})
|
||||
@@ -277,7 +270,7 @@ func NameUpdateDisk(ctx context.Context, diskId uint64, plan *models.ResourceDis
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "NameUpdateDisk: response from CloudAPI().Disks().Rename", map[string]any{
|
||||
"disk_id": plan.Id.ValueString(),
|
||||
"disk_id": plan.ID.ValueString(),
|
||||
"response": res})
|
||||
|
||||
return nil
|
||||
@@ -285,16 +278,16 @@ func NameUpdateDisk(ctx context.Context, diskId uint64, plan *models.ResourceDis
|
||||
|
||||
// LimitIOUpdateDisk changes IO limits that user specified in iotune field for updated resource.
|
||||
// In case of failure returns errors.
|
||||
func LimitIOUpdateDisk(ctx context.Context, diskId uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
func LimitIOUpdateDisk(ctx context.Context, diskID uint64, plan *models.ResourceDiskModel, c *client.Client) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
limitIOReq := disks.LimitIORequest{
|
||||
DiskID: diskId,
|
||||
DiskID: diskID,
|
||||
}
|
||||
|
||||
var iotunePlan models.IOTuneModel
|
||||
// plan.IOTune is not null as it was checked before call
|
||||
tflog.Info(ctx, "LimitIOUpdateDisk: new iotune specified", map[string]any{"disk_id": diskId})
|
||||
tflog.Info(ctx, "LimitIOUpdateDisk: new iotune specified", map[string]any{"disk_id": diskID})
|
||||
diags.Append(plan.IOTune.As(ctx, &iotunePlan, basetypes.ObjectAsOptions{})...)
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, "LimitIOUpdateDisk: cannot populate iotune with plan.IOTune object element")
|
||||
@@ -320,7 +313,7 @@ func LimitIOUpdateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
limitIOReq.WriteIOPSSecMax = uint64(iotunePlan.WriteIOPSSecMax.ValueInt64())
|
||||
|
||||
tflog.Info(ctx, "LimitIOUpdateDisk: before calling CloudAPI().Disks().LimitIO", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"limitIOReq": limitIOReq})
|
||||
res, err := c.CloudAPI().Disks().LimitIO(ctx, limitIOReq)
|
||||
if err != nil {
|
||||
@@ -329,7 +322,7 @@ func LimitIOUpdateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
return diags
|
||||
}
|
||||
tflog.Info(ctx, "LimitIOUpdateDisk: response from CloudAPI().Disks().LimitIO", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"response": res})
|
||||
|
||||
return nil
|
||||
@@ -337,34 +330,34 @@ func LimitIOUpdateDisk(ctx context.Context, diskId uint64, plan *models.Resource
|
||||
|
||||
// ShareableUpdateDisk shares or unshares disk.
|
||||
// In case of failure returns errors.
|
||||
func ShareableUpdateDisk(ctx context.Context, diskId uint64, share bool, c *client.Client) diag.Diagnostics {
|
||||
func ShareableUpdateDisk(ctx context.Context, diskID uint64, share bool, c *client.Client) diag.Diagnostics {
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
// share
|
||||
if share {
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: before calling CloudAPI().Disks().Share", map[string]any{"disk_id": diskId})
|
||||
res, err := c.CloudAPI().Disks().Share(ctx, disks.ShareRequest{DiskID: diskId})
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: before calling CloudAPI().Disks().Share", map[string]any{"disk_id": diskID})
|
||||
res, err := c.CloudAPI().Disks().Share(ctx, disks.ShareRequest{DiskID: diskID})
|
||||
if err != nil {
|
||||
diags.AddError("ShareableUpdateDisk: Unable to share Disk",
|
||||
err.Error())
|
||||
return diags
|
||||
}
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: response from CloudAPI().Disks().Share", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"response": res})
|
||||
}
|
||||
|
||||
// unshare
|
||||
if !share {
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: before calling CloudAPI().Disks().Unshare", map[string]any{"disk_id": diskId})
|
||||
res, err := c.CloudAPI().Disks().Unshare(ctx, disks.UnshareRequest{DiskID: diskId})
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: before calling CloudAPI().Disks().Unshare", map[string]any{"disk_id": diskID})
|
||||
res, err := c.CloudAPI().Disks().Unshare(ctx, disks.UnshareRequest{DiskID: diskID})
|
||||
if err != nil {
|
||||
diags.AddError("ShareableUpdateDisk: Unable to unshare Disk",
|
||||
err.Error())
|
||||
return diags
|
||||
}
|
||||
tflog.Info(ctx, "ShareableUpdateDisk: response from CloudAPI().Disks().Unshare", map[string]any{
|
||||
"disk_id": diskId,
|
||||
"disk_id": diskID,
|
||||
"response": res})
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ func ExtNetDataSource(ctx context.Context, state *models.DataSourceExtNetModel,
|
||||
NetName: types.StringValue(recordExtNet.Name),
|
||||
Network: types.StringValue(recordExtNet.Network),
|
||||
NetworkID: types.Int64Value(int64(recordExtNet.NetworkID)),
|
||||
NTP: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordExtNet.NTP),
|
||||
PreReservationsNum: types.Int64Value(int64(recordExtNet.PreReservationsNum)),
|
||||
Prefix: types.Int64Value(int64(recordExtNet.Prefix)),
|
||||
PriVNFDevID: types.Int64Value(int64(recordExtNet.PriVNFDevID)),
|
||||
|
||||
@@ -36,6 +36,7 @@ func ExtNetListDataSource(ctx context.Context, state *models.DataSourceExtNetLis
|
||||
Network: state.Network,
|
||||
VLANID: state.VLANID,
|
||||
VNFDevID: state.VNFDevID,
|
||||
OVSBridge: state.OVSBridge,
|
||||
Status: state.Status,
|
||||
Page: state.Page,
|
||||
Size: state.Size,
|
||||
|
||||
@@ -30,6 +30,7 @@ type DataSourceExtNetModel struct {
|
||||
NetName types.String `tfsdk:"net_name"`
|
||||
Network types.String `tfsdk:"network"`
|
||||
NetworkID types.Int64 `tfsdk:"network_id"`
|
||||
NTP types.List `tfsdk:"ntp"`
|
||||
PreReservationsNum types.Int64 `tfsdk:"pre_reservations_num"`
|
||||
Prefix types.Int64 `tfsdk:"prefix"`
|
||||
PriVNFDevID types.Int64 `tfsdk:"pri_vnf_dev_id"`
|
||||
|
||||
@@ -13,6 +13,7 @@ type DataSourceExtNetListModel struct {
|
||||
Network types.String `tfsdk:"network"`
|
||||
VLANID types.Int64 `tfsdk:"vlan_id"`
|
||||
VNFDevID types.Int64 `tfsdk:"vnfdev_id"`
|
||||
OVSBridge types.String `tfsdk:"ovs_bridge"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Page types.Int64 `tfsdk:"page"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
|
||||
@@ -31,6 +31,10 @@ func MakeSchemaDataSourceExtNet() map[string]schema.Attribute {
|
||||
"default": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"ntp": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"default_qos": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
Attributes: map[string]schema.Attribute{
|
||||
|
||||
@@ -31,6 +31,10 @@ func MakeSchemaDataSourceExtNetList() map[string]schema.Attribute {
|
||||
Optional: true,
|
||||
Description: "find by vnfdevices id",
|
||||
},
|
||||
"ovs_bridge": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "find by ovs_bridge",
|
||||
},
|
||||
"status": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "find by status",
|
||||
|
||||
@@ -34,6 +34,9 @@ func ExtNetListCheckPresence(ctx context.Context, plan *models.DataSourceExtNetL
|
||||
if !plan.VNFDevID.IsNull() {
|
||||
extnetListReq.VNFDevID = uint64(plan.VNFDevID.ValueInt64())
|
||||
}
|
||||
if !plan.OVSBridge.IsNull() {
|
||||
extnetListReq.OVSBridge = plan.OVSBridge.ValueString()
|
||||
}
|
||||
if !plan.Status.IsNull() {
|
||||
extnetListReq.Status = plan.Status.ValueString()
|
||||
}
|
||||
|
||||
@@ -33,16 +33,16 @@ func FlipgroupResource(ctx context.Context, plan *models.ResourceFLIPGroupModel,
|
||||
}
|
||||
|
||||
*plan = models.ResourceFLIPGroupModel{
|
||||
AccountID: plan.AccountID,
|
||||
Name: plan.Name,
|
||||
NetType: plan.NetType,
|
||||
NetID: plan.NetID,
|
||||
ClientType: plan.ClientType,
|
||||
AccountID: types.Int64Value(int64(recordFG.AccountID)),
|
||||
Name: types.StringValue(recordFG.Name),
|
||||
NetType: types.StringValue(recordFG.NetType),
|
||||
NetID: types.Int64Value(int64(recordFG.NetID)),
|
||||
ClientType: types.StringValue(recordFG.ClientType),
|
||||
Timeouts: plan.Timeouts,
|
||||
Description: plan.Description,
|
||||
ClientIDs: plan.ClientIDs,
|
||||
Description: types.StringValue(recordFG.Description),
|
||||
ClientIDs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordFG.ClientIDs),
|
||||
ID: plan.ID,
|
||||
IP: plan.IP,
|
||||
IP: types.StringValue(recordFG.IP),
|
||||
|
||||
AccountName: types.StringValue(recordFG.AccountName),
|
||||
ConnID: types.Int64Value(int64(recordFG.ConnID)),
|
||||
@@ -69,10 +69,6 @@ func FlipgroupResource(ctx context.Context, plan *models.ResourceFLIPGroupModel,
|
||||
plan.IP = types.StringValue(recordFG.IP)
|
||||
}
|
||||
|
||||
if plan.ClientIDs.IsUnknown() {
|
||||
plan.ClientIDs = flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordFG.ClientIDs)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattens.FlipgroupResource", map[string]any{"flipgroup_id": plan.ID.ValueString()})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ func DataSourceImage(ctx context.Context, state *models.RecordImageModel, c *cli
|
||||
ResID: types.StringValue(image.ResID),
|
||||
RescueCD: types.BoolValue(image.RescueCD),
|
||||
SepID: types.Int64Value(int64(image.SepID)),
|
||||
SnapshotID: types.StringValue(image.SnapshotID),
|
||||
Size: types.Int64Value(int64(image.Size)),
|
||||
Status: types.StringValue(image.Status),
|
||||
TechStatus: types.StringValue(image.TechStatus),
|
||||
@@ -77,7 +78,7 @@ func DataSourceImage(ctx context.Context, state *models.RecordImageModel, c *cli
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
|
||||
}
|
||||
state.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
state.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ func ResourceImage(ctx context.Context, plan *models.ImageResourceModel, c *clie
|
||||
ResID: types.StringValue(image.ResID),
|
||||
RescueCD: types.BoolValue(image.RescueCD),
|
||||
Size: types.Int64Value(int64(image.Size)),
|
||||
SnapshotID: types.StringValue(image.SnapshotID),
|
||||
Status: types.StringValue(image.Status),
|
||||
TechStatus: types.StringValue(image.TechStatus),
|
||||
Version: types.StringValue(image.Version),
|
||||
@@ -84,7 +85,7 @@ func ResourceImage(ctx context.Context, plan *models.ImageResourceModel, c *clie
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
|
||||
}
|
||||
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package flattens
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@@ -30,42 +31,46 @@ func ResourceImageVirtual(ctx context.Context, plan *models.ImageVirtualResource
|
||||
return diags
|
||||
}
|
||||
|
||||
cdPresentedTo, _ := json.Marshal(image.CdPresentedTo)
|
||||
*plan = models.ImageVirtualResourceModel{
|
||||
ImageName: types.StringValue(image.Name),
|
||||
LinkTo: types.Int64Value(int64(image.LinkTo)),
|
||||
Timeouts: plan.Timeouts,
|
||||
Id: types.StringValue(strconv.Itoa(int(image.ID))),
|
||||
LastUpdated: plan.LastUpdated,
|
||||
UNCPath: types.StringValue(image.UNCPath),
|
||||
CKey: types.StringValue(image.CKey),
|
||||
AccountID: types.Int64Value(int64(image.AccountID)),
|
||||
Architecture: types.StringValue(image.Architecture),
|
||||
BootType: types.StringValue(image.BootType),
|
||||
Bootable: types.BoolValue(image.Bootable),
|
||||
ComputeCIID: types.Int64Value(int64(image.ComputeCIID)),
|
||||
DeletedTime: types.Int64Value(int64(image.DeletedTime)),
|
||||
Description: types.StringValue(image.Description),
|
||||
Enabled: types.BoolValue(image.Enabled),
|
||||
GID: types.Int64Value(int64(image.GID)),
|
||||
GUID: types.Int64Value(int64(image.GUID)),
|
||||
History: flattenHistoryInResource(ctx, &image.History),
|
||||
HotResize: types.BoolValue(image.HotResize),
|
||||
LastModified: types.Int64Value(int64(image.LastModified)),
|
||||
Milestones: types.Int64Value(int64(image.Milestones)),
|
||||
ImageId: types.Int64Value(int64(image.ID)),
|
||||
ImageType: types.StringValue(image.Type),
|
||||
Password: types.StringValue(image.Password),
|
||||
PoolName: types.StringValue(image.Pool),
|
||||
ProviderName: types.StringValue(image.ProviderName),
|
||||
PurgeAttempts: types.Int64Value(int64(image.PurgeAttempts)),
|
||||
ResID: types.StringValue(image.ResID),
|
||||
RescueCD: types.BoolValue(image.RescueCD),
|
||||
SepID: types.Int64Value(int64(image.SepID)),
|
||||
Size: types.Int64Value(int64(image.Size)),
|
||||
Status: types.StringValue(image.Status),
|
||||
TechStatus: types.StringValue(image.TechStatus),
|
||||
Username: types.StringValue(image.Username),
|
||||
Version: types.StringValue(image.Version),
|
||||
ImageName: types.StringValue(image.Name),
|
||||
LinkTo: types.Int64Value(int64(image.LinkTo)),
|
||||
Timeouts: plan.Timeouts,
|
||||
Id: types.StringValue(strconv.Itoa(int(image.ID))),
|
||||
LastUpdated: plan.LastUpdated,
|
||||
UNCPath: types.StringValue(image.UNCPath),
|
||||
CKey: types.StringValue(image.CKey),
|
||||
AccountID: types.Int64Value(int64(image.AccountID)),
|
||||
Architecture: types.StringValue(image.Architecture),
|
||||
BootType: types.StringValue(image.BootType),
|
||||
Bootable: types.BoolValue(image.Bootable),
|
||||
CdPresentedTo: types.StringValue(string(cdPresentedTo)),
|
||||
ComputeCIID: types.Int64Value(int64(image.ComputeCIID)),
|
||||
DeletedTime: types.Int64Value(int64(image.DeletedTime)),
|
||||
Description: types.StringValue(image.Description),
|
||||
Enabled: types.BoolValue(image.Enabled),
|
||||
GID: types.Int64Value(int64(image.GID)),
|
||||
GUID: types.Int64Value(int64(image.GUID)),
|
||||
History: flattenHistoryInResource(ctx, &image.History),
|
||||
HotResize: types.BoolValue(image.HotResize),
|
||||
LastModified: types.Int64Value(int64(image.LastModified)),
|
||||
Milestones: types.Int64Value(int64(image.Milestones)),
|
||||
NetworkInterfaceNaming: types.StringValue(image.NetworkInterfaceNaming),
|
||||
ImageId: types.Int64Value(int64(image.ID)),
|
||||
ImageType: types.StringValue(image.Type),
|
||||
Password: types.StringValue(image.Password),
|
||||
PoolName: types.StringValue(image.Pool),
|
||||
ProviderName: types.StringValue(image.ProviderName),
|
||||
PurgeAttempts: types.Int64Value(int64(image.PurgeAttempts)),
|
||||
ResID: types.StringValue(image.ResID),
|
||||
RescueCD: types.BoolValue(image.RescueCD),
|
||||
SepID: types.Int64Value(int64(image.SepID)),
|
||||
Size: types.Int64Value(int64(image.Size)),
|
||||
SnapshotID: types.StringValue(image.SnapshotID),
|
||||
Status: types.StringValue(image.Status),
|
||||
TechStatus: types.StringValue(image.TechStatus),
|
||||
Username: types.StringValue(image.Username),
|
||||
Version: types.StringValue(image.Version),
|
||||
}
|
||||
|
||||
plan.ACL, diags = types.ListValueFrom(ctx, types.StringType, image.ACL)
|
||||
@@ -76,7 +81,7 @@ func ResourceImageVirtual(ctx context.Context, plan *models.ImageVirtualResource
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDrivers", diags))
|
||||
}
|
||||
plan.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
plan.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, image.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
|
||||
}
|
||||
|
||||
@@ -37,12 +37,13 @@ type RecordImageModel struct {
|
||||
Password types.String `tfsdk:"password"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
PoolName types.String `tfsdk:"pool_name"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
ProviderName types.String `tfsdk:"provider_name"`
|
||||
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
RescueCD types.Bool `tfsdk:"rescuecd"`
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
SnapshotID types.String `tfsdk:"snapshot_id"`
|
||||
SharedWith types.List `tfsdk:"shared_with"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
|
||||
@@ -43,12 +43,13 @@ type ImageResourceModel struct {
|
||||
LinkTo types.Int64 `tfsdk:"link_to"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
ImageId types.Int64 `tfsdk:"image_id"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
ProviderName types.String `tfsdk:"provider_name"`
|
||||
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
RescueCD types.Bool `tfsdk:"rescuecd"`
|
||||
SharedWith types.List `tfsdk:"shared_with"`
|
||||
SnapshotID types.String `tfsdk:"snapshot_id"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
|
||||
@@ -11,42 +11,45 @@ type ImageVirtualResourceModel struct {
|
||||
LinkTo types.Int64 `tfsdk:"link_to"`
|
||||
Timeouts timeouts.Value `tfsdk:"timeouts"`
|
||||
// responce fields
|
||||
Id types.String `tfsdk:"id"`
|
||||
LastUpdated types.String `tfsdk:"last_updated"`
|
||||
UNCPath types.String `tfsdk:"unc_path"`
|
||||
CKey types.String `tfsdk:"ckey"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
ACL types.List `tfsdk:"acl"`
|
||||
Architecture types.String `tfsdk:"architecture"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
Bootable types.Bool `tfsdk:"bootable"`
|
||||
ComputeCIID types.Int64 `tfsdk:"compute_ci_id"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Drivers types.List `tfsdk:"drivers"`
|
||||
Enabled types.Bool `tfsdk:"enabled"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
History types.List `tfsdk:"history"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
LastModified types.Int64 `tfsdk:"last_modified"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
ImageId types.Int64 `tfsdk:"image_id"`
|
||||
ImageType types.String `tfsdk:"image_type"`
|
||||
Password types.String `tfsdk:"password"`
|
||||
PoolName types.String `tfsdk:"pool_name"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
ProviderName types.String `tfsdk:"provider_name"`
|
||||
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
RescueCD types.Bool `tfsdk:"rescuecd"`
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
SharedWith types.List `tfsdk:"shared_with"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
Version types.String `tfsdk:"version"`
|
||||
Id types.String `tfsdk:"id"`
|
||||
LastUpdated types.String `tfsdk:"last_updated"`
|
||||
UNCPath types.String `tfsdk:"unc_path"`
|
||||
CKey types.String `tfsdk:"ckey"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
ACL types.List `tfsdk:"acl"`
|
||||
Architecture types.String `tfsdk:"architecture"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
Bootable types.Bool `tfsdk:"bootable"`
|
||||
CdPresentedTo types.String `tfsdk:"cd_presented_to"`
|
||||
ComputeCIID types.Int64 `tfsdk:"compute_ci_id"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Drivers types.List `tfsdk:"drivers"`
|
||||
Enabled types.Bool `tfsdk:"enabled"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
History types.List `tfsdk:"history"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
LastModified types.Int64 `tfsdk:"last_modified"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
ImageId types.Int64 `tfsdk:"image_id"`
|
||||
ImageType types.String `tfsdk:"image_type"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
Password types.String `tfsdk:"password"`
|
||||
PoolName types.String `tfsdk:"pool_name"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
ProviderName types.String `tfsdk:"provider_name"`
|
||||
PurgeAttempts types.Int64 `tfsdk:"purge_attempts"`
|
||||
ResID types.String `tfsdk:"res_id"`
|
||||
RescueCD types.Bool `tfsdk:"rescuecd"`
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
SharedWith types.List `tfsdk:"shared_with"`
|
||||
Size types.Int64 `tfsdk:"size"`
|
||||
SnapshotID types.String `tfsdk:"snapshot_id"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
Version types.String `tfsdk:"version"`
|
||||
}
|
||||
|
||||
type HistoryInImageVirtualResourceModel struct {
|
||||
|
||||
@@ -115,7 +115,7 @@ func MakeSchemaDataSourceImage() map[string]schema.Attribute {
|
||||
"purge_attempts": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -128,6 +128,9 @@ func MakeSchemaDataSourceImage() map[string]schema.Attribute {
|
||||
"sep_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"shared_with": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
|
||||
@@ -30,9 +30,9 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
|
||||
"image_type": schema.StringAttribute{
|
||||
Required: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOf("linux", "windows", "other"),
|
||||
stringvalidator.OneOf("linux", "windows", "unknown"),
|
||||
},
|
||||
Description: "Image type linux, windows or other",
|
||||
Description: "Image type linux, windows or unknown",
|
||||
},
|
||||
"drivers": schema.ListAttribute{
|
||||
Required: true,
|
||||
@@ -167,7 +167,7 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
|
||||
"purge_attempts": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -184,6 +184,9 @@ func MakeSchemaResourceImage() map[string]schema.Attribute {
|
||||
"size": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -54,6 +54,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
|
||||
"compute_ci_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"cd_presented_to": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -98,6 +101,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
|
||||
"milestones": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"network_interface_naming": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -116,7 +122,7 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
|
||||
"purge_attempts": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -136,6 +142,9 @@ func MakeSchemaResourceImageVirtual() map[string]schema.Attribute {
|
||||
"size": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"snapshot_id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -73,6 +73,7 @@ func DataSourceK8s(ctx context.Context, state *models.RecordK8SDataSourceModel,
|
||||
CreatedTime: types.Int64Value(int64(cluster.CreatedTime)),
|
||||
DeletedBy: types.StringValue(cluster.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(cluster.DeletedTime)),
|
||||
Desc: types.StringValue(cluster.Description),
|
||||
ExtnetOnly: types.BoolValue(cluster.ExtnetOnly),
|
||||
HighlyAvailableLB: types.BoolValue(cluster.HighlyAvailableLB),
|
||||
K8CIName: types.StringValue(cluster.K8CIName),
|
||||
|
||||
@@ -57,20 +57,20 @@ func K8SCPResource(ctx context.Context, plan *models.ResourceK8SCPModel, c *clie
|
||||
NetworkPlugin: types.StringValue(cluster.NetworkPlugin),
|
||||
SEPID: plan.SEPID,
|
||||
SEPPool: plan.SEPPool,
|
||||
WithLB: plan.WithLB,
|
||||
HighlyAvailable: plan.HighlyAvailable,
|
||||
WithLB: types.BoolValue(cluster.WithLB),
|
||||
HighlyAvailable: types.BoolValue(cluster.HighlyAvailableLB),
|
||||
AdditionalSANs: plan.AdditionalSANs,
|
||||
InitConfiguration: plan.InitConfiguration,
|
||||
ClusterConfiguration: plan.ClusterConfiguration,
|
||||
KubeletConfiguration: plan.KubeletConfiguration,
|
||||
KubeProxyConfiguration: plan.KubeProxyConfiguration,
|
||||
JoinConfiguration: plan.JoinConfiguration,
|
||||
Description: plan.Description,
|
||||
ExtNetOnly: plan.ExtNetOnly,
|
||||
Description: types.StringValue(cluster.Description),
|
||||
ExtNetOnly: types.BoolValue(cluster.ExtnetOnly),
|
||||
OidcCertificate: plan.OidcCertificate,
|
||||
Chipset: plan.Chipset,
|
||||
Start: plan.Start,
|
||||
Enabled: plan.Enabled,
|
||||
Start: types.BoolValue(cluster.TechStatus == "STARTED"),
|
||||
Enabled: types.BoolValue(cluster.Status == "ENABLED"),
|
||||
Permanently: plan.Permanently,
|
||||
Restore: plan.Restore,
|
||||
Timeouts: plan.Timeouts,
|
||||
|
||||
@@ -49,7 +49,6 @@ func K8SWGResource(ctx context.Context, plan *models.ResourceK8SWGModel, c *clie
|
||||
CloudInit: plan.CloudInit,
|
||||
Timeouts: plan.Timeouts,
|
||||
Chipset: plan.Chipset,
|
||||
WorkerChipset: plan.WorkerChipset,
|
||||
Id: types.StringValue(strconv.Itoa(int(wg.ID))),
|
||||
WorkerGroupId: types.Int64Value(int64(wg.ID)),
|
||||
LastUpdated: plan.LastUpdated,
|
||||
|
||||
@@ -23,6 +23,7 @@ type RecordK8SDataSourceModel struct {
|
||||
HighlyAvailableLB types.Bool `tfsdk:"ha_mode"`
|
||||
K8SAddressVIP *K8SAddressVIP `tfsdk:"address_vip"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Desc types.String `tfsdk:"desc"`
|
||||
ExtNetID types.Int64 `tfsdk:"extnet_id"`
|
||||
K8CIName types.String `tfsdk:"k8sci_name"`
|
||||
Masters *MasterGroupDataSourceModel `tfsdk:"masters"`
|
||||
|
||||
@@ -11,7 +11,6 @@ type ResourceK8SWGModel struct {
|
||||
K8SID types.Int64 `tfsdk:"k8s_id"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
Num types.Int64 `tfsdk:"num"`
|
||||
WorkerChipset types.String `tfsdk:"worker_chipset"`
|
||||
CPU types.Int64 `tfsdk:"cpu"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
|
||||
@@ -185,7 +185,7 @@ func (r *resourceK8SCP) Update(ctx context.Context, req resource.UpdateRequest,
|
||||
}
|
||||
|
||||
// Update Name or/and Description cluster
|
||||
if !plan.Name.Equal(state.Name) || !plan.Description.Equal(state.Description) {
|
||||
if !plan.Name.Equal(state.Name) || (!plan.Description.Equal(state.Description) && !plan.Description.IsNull()) {
|
||||
resp.Diagnostics.Append(utilities.K8SCPUpdateNameOrDescription(ctx, &plan, &state, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Error update info")
|
||||
@@ -221,7 +221,7 @@ func (r *resourceK8SCP) Update(ctx context.Context, req resource.UpdateRequest,
|
||||
}
|
||||
|
||||
//Update LB params
|
||||
if (state.WithLB.IsNull() || state.WithLB.ValueBool()) && !plan.LBSysctlParams.Equal(state.LBSysctlParams) {
|
||||
if state.WithLB.ValueBool() && !plan.LBSysctlParams.Equal(state.LBSysctlParams) && !plan.LBSysctlParams.IsNull() {
|
||||
resp.Diagnostics.Append(utilities.K8CPUpdateSysctlParams(ctx, &plan, &state, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Error Update LB params")
|
||||
|
||||
@@ -119,6 +119,9 @@ func MakeSchemaDataSourceK8S() map[string]schema.Attribute {
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"extnet_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
|
||||
"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/int64planmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
|
||||
@@ -85,10 +86,14 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
|
||||
},
|
||||
"with_lb": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "Create k8s with load balancer if true.",
|
||||
},
|
||||
"ha_mode": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
Description: "Use Highly Available schema for LB deploy",
|
||||
},
|
||||
"additional_sans": schema.ListAttribute{
|
||||
@@ -118,10 +123,13 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Text description of this instance.",
|
||||
},
|
||||
"extnet_only": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
Description: "Use only selected ExtNet for infrastructure connections",
|
||||
},
|
||||
"oidc_cert": schema.StringAttribute{
|
||||
@@ -152,18 +160,26 @@ func MakeSchemaResourceK8SCP() map[string]schema.Attribute {
|
||||
// optional attributes for update
|
||||
"start": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
Description: "Start k8s cluster.",
|
||||
},
|
||||
"enabled": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "Enable k8s cluster",
|
||||
},
|
||||
"permanently": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "whether to completely delete the k8s cluster",
|
||||
},
|
||||
"restore": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(true),
|
||||
Description: "if true, restore the k8s cluster from Recycle Bin",
|
||||
},
|
||||
// computed attributes
|
||||
|
||||
@@ -29,13 +29,6 @@ func MakeSchemaResourceK8SWG() map[string]schema.Attribute {
|
||||
Computed: true,
|
||||
Description: "Number of worker nodes to create.",
|
||||
},
|
||||
"worker_chipset": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Description: "Type of the emulated system of worker nodes",
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOfCaseInsensitive("Q35", "i440fx"),
|
||||
},
|
||||
},
|
||||
"cpu": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
|
||||
@@ -219,7 +219,7 @@ func K8SWGUpdateNumWorkers(ctx context.Context, plan, state *models.ResourceK8SW
|
||||
K8SID: k8sId,
|
||||
WorkersGroupID: wg.ID,
|
||||
Num: uint64(newNum) - wg.Num,
|
||||
Chipset: plan.WorkerChipset.ValueString(),
|
||||
Chipset: plan.Chipset.ValueString(),
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Add workers in wg with id", map[string]any{"wg_id": state.WorkerGroupId.ValueInt64(), "k8s_id": state.K8SID.ValueInt64()})
|
||||
|
||||
@@ -51,6 +51,7 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
|
||||
Chipset: types.StringValue(computeRecord.Chipset),
|
||||
BootDiskSize: types.Int64Value(int64(computeRecord.BootDiskSize)),
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &computeRecord.BootOrder),
|
||||
BootType: types.StringValue(computeRecord.BootType),
|
||||
CdImageId: types.Int64Value(int64(computeRecord.CdImageId)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.Clones),
|
||||
CloneReference: types.Int64Value(int64(computeRecord.CloneReference)),
|
||||
@@ -69,10 +70,12 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
|
||||
GID: types.Int64Value(int64(computeRecord.GID)),
|
||||
GUID: types.Int64Value(int64(computeRecord.GUID)),
|
||||
HPBacked: types.BoolValue(computeRecord.HPBacked),
|
||||
HotResize: types.BoolValue(computeRecord.HotResize),
|
||||
ImageID: types.Int64Value(int64(computeRecord.ImageID)),
|
||||
ImageName: types.StringValue(computeRecord.ImageName),
|
||||
Interfaces: flattenInterfaces(ctx, &computeRecord.Interfaces),
|
||||
LockStatus: types.StringValue(computeRecord.LockStatus),
|
||||
LoaderType: types.StringValue(computeRecord.LoaderType),
|
||||
ManagerID: types.Int64Value(int64(computeRecord.ManagerID)),
|
||||
ManagerType: types.StringValue(computeRecord.ManagerType),
|
||||
MigrationJob: types.Int64Value(int64(computeRecord.MigrationJob)),
|
||||
@@ -84,32 +87,33 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
|
||||
NatableVINSNetwork: types.StringValue(computeRecord.NatableVINSNetwork),
|
||||
NatableVINSNetworkName: types.StringValue(computeRecord.NatableVINSNetworkName),
|
||||
NeedReboot: types.BoolValue(computeRecord.NeedReboot),
|
||||
NetworkInterfaceNaming: types.StringValue(computeRecord.NetworkInterfaceNaming),
|
||||
NumaAffinity: types.StringValue(computeRecord.NumaAffinity),
|
||||
NumaNodeId: types.Int64Value(int64(computeRecord.NumaNodeId)),
|
||||
OSUsers: flattenOSUsers(ctx, &computeRecord.OSUsers),
|
||||
Pinned: types.BoolValue(computeRecord.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.PreferredCPU),
|
||||
PCIDevices: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, flattenPCI(ctx, pciDevicesList)),
|
||||
RAM: types.Int64Value(int64(computeRecord.RAM)),
|
||||
ReferenceID: types.StringValue(computeRecord.ReferenceID),
|
||||
Registered: types.BoolValue(computeRecord.Registered),
|
||||
ResName: types.StringValue(computeRecord.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(computeRecord.RGID)),
|
||||
RGName: types.StringValue(computeRecord.RGName),
|
||||
SnapSets: flattenSnapSet(ctx, &computeRecord.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(computeRecord.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(computeRecord.StatelessSepType),
|
||||
Status: types.StringValue(computeRecord.Status),
|
||||
TechStatus: types.StringValue(computeRecord.TechStatus),
|
||||
UpdatedBy: types.StringValue(computeRecord.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(computeRecord.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(computeRecord.UserManaged),
|
||||
Userdata: types.StringValue(string(userdata)),
|
||||
VirtualImageID: types.Int64Value(int64(computeRecord.VirtualImageID)),
|
||||
VirtualImageName: types.StringValue(computeRecord.VirtualImageName),
|
||||
VNCPassword: types.StringValue(computeRecord.VNCPassword),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.VGPUs),
|
||||
//Pinned: types.BoolValue(computeRecord.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.PreferredCPU),
|
||||
PCIDevices: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, flattenPCI(ctx, pciDevicesList)),
|
||||
RAM: types.Int64Value(int64(computeRecord.RAM)),
|
||||
ReferenceID: types.StringValue(computeRecord.ReferenceID),
|
||||
Registered: types.BoolValue(computeRecord.Registered),
|
||||
ResName: types.StringValue(computeRecord.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &computeRecord.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(computeRecord.RGID)),
|
||||
RGName: types.StringValue(computeRecord.RGName),
|
||||
SnapSets: flattenSnapSet(ctx, &computeRecord.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(computeRecord.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(computeRecord.StatelessSepType),
|
||||
Status: types.StringValue(computeRecord.Status),
|
||||
TechStatus: types.StringValue(computeRecord.TechStatus),
|
||||
UpdatedBy: types.StringValue(computeRecord.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(computeRecord.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(computeRecord.UserManaged),
|
||||
Userdata: types.StringValue(string(userdata)),
|
||||
VirtualImageID: types.Int64Value(int64(computeRecord.VirtualImageID)),
|
||||
VirtualImageName: types.StringValue(computeRecord.VirtualImageName),
|
||||
VNCPassword: types.StringValue(computeRecord.VNCPassword),
|
||||
VGPUs: flattenComputeVGPU(ctx, computeRecord.VGPUs),
|
||||
}
|
||||
|
||||
state.Tags, diags = types.MapValueFrom(ctx, types.StringType, computeRecord.Tags)
|
||||
@@ -232,23 +236,24 @@ func flattenDisks(ctx context.Context, disks *compute.ListComputeDisks) []models
|
||||
StorageID: types.StringValue(item.Replication.StorageID),
|
||||
VolumeID: types.StringValue(item.Replication.VolumeID),
|
||||
},
|
||||
ResID: types.StringValue(item.ResID),
|
||||
Role: types.StringValue(item.Role),
|
||||
SepID: types.Int64Value(int64(item.SepID)),
|
||||
Shareable: types.BoolValue(item.Shareable),
|
||||
SizeMax: types.Int64Value(int64(item.SizeMax)),
|
||||
SizeUsed: types.Float64Value(item.SizeUsed),
|
||||
Snapshots: flattenSnapshotExtend(ctx, &item.Snapshots),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
Type: types.StringValue(item.Type),
|
||||
VMID: types.Int64Value(int64(item.VMID)),
|
||||
ResID: types.StringValue(item.ResID),
|
||||
Role: types.StringValue(item.Role),
|
||||
SepID: types.Int64Value(int64(item.SepID)),
|
||||
Shareable: types.BoolValue(item.Shareable),
|
||||
SizeAvailable: types.Float64Value(item.SizeAvailable),
|
||||
SizeMax: types.Int64Value(int64(item.SizeMax)),
|
||||
SizeUsed: types.Float64Value(item.SizeUsed),
|
||||
Snapshots: flattenSnapshotExtend(ctx, &item.Snapshots),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
Type: types.StringValue(item.Type),
|
||||
VMID: types.Int64Value(int64(item.VMID)),
|
||||
}
|
||||
temp.Images, diags = types.ListValueFrom(ctx, types.Int64Type, item.Images)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDisks", diags))
|
||||
}
|
||||
temp.PresentTo, diags = types.ListValueFrom(ctx, types.Int64Type, item.PresentTo)
|
||||
temp.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, item.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDisks", diags))
|
||||
}
|
||||
@@ -387,3 +392,36 @@ func flattenPCI(ctx context.Context, pciList *compute.ListPCIDevices) []uint64 {
|
||||
tflog.Info(ctx, "End flattenPCI")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputeVGPU(ctx context.Context, vgpuList []compute.VGPUItem) []models.VGPUModel {
|
||||
tflog.Info(ctx, "Start flattenVGPU")
|
||||
|
||||
res := make([]models.VGPUModel, 0, len(vgpuList))
|
||||
for _, item := range vgpuList {
|
||||
temp := models.VGPUModel{
|
||||
ID: types.Int64Value(int64(item.ID)),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
Type: types.StringValue(item.Type),
|
||||
Mode: types.StringValue(item.Mode),
|
||||
Status: types.StringValue(item.Status),
|
||||
ProfileID: types.Int64Value(int64(item.ProfileID)),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
LastUpdateTime: types.Int64Value(int64(item.LastUpdateTime)),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
VMID: types.Int64Value(int64(item.VMID)),
|
||||
PGPUID: types.Int64Value(int64(item.PGPuid)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
RGID: types.Int64Value(int64(item.RgID)),
|
||||
LastClaimedBy: types.Int64Value(int64(item.LastClaimedBy)),
|
||||
PCISlot: types.Int64Value(int64(item.PCISlot)),
|
||||
BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenVGPU")
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -65,69 +65,73 @@ func flattenItemsList(ctx context.Context, computes *compute.ListComputes) []mod
|
||||
customFields, _ := json.Marshal(item.CustomFields)
|
||||
devices, _ := json.Marshal(item.Devices)
|
||||
temp := models.ItemComputeModel{
|
||||
ACL: flattenACLInList(ctx, &item.ACL),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
AccountName: types.StringValue(item.AccountName),
|
||||
AffinityLabel: types.StringValue(item.AffinityLabel),
|
||||
AffinityRules: flattenAffinityRuleInList(ctx, &item.AffinityRules),
|
||||
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
|
||||
AntiAffinityRules: flattenAffinityRuleInList(ctx, &item.AntiAffinityRules),
|
||||
Architecture: types.StringValue(item.Architecture),
|
||||
AutoStartWithNode: types.BoolValue(item.AutoStart),
|
||||
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
|
||||
CdImageId: types.Int64Value(int64(item.CdImageId)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
|
||||
CloneReference: types.Int64Value(int64(item.CloneReference)),
|
||||
Chipset: types.StringValue(item.Chipset),
|
||||
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
|
||||
CPU: types.Int64Value(int64(item.CPU)),
|
||||
CPUPin: types.BoolValue(item.CPUPin),
|
||||
CreatedBy: types.StringValue(item.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Description: types.StringValue(item.Description),
|
||||
Devices: types.StringValue(string(devices)),
|
||||
Disks: flattenDisksInList(ctx, &item.Disks),
|
||||
Driver: types.StringValue(item.Driver),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
HPBacked: types.BoolValue(item.HPBacked),
|
||||
ComputeId: types.Int64Value(int64(item.ID)),
|
||||
ImageID: types.Int64Value(int64(item.ImageID)),
|
||||
Interfaces: flattenInterfaceInList(ctx, &item.Interfaces),
|
||||
LockStatus: types.StringValue(item.LockStatus),
|
||||
ManagerID: types.Int64Value(int64(item.ManagerID)),
|
||||
ManagerType: types.StringValue(item.ManagerType),
|
||||
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
Name: types.StringValue(item.Name),
|
||||
NeedReboot: types.BoolValue(item.NeedReboot),
|
||||
NumaAffinity: types.StringValue(item.NumaAffinity),
|
||||
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
|
||||
Pinned: types.BoolValue(item.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
Registered: types.BoolValue(item.Registered),
|
||||
ResName: types.StringValue(item.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
SnapSets: flattenSnapSetInList(ctx, &item.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(item.StatelessSepType),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
|
||||
UpdatedBy: types.StringValue(item.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(item.UserManaged),
|
||||
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
|
||||
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
|
||||
ACL: flattenACLInList(ctx, &item.ACL),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
AccountName: types.StringValue(item.AccountName),
|
||||
AffinityLabel: types.StringValue(item.AffinityLabel),
|
||||
AffinityRules: flattenAffinityRuleInList(ctx, &item.AffinityRules),
|
||||
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
|
||||
AntiAffinityRules: flattenAffinityRuleInList(ctx, &item.AntiAffinityRules),
|
||||
Architecture: types.StringValue(item.Architecture),
|
||||
AutoStartWithNode: types.BoolValue(item.AutoStart),
|
||||
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
|
||||
BootType: types.StringValue(item.BootType),
|
||||
CdImageId: types.Int64Value(int64(item.CdImageId)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
|
||||
CloneReference: types.Int64Value(int64(item.CloneReference)),
|
||||
Chipset: types.StringValue(item.Chipset),
|
||||
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
|
||||
CPU: types.Int64Value(int64(item.CPU)),
|
||||
CPUPin: types.BoolValue(item.CPUPin),
|
||||
CreatedBy: types.StringValue(item.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Description: types.StringValue(item.Description),
|
||||
Devices: types.StringValue(string(devices)),
|
||||
Disks: flattenDisksInList(ctx, &item.Disks),
|
||||
Driver: types.StringValue(item.Driver),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
HPBacked: types.BoolValue(item.HPBacked),
|
||||
HotResize: types.BoolValue(item.HotResize),
|
||||
ComputeId: types.Int64Value(int64(item.ID)),
|
||||
ImageID: types.Int64Value(int64(item.ImageID)),
|
||||
Interfaces: flattenInterfaceInList(ctx, &item.Interfaces),
|
||||
LockStatus: types.StringValue(item.LockStatus),
|
||||
LoaderType: types.StringValue(item.LoaderType),
|
||||
ManagerID: types.Int64Value(int64(item.ManagerID)),
|
||||
ManagerType: types.StringValue(item.ManagerType),
|
||||
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
Name: types.StringValue(item.Name),
|
||||
NeedReboot: types.BoolValue(item.NeedReboot),
|
||||
NetworkInterfaceNaming: types.StringValue(item.NetworkInterfaceNaming),
|
||||
NumaAffinity: types.StringValue(item.NumaAffinity),
|
||||
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
|
||||
//Pinned: types.BoolValue(item.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
Registered: types.BoolValue(item.Registered),
|
||||
ResName: types.StringValue(item.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
SnapSets: flattenSnapSetInList(ctx, &item.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(item.StatelessSepType),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
|
||||
UpdatedBy: types.StringValue(item.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(item.UserManaged),
|
||||
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
|
||||
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
|
||||
}
|
||||
|
||||
temp.Tags, diags = types.MapValueFrom(ctx, types.StringType, item.Tags)
|
||||
@@ -187,9 +191,9 @@ func flattenDisksInList(ctx context.Context, disks *compute.ListInfoDisks) []mod
|
||||
res := make([]models.DiskInListModel, 0, len(*disks))
|
||||
for _, item := range *disks {
|
||||
temp := models.DiskInListModel{
|
||||
BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
DiskId: types.Int64Value(int64(item.ID)),
|
||||
PCISlot: types.Int64Value(item.PCISlot),
|
||||
//BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
DiskId: types.Int64Value(int64(item.ID)),
|
||||
//PCISlot: types.Int64Value(item.PCISlot),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -63,69 +63,73 @@ func flattenItemsListDeleted(ctx context.Context, computes *compute.ListComputes
|
||||
customFields, _ := json.Marshal(item.CustomFields)
|
||||
devices, _ := json.Marshal(item.Devices)
|
||||
temp := models.ItemListDeletedComputeModel{
|
||||
ACL: flattenACLInListDeleted(ctx, &item.ACL),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
AccountName: types.StringValue(item.AccountName),
|
||||
AffinityLabel: types.StringValue(item.AffinityLabel),
|
||||
AffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AffinityRules),
|
||||
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
|
||||
AntiAffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AntiAffinityRules),
|
||||
Architecture: types.StringValue(item.Architecture),
|
||||
AutoStartWithNode: types.BoolValue(item.AutoStart),
|
||||
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
|
||||
CdImageId: types.Int64Value(int64(item.CdImageId)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
|
||||
Chipset: types.StringValue(item.Chipset),
|
||||
CloneReference: types.Int64Value(int64(item.CloneReference)),
|
||||
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
|
||||
CPU: types.Int64Value(int64(item.CPU)),
|
||||
CPUPin: types.BoolValue(item.CPUPin),
|
||||
CreatedBy: types.StringValue(item.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Description: types.StringValue(item.Description),
|
||||
Devices: types.StringValue(string(devices)),
|
||||
Disks: flattenDisksInListDeleted(ctx, &item.Disks),
|
||||
Driver: types.StringValue(item.Driver),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
HPBacked: types.BoolValue(item.HPBacked),
|
||||
ComputeId: types.Int64Value(int64(item.ID)),
|
||||
ImageID: types.Int64Value(int64(item.ImageID)),
|
||||
Interfaces: flattenInterfaceInListDeleted(ctx, &item.Interfaces),
|
||||
LockStatus: types.StringValue(item.LockStatus),
|
||||
ManagerID: types.Int64Value(int64(item.ManagerID)),
|
||||
ManagerType: types.StringValue(item.ManagerType),
|
||||
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
Name: types.StringValue(item.Name),
|
||||
NeedReboot: types.BoolValue(item.NeedReboot),
|
||||
NumaAffinity: types.StringValue(item.NumaAffinity),
|
||||
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
|
||||
Pinned: types.BoolValue(item.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
Registered: types.BoolValue(item.Registered),
|
||||
ResName: types.StringValue(item.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
SnapSets: flattenSnapSetInListDeleted(ctx, &item.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(item.StatelessSepType),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
|
||||
UpdatedBy: types.StringValue(item.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(item.UserManaged),
|
||||
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
|
||||
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
|
||||
ACL: flattenACLInListDeleted(ctx, &item.ACL),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
AccountName: types.StringValue(item.AccountName),
|
||||
AffinityLabel: types.StringValue(item.AffinityLabel),
|
||||
AffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AffinityRules),
|
||||
AffinityWeight: types.Int64Value(int64(item.AffinityWeight)),
|
||||
AntiAffinityRules: flattenAffinityRuleInListDeleted(ctx, &item.AntiAffinityRules),
|
||||
Architecture: types.StringValue(item.Architecture),
|
||||
AutoStartWithNode: types.BoolValue(item.AutoStart),
|
||||
BootDiskSize: types.Int64Value(int64(item.BootDiskSize)),
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, &item.BootOrder),
|
||||
BootType: types.StringValue(item.BootType),
|
||||
CdImageId: types.Int64Value(int64(item.CdImageId)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.Clones),
|
||||
Chipset: types.StringValue(item.Chipset),
|
||||
CloneReference: types.Int64Value(int64(item.CloneReference)),
|
||||
ComputeCIID: types.Int64Value(int64(item.ComputeCIID)),
|
||||
CPU: types.Int64Value(int64(item.CPU)),
|
||||
CPUPin: types.BoolValue(item.CPUPin),
|
||||
CreatedBy: types.StringValue(item.CreatedBy),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
DeletedBy: types.StringValue(item.DeletedBy),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
Description: types.StringValue(item.Description),
|
||||
Devices: types.StringValue(string(devices)),
|
||||
Disks: flattenDisksInListDeleted(ctx, &item.Disks),
|
||||
Driver: types.StringValue(item.Driver),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
HPBacked: types.BoolValue(item.HPBacked),
|
||||
HotResize: types.BoolValue(item.HotResize),
|
||||
ComputeId: types.Int64Value(int64(item.ID)),
|
||||
ImageID: types.Int64Value(int64(item.ImageID)),
|
||||
Interfaces: flattenInterfaceInListDeleted(ctx, &item.Interfaces),
|
||||
LockStatus: types.StringValue(item.LockStatus),
|
||||
LoaderType: types.StringValue(item.LoaderType),
|
||||
ManagerID: types.Int64Value(int64(item.ManagerID)),
|
||||
ManagerType: types.StringValue(item.ManagerType),
|
||||
MigrationJob: types.Int64Value(int64(item.MigrationJob)),
|
||||
Milestones: types.Int64Value(int64(item.Milestones)),
|
||||
Name: types.StringValue(item.Name),
|
||||
NeedReboot: types.BoolValue(item.NeedReboot),
|
||||
NetworkInterfaceNaming: types.StringValue(item.NetworkInterfaceNaming),
|
||||
NumaAffinity: types.StringValue(item.NumaAffinity),
|
||||
NumaNodeId: types.Int64Value(int64(item.NumaNodeId)),
|
||||
//Pinned: types.BoolValue(item.Pinned),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.PreferredCPU),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
Registered: types.BoolValue(item.Registered),
|
||||
ResName: types.StringValue(item.ResName),
|
||||
ReservedNodeCpus: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.ReservedNodeCpus),
|
||||
RGID: types.Int64Value(int64(item.RGID)),
|
||||
RGName: types.StringValue(item.RGName),
|
||||
SnapSets: flattenSnapSetInListDeleted(ctx, &item.SnapSets),
|
||||
StatelessSepID: types.Int64Value(int64(item.StatelessSepID)),
|
||||
StatelessSepType: types.StringValue(item.StatelessSepType),
|
||||
Status: types.StringValue(item.Status),
|
||||
TechStatus: types.StringValue(item.TechStatus),
|
||||
TotalDiskSize: types.Int64Value(int64(item.TotalDiskSize)),
|
||||
UpdatedBy: types.StringValue(item.UpdatedBy),
|
||||
UpdatedTime: types.Int64Value(int64(item.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(item.UserManaged),
|
||||
VINSConnected: types.Int64Value(int64(item.VINSConnected)),
|
||||
VirtualImageID: types.Int64Value(int64(item.VirtualImageID)),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, &item.VGPUs),
|
||||
}
|
||||
|
||||
temp.Tags, diags = types.MapValueFrom(ctx, types.StringType, item.Tags)
|
||||
@@ -185,9 +189,9 @@ func flattenDisksInListDeleted(ctx context.Context, disks *compute.ListInfoDisks
|
||||
res := make([]models.DiskInListDeletedModel, 0, len(*disks))
|
||||
for _, item := range *disks {
|
||||
temp := models.DiskInListDeletedModel{
|
||||
BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
DiskId: types.Int64Value(int64(item.ID)),
|
||||
PCISlot: types.Int64Value(item.PCISlot),
|
||||
//BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
DiskId: types.Int64Value(int64(item.ID)),
|
||||
//PCISlot: types.Int64Value(item.PCISlot),
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,24 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
}
|
||||
pfwList, err := utilities.ComputeResourcePFWListGet(ctx, recordItemCompute.ID, c)
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
diags.AddError("ComputeResourcePFWListGet error: ", err.Error())
|
||||
tflog.Error(ctx, fmt.Sprint("ComputeResourcePFWListGet error ", err))
|
||||
}
|
||||
}
|
||||
|
||||
userList, err := utilities.ComputeResourceUserAccessGet(ctx, recordItemCompute.ID, c)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprintf("Error getting user list: %v", err))
|
||||
}
|
||||
|
||||
pciDevicesList, err := utilities.ResourceComputePCIDevicesListCheckPresence(ctx, recordItemCompute.ID, c)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprintf("Error getting pci list: %v", err))
|
||||
}
|
||||
|
||||
bootdisk := findBootDisk(recordItemCompute.Disks)
|
||||
devices, _ := json.Marshal(recordItemCompute.Devices)
|
||||
userdata, _ := json.Marshal(recordItemCompute.Userdata)
|
||||
@@ -32,57 +50,58 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
|
||||
*plan = models.ResourceComputeModel{
|
||||
// required fields
|
||||
Name: plan.Name,
|
||||
RGID: plan.RGID,
|
||||
Driver: plan.Driver,
|
||||
CPU: plan.CPU,
|
||||
RAM: plan.RAM,
|
||||
ID: plan.ID,
|
||||
Name: types.StringValue(recordItemCompute.Name),
|
||||
RGID: types.Int64Value(int64(recordItemCompute.RGID)),
|
||||
Driver: types.StringValue(recordItemCompute.Driver),
|
||||
CPU: types.Int64Value(int64(recordItemCompute.CPU)),
|
||||
RAM: types.Int64Value(int64(recordItemCompute.RAM)),
|
||||
Timeouts: plan.Timeouts,
|
||||
|
||||
// optional fields
|
||||
ImageID: plan.ImageID,
|
||||
ImageID: types.Int64Value(int64(bootdisk.ImageID)),
|
||||
WithoutBootDisk: plan.WithoutBootDisk,
|
||||
// we intentionally use the SizeMax field, do not change it until the BootDiskSize field is fixed on the platform
|
||||
BootDiskSize: types.Int64Value(int64(bootdisk.SizeMax)),
|
||||
AffinityLabel: types.StringValue(recordItemCompute.AffinityLabel),
|
||||
AffinityRules: plan.AffinityRules,
|
||||
AntiAffinityRules: plan.AntiAffinityRules,
|
||||
AutoStartWithNode: types.BoolValue(recordItemCompute.AutoStart),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
Chipset: types.StringValue(recordItemCompute.Chipset),
|
||||
Stateless: plan.Stateless,
|
||||
SepId: types.Int64Value(int64(bootdisk.SepID)),
|
||||
Pool: types.StringValue(bootdisk.Pool),
|
||||
ExtraDisks: plan.ExtraDisks,
|
||||
Network: flattenNetwork(ctx, plan.Network, &recordItemCompute.Interfaces),
|
||||
Tags: plan.Tags,
|
||||
PortForwarding: plan.PortForwarding,
|
||||
UserAccess: plan.UserAccess,
|
||||
Snapshot: plan.Snapshot,
|
||||
PCIDevices: plan.PCIDevices,
|
||||
Rollback: plan.Rollback,
|
||||
CD: plan.CD,
|
||||
PinToStack: plan.PinToStack,
|
||||
Description: types.StringValue(recordItemCompute.Description),
|
||||
CloudInit: plan.CloudInit,
|
||||
Enabled: plan.Enabled,
|
||||
Pause: plan.Pause,
|
||||
Reset: plan.Reset,
|
||||
Restore: plan.Restore,
|
||||
AutoStart: plan.AutoStart,
|
||||
ForceStop: plan.ForceStop,
|
||||
ForceResize: plan.ForceResize,
|
||||
DataDisks: plan.DataDisks,
|
||||
Started: plan.Started,
|
||||
DetachDisks: plan.DetachDisks,
|
||||
Permanently: plan.Permanently,
|
||||
IS: plan.IS,
|
||||
IpaType: plan.IpaType,
|
||||
NumaAffinity: plan.NumaAffinity,
|
||||
CPUPin: plan.CPUPin,
|
||||
HPBacked: plan.HPBacked,
|
||||
BootDiskSize: types.Int64Value(int64(bootdisk.SizeMax)),
|
||||
AffinityLabel: types.StringValue(recordItemCompute.AffinityLabel),
|
||||
AffinityRules: flattenComputeAffinityRule(ctx, &recordItemCompute.AffinityRules),
|
||||
AntiAffinityRules: flattenComputeAffinityRule(ctx, &recordItemCompute.AntiAffinityRules),
|
||||
AutoStartWithNode: types.BoolValue(recordItemCompute.AutoStart),
|
||||
CustomFields: types.StringValue(string(customFields)),
|
||||
Chipset: types.StringValue(recordItemCompute.Chipset),
|
||||
SepId: types.Int64Value(int64(bootdisk.SepID)),
|
||||
Pool: types.StringValue(bootdisk.Pool),
|
||||
ExtraDisks: plan.ExtraDisks,
|
||||
Network: flattenNetwork(ctx, plan.Network, &recordItemCompute.Interfaces),
|
||||
Tags: flattenComputeTags(ctx, recordItemCompute.Tags),
|
||||
PortForwarding: flattenComputePortForwarding(ctx, pfwList.Data),
|
||||
UserAccess: flattenUserAccess(ctx, userList),
|
||||
Snapshot: plan.Snapshot,
|
||||
PCIDevices: flattens.FlattenSimpleTypeToSet(ctx, types.Int64Type, flattenPCIDevices(ctx, pciDevicesList)),
|
||||
Rollback: plan.Rollback,
|
||||
CDImageID: types.Int64Value(int64(recordItemCompute.CdImageId)),
|
||||
PinToStack: types.BoolValue(recordItemCompute.PinnedToStack),
|
||||
Description: types.StringValue(recordItemCompute.Description),
|
||||
CloudInit: plan.CloudInit,
|
||||
Enabled: types.BoolValue(recordItemCompute.Status == "ENABLED"),
|
||||
Pause: types.BoolValue(recordItemCompute.TechStatus == "PAUSED"),
|
||||
Reset: plan.Reset,
|
||||
Restore: plan.Restore,
|
||||
ForceStop: plan.ForceStop,
|
||||
ForceResize: plan.ForceResize,
|
||||
Started: types.BoolValue(recordItemCompute.TechStatus == "STARTED"),
|
||||
DetachDisks: plan.DetachDisks,
|
||||
Permanently: plan.Permanently,
|
||||
IS: plan.IS,
|
||||
IpaType: plan.IpaType,
|
||||
NumaAffinity: types.StringValue(recordItemCompute.NumaAffinity),
|
||||
CPUPin: types.BoolValue(recordItemCompute.CPUPin),
|
||||
HPBacked: types.BoolValue(recordItemCompute.HPBacked),
|
||||
SnapshotDeleteAsync: plan.SnapshotDeleteAsync,
|
||||
|
||||
LoaderType: types.StringValue(recordItemCompute.LoaderType),
|
||||
BootType: types.StringValue(recordItemCompute.BootType),
|
||||
HotResize: types.BoolValue(recordItemCompute.HotResize),
|
||||
NetworkInterfaceNaming: types.StringValue(recordItemCompute.NetworkInterfaceNaming),
|
||||
//computed fields
|
||||
AccountId: types.Int64Value(int64(recordItemCompute.AccountID)),
|
||||
AccountName: types.StringValue(recordItemCompute.AccountName),
|
||||
@@ -92,7 +111,6 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
BootOrder: flattens.FlattenSimpleTypeToList(ctx, types.StringType, recordItemCompute.BootOrder),
|
||||
BootDisk: flattenDisk(ctx, bootdisk),
|
||||
BootDiskId: types.Int64Value(int64(bootdisk.ID)),
|
||||
CdImageId: types.Int64Value(int64(recordItemCompute.CdImageId)),
|
||||
CloneReference: types.Int64Value(int64(recordItemCompute.CloneReference)),
|
||||
Clones: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.Clones),
|
||||
ComputeCIID: types.Int64Value(int64(recordItemCompute.ComputeCIID)),
|
||||
@@ -105,6 +123,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
Disks: flattenResourceDisks(ctx, &recordItemCompute.Disks),
|
||||
GID: types.Int64Value(int64(recordItemCompute.GID)),
|
||||
GUID: types.Int64Value(int64(recordItemCompute.GUID)),
|
||||
ID: plan.ID,
|
||||
ImageName: types.StringValue(recordItemCompute.ImageName),
|
||||
Interfaces: flattenResourceInterfaces(ctx, &recordItemCompute.Interfaces),
|
||||
LockStatus: types.StringValue(recordItemCompute.LockStatus),
|
||||
@@ -120,7 +139,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
NeedReboot: types.BoolValue(recordItemCompute.NeedReboot),
|
||||
NumaNodeId: types.Int64Value(int64(recordItemCompute.NumaNodeId)),
|
||||
OSUsers: flattenResourceOSUsers(ctx, &recordItemCompute.OSUsers),
|
||||
Pinned: types.BoolValue(recordItemCompute.Pinned),
|
||||
Pinned: types.BoolValue(recordItemCompute.PinnedToStack),
|
||||
PreferredCPU: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.PreferredCPU),
|
||||
ReferenceID: types.StringValue(recordItemCompute.ReferenceID),
|
||||
Registered: types.BoolValue(recordItemCompute.Registered),
|
||||
@@ -136,7 +155,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
|
||||
UpdatedTime: types.Int64Value(int64(recordItemCompute.UpdatedTime)),
|
||||
UserManaged: types.BoolValue(recordItemCompute.UserManaged),
|
||||
Userdata: types.StringValue(string(userdata)),
|
||||
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.VGPUs),
|
||||
VGPUs: flattenResourceComputeVGPU(ctx, recordItemCompute.VGPUs),
|
||||
VirtualImageID: types.Int64Value(int64(recordItemCompute.VirtualImageID)),
|
||||
VirtualImageName: types.StringValue(recordItemCompute.VirtualImageName),
|
||||
VNCPassword: types.StringValue(recordItemCompute.VNCPassword),
|
||||
@@ -204,9 +223,10 @@ func flattenACLItems(ctx context.Context, item *compute.ListACL) types.List {
|
||||
func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Object {
|
||||
tflog.Info(ctx, fmt.Sprintf("flattenDisk: start flatten disk with ID - %v", disk.ID))
|
||||
|
||||
diags := diag.Diagnostics{}
|
||||
|
||||
acl, _ := json.Marshal(disk.ACL)
|
||||
temp := models.ItemResourceDiskModel{
|
||||
CKey: types.StringValue(disk.CKey),
|
||||
ACL: types.StringValue(string(acl)),
|
||||
AccountID: types.Int64Value(int64(disk.AccountID)),
|
||||
BootPartition: types.Int64Value(int64(disk.BootPartition)),
|
||||
@@ -220,7 +240,7 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
|
||||
GUID: types.Int64Value(int64(disk.GUID)),
|
||||
ID: types.Int64Value(int64(disk.ID)),
|
||||
ImageID: types.Int64Value(int64(disk.ImageID)),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.StringType, disk.Images),
|
||||
Images: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, disk.Images),
|
||||
IOTune: flattensIOTune(ctx, &disk.IOTune),
|
||||
IQN: types.StringValue(disk.IQN),
|
||||
Login: types.StringValue(disk.Login),
|
||||
@@ -232,7 +252,6 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
|
||||
Passwd: types.StringValue(disk.Passwd),
|
||||
Pool: types.StringValue(disk.Pool),
|
||||
PCISlot: types.Int64Value(disk.PCISlot),
|
||||
PresentTo: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, disk.PresentTo),
|
||||
PurgeTime: types.Int64Value(int64(disk.PurgeTime)),
|
||||
RealityDeviceNumber: types.Int64Value(int64(disk.RealityDeviceNumber)),
|
||||
Replication: flattenDiskReplication(ctx, &disk.Replication),
|
||||
@@ -249,9 +268,14 @@ func flattenDisk(ctx context.Context, disk *compute.ItemComputeDisk) types.Objec
|
||||
VMID: types.Int64Value(int64(disk.VMID)),
|
||||
}
|
||||
|
||||
res, err := types.ObjectValueFrom(ctx, models.ItemDisk, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDisk struct to obj", err))
|
||||
temp.PresentTo, diags = types.MapValueFrom(ctx, types.Int64Type, disk.PresentTo)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenPresentTo", diags))
|
||||
}
|
||||
|
||||
res, diags := types.ObjectValueFrom(ctx, models.ItemDisk, temp)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenDisk struct to obj", diags))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, fmt.Sprintf("flattenDisk: end flatten disk with ID - %v", disk.ID))
|
||||
@@ -537,3 +561,165 @@ func flattenNetworkWeight(ctx context.Context, networks types.Set, item compute.
|
||||
tflog.Info(ctx, "End flattenNetworkWeight")
|
||||
return types.Int64Value(0)
|
||||
}
|
||||
|
||||
func flattenComputeAffinityRule(ctx context.Context, rules *compute.ListRules) types.Set {
|
||||
tflog.Info(ctx, "Start flattenAffinityRule")
|
||||
|
||||
tempSlice := make([]types.Object, 0, len(*rules))
|
||||
for _, item := range *rules {
|
||||
temp := models.ItemResourceRulesModel{
|
||||
Key: types.StringValue(item.Key),
|
||||
Mode: types.StringValue(item.Mode),
|
||||
Policy: types.StringValue(item.Policy),
|
||||
Topology: types.StringValue(item.Topology),
|
||||
Value: types.StringValue(item.Value),
|
||||
}
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ItemResourceRules, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputeAffinityRule struct to obj", err))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemResourceRules}, tempSlice)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputeAffinityRule", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenAffinityRule")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputeTags(ctx context.Context, tags map[string]string) types.Set {
|
||||
tflog.Info(ctx, "Start flattenComputeTags")
|
||||
|
||||
tempSlice := make([]types.Object, 0, len(tags))
|
||||
for key, value := range tags {
|
||||
temp := models.ItemTagModel{
|
||||
Key: types.StringValue(key),
|
||||
Value: types.StringValue(value),
|
||||
}
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ItemTag, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputeTags struct to obj", err))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemTag}, tempSlice)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputeTags", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenComputeTags")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenComputePortForwarding(ctx context.Context, list []compute.ItemPFW) types.Set {
|
||||
tflog.Info(ctx, "Start flattenComputePortForwarding")
|
||||
|
||||
tempSlice := make([]types.Object, 0, len(list))
|
||||
for _, item := range list {
|
||||
temp := models.ItemPortForfardingModel{
|
||||
PublicPortStart: types.Int64Value(int64(item.PublicPortStart)),
|
||||
PublicPortEnd: types.Int64Value(int64(item.PublicPortEnd)),
|
||||
LocalPort: types.Int64Value(int64(item.LocalPort)),
|
||||
Proto: types.StringValue(item.Protocol),
|
||||
}
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ItemPortForfarding, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputePortForwarding struct to obj", err))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, err := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemPortForfarding}, tempSlice)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenComputePortForwarding", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenComputePortForwarding")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenUserAccess(ctx context.Context, userList *compute.ListUsers) types.Set {
|
||||
tflog.Info(ctx, "Start flattenUserAccess")
|
||||
tempSlice := make([]types.Object, 0)
|
||||
|
||||
// Process compute ACL
|
||||
for _, item := range userList.Data.ComputeACL {
|
||||
temp := models.UserAccessModel{
|
||||
Username: types.StringValue(item.UserGroupID),
|
||||
AccessType: types.StringValue(item.Right),
|
||||
}
|
||||
obj, diags := types.ObjectValueFrom(ctx, models.ItemUserAccess, temp)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenUserAccess struct to obj", diags))
|
||||
continue
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, diags := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.ItemUserAccess}, tempSlice)
|
||||
if diags != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error flattenUserAccess", diags))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenUserAccess")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenPCIDevices(ctx context.Context, pciList *compute.ListPCIDevices) []uint64 {
|
||||
tflog.Info(ctx, "Start flattenPCI")
|
||||
res := make([]uint64, 0, len(pciList.Data))
|
||||
|
||||
for _, v := range pciList.Data {
|
||||
res = append(res, v.ID)
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenPCI")
|
||||
return res
|
||||
}
|
||||
|
||||
func flattenResourceComputeVGPU(ctx context.Context, vgpuList []compute.VGPUItem) types.List {
|
||||
tflog.Info(ctx, "Start flattenVGPU")
|
||||
tempSlice := make([]types.Object, 0, len(vgpuList))
|
||||
|
||||
for _, item := range vgpuList {
|
||||
temp := models.ComputeVGPUModel{
|
||||
ID: types.Int64Value(int64(item.ID)),
|
||||
GID: types.Int64Value(int64(item.GID)),
|
||||
Type: types.StringValue(item.Type),
|
||||
Mode: types.StringValue(item.Mode),
|
||||
Status: types.StringValue(item.Status),
|
||||
ProfileID: types.Int64Value(int64(item.ProfileID)),
|
||||
RAM: types.Int64Value(int64(item.RAM)),
|
||||
LastUpdateTime: types.Int64Value(int64(item.LastUpdateTime)),
|
||||
CreatedTime: types.Int64Value(int64(item.CreatedTime)),
|
||||
DeletedTime: types.Int64Value(int64(item.DeletedTime)),
|
||||
VMID: types.Int64Value(int64(item.VMID)),
|
||||
PGPUID: types.Int64Value(int64(item.PGPuid)),
|
||||
ReferenceID: types.StringValue(item.ReferenceID),
|
||||
AccountID: types.Int64Value(int64(item.AccountID)),
|
||||
RGID: types.Int64Value(int64(item.RgID)),
|
||||
LastClaimedBy: types.Int64Value(int64(item.LastClaimedBy)),
|
||||
PCISlot: types.Int64Value(int64(item.PCISlot)),
|
||||
BusNumber: types.Int64Value(int64(item.BusNumber)),
|
||||
GUID: types.Int64Value(int64(item.GUID)),
|
||||
}
|
||||
|
||||
obj, err := types.ObjectValueFrom(ctx, models.ComputeItemVGPU, temp)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error converting VGPU model to object", err))
|
||||
}
|
||||
tempSlice = append(tempSlice, obj)
|
||||
}
|
||||
|
||||
res, err := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.ComputeItemVGPU}, tempSlice)
|
||||
if err != nil {
|
||||
tflog.Error(ctx, fmt.Sprint("Error creating VGPU list value", err))
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattenVGPU")
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -79,10 +79,14 @@ type RecordComputeModel struct {
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
UserManaged types.Bool `tfsdk:"user_managed"`
|
||||
Userdata types.String `tfsdk:"user_data"`
|
||||
VGPUs types.List `tfsdk:"vgpus"`
|
||||
VGPUs []VGPUModel `tfsdk:"vgpus"`
|
||||
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
|
||||
VirtualImageName types.String `tfsdk:"virtual_image_name"`
|
||||
VNCPassword types.String `tfsdk:"vnc_password"`
|
||||
LoaderType types.String `tfsdk:"loader_type"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
}
|
||||
|
||||
type RecordACLModel struct {
|
||||
@@ -136,7 +140,7 @@ type ItemDiskModel struct {
|
||||
Passwd types.String `tfsdk:"passwd"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
RealityDeviceNumber types.Int64 `tfsdk:"reality_device_number"`
|
||||
@@ -145,6 +149,7 @@ type ItemDiskModel struct {
|
||||
Role types.String `tfsdk:"role"`
|
||||
SepID types.Int64 `tfsdk:"sep_id"`
|
||||
Shareable types.Bool `tfsdk:"shareable"`
|
||||
SizeAvailable types.Float64 `tfsdk:"size_available"`
|
||||
SizeMax types.Int64 `tfsdk:"size_max"`
|
||||
SizeUsed types.Float64 `tfsdk:"size_used"`
|
||||
Snapshots []ItemSnapshotExtendModel `tfsdk:"snapshots"`
|
||||
@@ -244,3 +249,25 @@ type ReplicationModel struct {
|
||||
StorageID types.String `tfsdk:"storage_id"`
|
||||
VolumeID types.String `tfsdk:"volume_id"`
|
||||
}
|
||||
|
||||
type VGPUModel struct {
|
||||
ID types.Int64 `tfsdk:"id"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
Type types.String `tfsdk:"type"`
|
||||
Mode types.String `tfsdk:"mode"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
ProfileID types.Int64 `tfsdk:"profile_id"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
LastUpdateTime types.Int64 `tfsdk:"last_update_time"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
VMID types.Int64 `tfsdk:"vmid"`
|
||||
PGPUID types.Int64 `tfsdk:"pgpuid"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
LastClaimedBy types.Int64 `tfsdk:"last_claimed_by"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
BusNumber types.Int64 `tfsdk:"bus_number"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
}
|
||||
|
||||
@@ -30,70 +30,74 @@ type ListComputesModel struct {
|
||||
}
|
||||
|
||||
type ItemComputeModel struct {
|
||||
ACL []ItemACLInListModel `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules []ItemRuleInListModel `tfsdk:"affinity_rules"`
|
||||
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
|
||||
AntiAffinityRules []ItemRuleInListModel `tfsdk:"anti_affinity_rules"`
|
||||
Architecture types.String `tfsdk:"arch"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
BootOrder types.List `tfsdk:"boot_order"`
|
||||
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
|
||||
CdImageId types.Int64 `tfsdk:"cd_image_id"`
|
||||
CloneReference types.Int64 `tfsdk:"clone_reference"`
|
||||
Clones types.List `tfsdk:"clones"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
|
||||
CPU types.Int64 `tfsdk:"cpus"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Devices types.String `tfsdk:"devices"`
|
||||
Disks []DiskInListModel `tfsdk:"disks"`
|
||||
Driver types.String `tfsdk:"driver"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
ComputeId types.Int64 `tfsdk:"compute_id"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Interfaces []ItemVNFInterfaceInListModel `tfsdk:"interfaces"`
|
||||
LockStatus types.String `tfsdk:"lock_status"`
|
||||
ManagerID types.Int64 `tfsdk:"manager_id"`
|
||||
ManagerType types.String `tfsdk:"manager_type"`
|
||||
MigrationJob types.Int64 `tfsdk:"migrationjob"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
NeedReboot types.Bool `tfsdk:"need_reboot"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
|
||||
Pinned types.Bool `tfsdk:"pinned"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
Registered types.Bool `tfsdk:"registered"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
RGName types.String `tfsdk:"rg_name"`
|
||||
SnapSets []ItemSnapSetInListModel `tfsdk:"snap_sets"`
|
||||
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
|
||||
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Tags types.Map `tfsdk:"tags"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
UserManaged types.Bool `tfsdk:"user_managed"`
|
||||
VGPUs types.List `tfsdk:"vgpus"`
|
||||
VINSConnected types.Int64 `tfsdk:"vins_connected"`
|
||||
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
|
||||
ACL []ItemACLInListModel `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules []ItemRuleInListModel `tfsdk:"affinity_rules"`
|
||||
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
|
||||
AntiAffinityRules []ItemRuleInListModel `tfsdk:"anti_affinity_rules"`
|
||||
Architecture types.String `tfsdk:"arch"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
BootOrder types.List `tfsdk:"boot_order"`
|
||||
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
|
||||
CdImageId types.Int64 `tfsdk:"cd_image_id"`
|
||||
CloneReference types.Int64 `tfsdk:"clone_reference"`
|
||||
Clones types.List `tfsdk:"clones"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
|
||||
CPU types.Int64 `tfsdk:"cpus"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Devices types.String `tfsdk:"devices"`
|
||||
Disks []DiskInListModel `tfsdk:"disks"`
|
||||
Driver types.String `tfsdk:"driver"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
ComputeId types.Int64 `tfsdk:"compute_id"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Interfaces []ItemVNFInterfaceInListModel `tfsdk:"interfaces"`
|
||||
LockStatus types.String `tfsdk:"lock_status"`
|
||||
ManagerID types.Int64 `tfsdk:"manager_id"`
|
||||
ManagerType types.String `tfsdk:"manager_type"`
|
||||
MigrationJob types.Int64 `tfsdk:"migrationjob"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
NeedReboot types.Bool `tfsdk:"need_reboot"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
|
||||
Pinned types.Bool `tfsdk:"pinned"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
Registered types.Bool `tfsdk:"registered"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
RGName types.String `tfsdk:"rg_name"`
|
||||
SnapSets []ItemSnapSetInListModel `tfsdk:"snap_sets"`
|
||||
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
|
||||
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Tags types.Map `tfsdk:"tags"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
UserManaged types.Bool `tfsdk:"user_managed"`
|
||||
VGPUs types.List `tfsdk:"vgpus"`
|
||||
VINSConnected types.Int64 `tfsdk:"vins_connected"`
|
||||
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
|
||||
LoaderType types.String `tfsdk:"loader_type"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
}
|
||||
|
||||
type ItemACLInListModel struct {
|
||||
|
||||
@@ -28,70 +28,74 @@ type ListDeletedComputesModel struct {
|
||||
}
|
||||
|
||||
type ItemListDeletedComputeModel struct {
|
||||
ACL []ItemACLInListDeletedModel `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules []ItemRuleInListDeletedModel `tfsdk:"affinity_rules"`
|
||||
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
|
||||
AntiAffinityRules []ItemRuleInListDeletedModel `tfsdk:"anti_affinity_rules"`
|
||||
Architecture types.String `tfsdk:"arch"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
BootOrder types.List `tfsdk:"boot_order"`
|
||||
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
|
||||
CdImageId types.Int64 `tfsdk:"cd_image_id"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
CloneReference types.Int64 `tfsdk:"clone_reference"`
|
||||
Clones types.List `tfsdk:"clones"`
|
||||
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
|
||||
CPU types.Int64 `tfsdk:"cpus"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Devices types.String `tfsdk:"devices"`
|
||||
Disks []DiskInListDeletedModel `tfsdk:"disks"`
|
||||
Driver types.String `tfsdk:"driver"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
ComputeId types.Int64 `tfsdk:"compute_id"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Interfaces []ItemVNFInterfaceInListDeletedModel `tfsdk:"interfaces"`
|
||||
LockStatus types.String `tfsdk:"lock_status"`
|
||||
ManagerID types.Int64 `tfsdk:"manager_id"`
|
||||
ManagerType types.String `tfsdk:"manager_type"`
|
||||
MigrationJob types.Int64 `tfsdk:"migrationjob"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
NeedReboot types.Bool `tfsdk:"need_reboot"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
|
||||
Pinned types.Bool `tfsdk:"pinned"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
Registered types.Bool `tfsdk:"registered"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
RGName types.String `tfsdk:"rg_name"`
|
||||
SnapSets []ItemSnapSetInListDeletedModel `tfsdk:"snap_sets"`
|
||||
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
|
||||
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Tags types.Map `tfsdk:"tags"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
UserManaged types.Bool `tfsdk:"user_managed"`
|
||||
VGPUs types.List `tfsdk:"vgpus"`
|
||||
VINSConnected types.Int64 `tfsdk:"vins_connected"`
|
||||
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
|
||||
ACL []ItemACLInListDeletedModel `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
AccountName types.String `tfsdk:"account_name"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules []ItemRuleInListDeletedModel `tfsdk:"affinity_rules"`
|
||||
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
|
||||
AntiAffinityRules []ItemRuleInListDeletedModel `tfsdk:"anti_affinity_rules"`
|
||||
Architecture types.String `tfsdk:"arch"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
BootOrder types.List `tfsdk:"boot_order"`
|
||||
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
|
||||
CdImageId types.Int64 `tfsdk:"cd_image_id"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
CloneReference types.Int64 `tfsdk:"clone_reference"`
|
||||
Clones types.List `tfsdk:"clones"`
|
||||
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
|
||||
CPU types.Int64 `tfsdk:"cpus"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
CreatedBy types.String `tfsdk:"created_by"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
DeletedBy types.String `tfsdk:"deleted_by"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
Description types.String `tfsdk:"desc"`
|
||||
Devices types.String `tfsdk:"devices"`
|
||||
Disks []DiskInListDeletedModel `tfsdk:"disks"`
|
||||
Driver types.String `tfsdk:"driver"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
ComputeId types.Int64 `tfsdk:"compute_id"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
Interfaces []ItemVNFInterfaceInListDeletedModel `tfsdk:"interfaces"`
|
||||
LockStatus types.String `tfsdk:"lock_status"`
|
||||
ManagerID types.Int64 `tfsdk:"manager_id"`
|
||||
ManagerType types.String `tfsdk:"manager_type"`
|
||||
MigrationJob types.Int64 `tfsdk:"migrationjob"`
|
||||
Milestones types.Int64 `tfsdk:"milestones"`
|
||||
Name types.String `tfsdk:"name"`
|
||||
NeedReboot types.Bool `tfsdk:"need_reboot"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
NumaNodeId types.Int64 `tfsdk:"numa_node_id"`
|
||||
Pinned types.Bool `tfsdk:"pinned"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
Registered types.Bool `tfsdk:"registered"`
|
||||
ResName types.String `tfsdk:"res_name"`
|
||||
ReservedNodeCpus types.List `tfsdk:"reserved_node_cpus"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
RGName types.String `tfsdk:"rg_name"`
|
||||
SnapSets []ItemSnapSetInListDeletedModel `tfsdk:"snap_sets"`
|
||||
StatelessSepID types.Int64 `tfsdk:"stateless_sep_id"`
|
||||
StatelessSepType types.String `tfsdk:"stateless_sep_type"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
Tags types.Map `tfsdk:"tags"`
|
||||
TechStatus types.String `tfsdk:"tech_status"`
|
||||
TotalDiskSize types.Int64 `tfsdk:"total_disks_size"`
|
||||
UpdatedBy types.String `tfsdk:"updated_by"`
|
||||
UpdatedTime types.Int64 `tfsdk:"updated_time"`
|
||||
UserManaged types.Bool `tfsdk:"user_managed"`
|
||||
VGPUs types.List `tfsdk:"vgpus"`
|
||||
VINSConnected types.Int64 `tfsdk:"vins_connected"`
|
||||
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
|
||||
LoaderType types.String `tfsdk:"loader_type"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
}
|
||||
|
||||
type ItemACLInListDeletedModel struct {
|
||||
|
||||
@@ -16,47 +16,49 @@ type ResourceComputeModel struct {
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
|
||||
//optional fields
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
WithoutBootDisk types.Bool `tfsdk:"without_boot_disk"`
|
||||
BootDiskSize types.Int64 `tfsdk:"boot_disk_size"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules types.Set `tfsdk:"affinity_rules"`
|
||||
AntiAffinityRules types.Set `tfsdk:"anti_affinity_rules"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
Stateless types.Bool `tfsdk:"stateless"`
|
||||
SepId types.Int64 `tfsdk:"sep_id"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
ExtraDisks types.Set `tfsdk:"extra_disks"`
|
||||
Network types.Set `tfsdk:"network"`
|
||||
Tags types.Set `tfsdk:"tags"`
|
||||
PortForwarding types.Set `tfsdk:"port_forwarding"`
|
||||
UserAccess types.Set `tfsdk:"user_access"`
|
||||
Snapshot types.Set `tfsdk:"snapshot"`
|
||||
PCIDevices types.Set `tfsdk:"pci_devices"`
|
||||
Rollback types.Object `tfsdk:"rollback"`
|
||||
CD types.Object `tfsdk:"cd"`
|
||||
PinToStack types.Bool `tfsdk:"pin_to_stack"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
Description types.String `tfsdk:"description"`
|
||||
CloudInit types.String `tfsdk:"cloud_init"`
|
||||
Enabled types.Bool `tfsdk:"enabled"`
|
||||
Pause types.Bool `tfsdk:"pause"`
|
||||
Reset types.Bool `tfsdk:"reset"`
|
||||
Restore types.Bool `tfsdk:"restore"`
|
||||
AutoStart types.Bool `tfsdk:"auto_start"`
|
||||
ForceStop types.Bool `tfsdk:"force_stop"`
|
||||
ForceResize types.Bool `tfsdk:"force_resize"`
|
||||
DataDisks types.String `tfsdk:"data_disks"`
|
||||
Started types.Bool `tfsdk:"started"`
|
||||
DetachDisks types.Bool `tfsdk:"detach_disks"`
|
||||
Permanently types.Bool `tfsdk:"permanently"`
|
||||
IS types.String `tfsdk:"is"`
|
||||
IpaType types.String `tfsdk:"ipa_type"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
ImageID types.Int64 `tfsdk:"image_id"`
|
||||
WithoutBootDisk types.Bool `tfsdk:"without_boot_disk"`
|
||||
BootDiskSize types.Int64 `tfsdk:"boot_disk_size"`
|
||||
AffinityLabel types.String `tfsdk:"affinity_label"`
|
||||
AffinityRules types.Set `tfsdk:"affinity_rules"`
|
||||
AntiAffinityRules types.Set `tfsdk:"anti_affinity_rules"`
|
||||
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
|
||||
CustomFields types.String `tfsdk:"custom_fields"`
|
||||
Chipset types.String `tfsdk:"chipset"`
|
||||
SepId types.Int64 `tfsdk:"sep_id"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
ExtraDisks types.Set `tfsdk:"extra_disks"`
|
||||
Network types.Set `tfsdk:"network"`
|
||||
Tags types.Set `tfsdk:"tags"`
|
||||
PortForwarding types.Set `tfsdk:"port_forwarding"`
|
||||
UserAccess types.Set `tfsdk:"user_access"`
|
||||
Snapshot types.Set `tfsdk:"snapshot"`
|
||||
PCIDevices types.Set `tfsdk:"pci_devices"`
|
||||
Rollback types.Object `tfsdk:"rollback"`
|
||||
CDImageID types.Int64 `tfsdk:"cd_image_id"`
|
||||
PinToStack types.Bool `tfsdk:"pin_to_stack"`
|
||||
PreferredCPU types.List `tfsdk:"preferred_cpu"`
|
||||
Description types.String `tfsdk:"description"`
|
||||
CloudInit types.String `tfsdk:"cloud_init"`
|
||||
Enabled types.Bool `tfsdk:"enabled"`
|
||||
Pause types.Bool `tfsdk:"pause"`
|
||||
Reset types.Bool `tfsdk:"reset"`
|
||||
Restore types.Bool `tfsdk:"restore"`
|
||||
ForceStop types.Bool `tfsdk:"force_stop"`
|
||||
ForceResize types.Bool `tfsdk:"force_resize"`
|
||||
Started types.Bool `tfsdk:"started"`
|
||||
DetachDisks types.Bool `tfsdk:"detach_disks"`
|
||||
Permanently types.Bool `tfsdk:"permanently"`
|
||||
IS types.String `tfsdk:"is"`
|
||||
IpaType types.String `tfsdk:"ipa_type"`
|
||||
NumaAffinity types.String `tfsdk:"numa_affinity"`
|
||||
CPUPin types.Bool `tfsdk:"cpu_pin"`
|
||||
HPBacked types.Bool `tfsdk:"hp_backed"`
|
||||
LoaderType types.String `tfsdk:"loader_type"`
|
||||
BootType types.String `tfsdk:"boot_type"`
|
||||
HotResize types.Bool `tfsdk:"hot_resize"`
|
||||
NetworkInterfaceNaming types.String `tfsdk:"network_interface_naming"`
|
||||
SnapshotDeleteAsync types.Bool `tfsdk:"snapshot_delete_async"`
|
||||
|
||||
// response fields
|
||||
ID types.String `tfsdk:"id"`
|
||||
@@ -68,7 +70,6 @@ type ResourceComputeModel struct {
|
||||
BootOrder types.List `tfsdk:"boot_order"`
|
||||
BootDisk types.Object `tfsdk:"boot_disk"`
|
||||
BootDiskId types.Int64 `tfsdk:"boot_disk_id"`
|
||||
CdImageId types.Int64 `tfsdk:"cd_image_id"`
|
||||
CloneReference types.Int64 `tfsdk:"clone_reference"`
|
||||
Clones types.List `tfsdk:"clones"`
|
||||
ComputeCIID types.Int64 `tfsdk:"computeci_id"`
|
||||
@@ -125,7 +126,6 @@ type RecordResourceACLModel struct {
|
||||
}
|
||||
|
||||
type ItemResourceDiskModel struct {
|
||||
CKey types.String `tfsdk:"ckey"`
|
||||
ACL types.String `tfsdk:"acl"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
BootPartition types.Int64 `tfsdk:"boot_partition"`
|
||||
@@ -151,7 +151,7 @@ type ItemResourceDiskModel struct {
|
||||
Passwd types.String `tfsdk:"passwd"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
Pool types.String `tfsdk:"pool"`
|
||||
PresentTo types.List `tfsdk:"present_to"`
|
||||
PresentTo types.Map `tfsdk:"present_to"`
|
||||
PurgeTime types.Int64 `tfsdk:"purge_time"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
RealityDeviceNumber types.Int64 `tfsdk:"reality_device_number"`
|
||||
@@ -218,6 +218,38 @@ type ItemResourceRulesModel struct {
|
||||
Value types.String `tfsdk:"value"`
|
||||
}
|
||||
|
||||
type ItemTagModel struct {
|
||||
Key types.String `tfsdk:"key"`
|
||||
Value types.String `tfsdk:"value"`
|
||||
}
|
||||
|
||||
type UserAccessModel struct {
|
||||
Username types.String `tfsdk:"username"`
|
||||
AccessType types.String `tfsdk:"access_type"`
|
||||
}
|
||||
|
||||
type ComputeVGPUModel struct {
|
||||
ID types.Int64 `tfsdk:"id"`
|
||||
GID types.Int64 `tfsdk:"gid"`
|
||||
Type types.String `tfsdk:"type"`
|
||||
Mode types.String `tfsdk:"mode"`
|
||||
Status types.String `tfsdk:"status"`
|
||||
ProfileID types.Int64 `tfsdk:"profile_id"`
|
||||
RAM types.Int64 `tfsdk:"ram"`
|
||||
LastUpdateTime types.Int64 `tfsdk:"last_update_time"`
|
||||
CreatedTime types.Int64 `tfsdk:"created_time"`
|
||||
DeletedTime types.Int64 `tfsdk:"deleted_time"`
|
||||
VMID types.Int64 `tfsdk:"vmid"`
|
||||
PGPUID types.Int64 `tfsdk:"pgpuid"`
|
||||
ReferenceID types.String `tfsdk:"reference_id"`
|
||||
AccountID types.Int64 `tfsdk:"account_id"`
|
||||
RGID types.Int64 `tfsdk:"rg_id"`
|
||||
LastClaimedBy types.Int64 `tfsdk:"last_claimed_by"`
|
||||
PCISlot types.Int64 `tfsdk:"pci_slot"`
|
||||
BusNumber types.Int64 `tfsdk:"bus_number"`
|
||||
GUID types.Int64 `tfsdk:"guid"`
|
||||
}
|
||||
|
||||
var ItemNetwork = map[string]attr.Type{
|
||||
"net_type": types.StringType,
|
||||
"net_id": types.Int64Type,
|
||||
@@ -228,7 +260,6 @@ var ItemNetwork = map[string]attr.Type{
|
||||
}
|
||||
|
||||
var ItemDisk = map[string]attr.Type{
|
||||
"ckey": types.StringType,
|
||||
"acl": types.StringType,
|
||||
"account_id": types.Int64Type,
|
||||
"boot_partition": types.Int64Type,
|
||||
@@ -242,7 +273,7 @@ var ItemDisk = map[string]attr.Type{
|
||||
"guid": types.Int64Type,
|
||||
"disk_id": types.Int64Type,
|
||||
"image_id": types.Int64Type,
|
||||
"images": types.ListType{ElemType: types.StringType},
|
||||
"images": types.ListType{ElemType: types.Int64Type},
|
||||
"iotune": types.ObjectType{AttrTypes: disks.ItemIOTune},
|
||||
"iqn": types.StringType,
|
||||
"login": types.StringType,
|
||||
@@ -254,7 +285,7 @@ var ItemDisk = map[string]attr.Type{
|
||||
"passwd": types.StringType,
|
||||
"pci_slot": types.Int64Type,
|
||||
"pool": types.StringType,
|
||||
"present_to": types.ListType{ElemType: types.Int64Type},
|
||||
"present_to": types.MapType{ElemType: types.Int64Type},
|
||||
"purge_time": types.Int64Type,
|
||||
"replication": types.ObjectType{AttrTypes: ItemReplication},
|
||||
"reality_device_number": types.Int64Type,
|
||||
@@ -361,3 +392,50 @@ var ItemSnapSets = map[string]attr.Type{
|
||||
"label": types.StringType,
|
||||
"timestamp": types.Int64Type,
|
||||
}
|
||||
|
||||
var ItemResourceRules = map[string]attr.Type{
|
||||
"key": types.StringType,
|
||||
"mode": types.StringType,
|
||||
"policy": types.StringType,
|
||||
"topology": types.StringType,
|
||||
"value": types.StringType,
|
||||
}
|
||||
|
||||
var ItemTag = map[string]attr.Type{
|
||||
"key": types.StringType,
|
||||
"value": types.StringType,
|
||||
}
|
||||
|
||||
var ItemPortForfarding = map[string]attr.Type{
|
||||
"public_port_start": types.Int64Type,
|
||||
"public_port_end": types.Int64Type,
|
||||
"local_port": types.Int64Type,
|
||||
"proto": types.StringType,
|
||||
}
|
||||
|
||||
var ItemUserAccess = map[string]attr.Type{
|
||||
"username": types.StringType,
|
||||
"access_type": types.StringType,
|
||||
}
|
||||
|
||||
var ComputeItemVGPU = map[string]attr.Type{
|
||||
"id": types.Int64Type,
|
||||
"gid": types.Int64Type,
|
||||
"type": types.StringType,
|
||||
"mode": types.StringType,
|
||||
"status": types.StringType,
|
||||
"profile_id": types.Int64Type,
|
||||
"ram": types.Int64Type,
|
||||
"last_update_time": types.Int64Type,
|
||||
"created_time": types.Int64Type,
|
||||
"deleted_time": types.Int64Type,
|
||||
"vmid": types.Int64Type,
|
||||
"pgpuid": types.Int64Type,
|
||||
"reference_id": types.StringType,
|
||||
"account_id": types.Int64Type,
|
||||
"rg_id": types.Int64Type,
|
||||
"last_claimed_by": types.Int64Type,
|
||||
"pci_slot": types.Int64Type,
|
||||
"bus_number": types.Int64Type,
|
||||
"guid": types.Int64Type,
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest
|
||||
tflog.Info(ctx, "Create resourceCompute: new simple Compute created", map[string]any{"id": ComputeId, "name": plan.Name.ValueString()})
|
||||
|
||||
// attach extra disk(s) to new compute
|
||||
if !plan.ExtraDisks.IsNull() {
|
||||
if !plan.ExtraDisks.IsNull() && !plan.ExtraDisks.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceExtraDiskCreate(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Create resourceCompute: error when attaching extra disk(s) to a new Compute ")
|
||||
@@ -112,52 +112,52 @@ func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest
|
||||
}
|
||||
|
||||
// add affinity_rules if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.AffinityRules.IsNull() {
|
||||
if !plan.AffinityRules.IsNull() && !plan.AffinityRules.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAffinityRules(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add anti_affinity_rules if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.AntiAffinityRules.IsNull() {
|
||||
if !plan.AntiAffinityRules.IsNull() && !plan.AntiAffinityRules.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAntiAffinityRules(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add tags if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.Tags.IsNull() {
|
||||
if !plan.Tags.IsNull() && !plan.Tags.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceTags(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add port_forwarding if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.PortForwarding.IsNull() {
|
||||
if !plan.PortForwarding.IsNull() && !plan.PortForwarding.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePortForwarding(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add user_access if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.UserAccess.IsNull() {
|
||||
if !plan.UserAccess.IsNull() && !plan.UserAccess.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceUserAccess(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add snapshot if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.Snapshot.IsNull() {
|
||||
if !plan.Snapshot.IsNull() && !plan.Snapshot.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceSnapshot(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// add cd if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.CD.IsNull() {
|
||||
if !plan.CDImageID.IsNull() && !plan.CDImageID.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceCDInsert(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// attach PCI devices to compute if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.PCIDevices.IsNull() {
|
||||
if !plan.PCIDevices.IsNull() && !plan.PCIDevices.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePCIDevice(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// set auto start_w_node if pin_to_stack == false
|
||||
if !plan.PinToStack.ValueBool() && plan.AutoStartWithNode.ValueBool() {
|
||||
if !plan.PinToStack.ValueBool() && plan.AutoStartWithNode.ValueBool() && !plan.PinToStack.IsUnknown() && !plan.AutoStartWithNode.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAutoStartWithNode(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
// pause if needed, warnings added to resp.Diagnostics in case of failure.
|
||||
if !plan.Pause.IsNull() && plan.Pause.ValueBool() {
|
||||
if !plan.Pause.IsNull() && plan.Pause.ValueBool() && !plan.Pause.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePause(ctx, &plan, r.client)...)
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
plan.ID = state.ID
|
||||
|
||||
// Enable/disable Compute if needed
|
||||
if !plan.Enabled.Equal(state.Enabled) {
|
||||
if !plan.Enabled.IsUnknown() && !plan.Enabled.Equal(state.Enabled) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceEnableDisable(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error enable/disable Compute")
|
||||
@@ -284,7 +284,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Start/stop Compute if needed
|
||||
if !plan.Started.Equal(state.Started) {
|
||||
if !plan.Started.IsUnknown() && !plan.Started.Equal(state.Started) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceStartStop(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error start/stop Compute")
|
||||
@@ -302,7 +302,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Resize boot disk size if needed
|
||||
if !plan.BootDiskSize.Equal(state.BootDiskSize) {
|
||||
if !plan.BootDiskSize.IsUnknown() && !plan.BootDiskSize.Equal(state.BootDiskSize) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceBootDiskResize(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error resize boot disk")
|
||||
@@ -311,7 +311,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Extra disk(s) update if needed
|
||||
if !plan.ExtraDisks.Equal(state.ExtraDisks) {
|
||||
if !plan.ExtraDisks.IsUnknown() && !plan.ExtraDisks.Equal(state.ExtraDisks) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceExtraDiskUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update extra disk list")
|
||||
@@ -320,7 +320,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// PCI device(s) update if needed
|
||||
if !plan.PCIDevices.Equal(state.PCIDevices) {
|
||||
if !plan.PCIDevices.IsUnknown() && !plan.PCIDevices.Equal(state.PCIDevices) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePCIDeviceUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update PCI device(s) list")
|
||||
@@ -329,7 +329,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// pin to stack if needed
|
||||
if !plan.PinToStack.Equal(state.PinToStack) {
|
||||
if !plan.PinToStack.IsUnknown() && !plan.PinToStack.Equal(state.PinToStack) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePinToStackUpdate(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error pin/unpin to stack compute")
|
||||
@@ -338,9 +338,14 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Compute parameters update if needed
|
||||
if (!plan.Description.IsUnknown() && !plan.Description.Equal(state.Description)) || !plan.Name.Equal(state.Name) ||
|
||||
!plan.NumaAffinity.Equal(state.NumaAffinity) || !plan.CPUPin.Equal(state.CPUPin) || !plan.HPBacked.Equal(state.HPBacked) || (!plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset)) ||
|
||||
!plan.AutoStartWithNode.Equal(state.AutoStartWithNode) || (!plan.PreferredCPU.IsUnknown() && !plan.PreferredCPU.Equal(state.Description)) {
|
||||
if (!plan.Description.IsUnknown() && !plan.Description.Equal(state.Description)) ||
|
||||
!plan.Name.IsUnknown() && !plan.Name.Equal(state.Name) ||
|
||||
!plan.NumaAffinity.IsUnknown() && !plan.NumaAffinity.Equal(state.NumaAffinity) ||
|
||||
!plan.CPUPin.IsUnknown() && !plan.CPUPin.Equal(state.CPUPin) ||
|
||||
!plan.HPBacked.IsUnknown() && !plan.HPBacked.Equal(state.HPBacked) ||
|
||||
(!plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset)) ||
|
||||
!plan.AutoStartWithNode.IsUnknown() && !plan.AutoStartWithNode.Equal(state.AutoStartWithNode) ||
|
||||
(!plan.PreferredCPU.IsUnknown() && !plan.PreferredCPU.Equal(state.Description)) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceComputeUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update compute parameters")
|
||||
@@ -358,7 +363,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Affinity label update if needed
|
||||
if !plan.AffinityLabel.Equal(state.AffinityLabel) && !plan.AffinityLabel.IsUnknown() {
|
||||
if !plan.AffinityLabel.IsUnknown() && !plan.AffinityLabel.Equal(state.AffinityLabel) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAffinityLabelUpdate(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update affinity label")
|
||||
@@ -367,7 +372,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Affinity rules update if needed
|
||||
if !plan.AffinityRules.Equal(state.AffinityRules) {
|
||||
if !plan.AffinityRules.IsUnknown() && !plan.AffinityRules.Equal(state.AffinityRules) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAffinityRulesUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update affinity rules")
|
||||
@@ -376,7 +381,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Anti affinity rules update if needed
|
||||
if !plan.AntiAffinityRules.Equal(state.AntiAffinityRules) {
|
||||
if !plan.AntiAffinityRules.IsUnknown() && !plan.AntiAffinityRules.Equal(state.AntiAffinityRules) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceAntiAffinityRulesUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update anti affinity rules")
|
||||
@@ -385,7 +390,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Tags update if needed
|
||||
if !plan.Tags.Equal(state.Tags) {
|
||||
if !plan.Tags.IsUnknown() && !plan.Tags.Equal(state.Tags) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceTagsUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update tags")
|
||||
@@ -394,7 +399,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Port forwarding update if needed
|
||||
if !plan.PortForwarding.Equal(state.PortForwarding) {
|
||||
if !plan.PortForwarding.IsUnknown() && !plan.PortForwarding.Equal(state.PortForwarding) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourcePortForwardingUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update port forwarding rules")
|
||||
@@ -403,7 +408,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// User access update if needed
|
||||
if !plan.UserAccess.Equal(state.UserAccess) {
|
||||
if !plan.UserAccess.IsUnknown() && !plan.UserAccess.Equal(state.UserAccess) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceUserAccessUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update user(s) access rules")
|
||||
@@ -412,7 +417,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Snapshot update if needed
|
||||
if !plan.Snapshot.Equal(state.Snapshot) {
|
||||
if !plan.Snapshot.IsUnknown() && !plan.Snapshot.Equal(state.Snapshot) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceSnapshotUpdate(ctx, &state, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update snapshot(s)")
|
||||
@@ -421,7 +426,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Rollback if needed
|
||||
if !plan.Rollback.Equal(state.Rollback) && !plan.Rollback.IsNull() {
|
||||
if !plan.Rollback.Equal(state.Rollback) && !plan.Rollback.IsNull() && !plan.Rollback.IsUnknown() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceRollback(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error rollback compute")
|
||||
@@ -430,7 +435,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// Cd update if needed
|
||||
if !plan.CD.Equal(state.CD) {
|
||||
if !plan.CDImageID.IsUnknown() && !plan.CDImageID.Equal(state.CDImageID) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceCDUpdate(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update cd image update")
|
||||
@@ -448,7 +453,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// reset compute if need
|
||||
if !plan.Reset.Equal(state.Reset) && plan.Reset.ValueBool() {
|
||||
if !plan.Reset.IsUnknown() && !plan.Reset.Equal(state.Reset) && plan.Reset.ValueBool() {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceResetCompute(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error reset compute")
|
||||
@@ -457,7 +462,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// redeploy compute if need
|
||||
if !plan.ImageID.Equal(state.ImageID) {
|
||||
if !plan.ImageID.IsUnknown() && !plan.ImageID.Equal(state.ImageID) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceRedeploy(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error redeploy compute")
|
||||
@@ -466,7 +471,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
|
||||
}
|
||||
|
||||
// custom fields update if needed
|
||||
if !plan.CustomFields.Equal(state.CustomFields) && !plan.CustomFields.IsUnknown() {
|
||||
if !plan.CustomFields.IsUnknown() && !plan.CustomFields.Equal(state.CustomFields) {
|
||||
resp.Diagnostics.Append(utilities.ComputeResourceCustomFieldUpdate(ctx, &plan, r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceCompute: Error update custom fields")
|
||||
|
||||
@@ -170,6 +170,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"boot_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"bootdisk_size": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -337,7 +340,7 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
@@ -385,6 +388,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
"shareable": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_available": schema.Float64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"size_max": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -446,6 +452,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
"hp_backed": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"hot_resize": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"image_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -563,6 +572,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"loader_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"lock_status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -581,6 +593,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
"name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"network_interface_naming": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"need_reboot": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -705,9 +720,69 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
|
||||
"user_managed": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vgpus": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
"vgpus": schema.ListNestedAttribute{
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"gid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"mode": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"profile_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"ram": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"last_update_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"pgpuid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"reference_id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"last_claimed_by": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"pci_slot": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"bus_number": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"guid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"virtual_image_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
|
||||
@@ -176,6 +176,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"boot_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"bootdisk_size": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -247,6 +250,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
|
||||
"hp_backed": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"hot_resize": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"compute_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -364,6 +370,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
|
||||
"lock_status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"loader_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -379,6 +388,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
|
||||
"name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"network_interface_naming": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"need_reboot": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -168,6 +168,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
},
|
||||
"boot_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"bootdisk_size": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -239,6 +242,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
|
||||
"hp_backed": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"hot_resize": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"compute_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -356,6 +362,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
|
||||
"lock_status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"loader_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"manager_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -371,6 +380,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
|
||||
"name": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"network_interface_naming": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"need_reboot": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
@@ -2,7 +2,6 @@ package schemas
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
|
||||
"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"
|
||||
@@ -53,6 +52,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
// optional attributes
|
||||
"image_id": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "ID of the OS image to base this compute instance on.",
|
||||
},
|
||||
"without_boot_disk": schema.BoolAttribute{ //default false
|
||||
@@ -71,6 +71,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"affinity_rules": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"topology": schema.StringAttribute{
|
||||
@@ -107,6 +108,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"anti_affinity_rules": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"topology": schema.StringAttribute{
|
||||
@@ -146,10 +148,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
Computed: true,
|
||||
Description: "custom fields for Compute. Must be dict",
|
||||
},
|
||||
"stateless": schema.BoolAttribute{ //default false
|
||||
Optional: true,
|
||||
Description: "Compute will be stateless (SVA_KVM_X86) if set to True",
|
||||
},
|
||||
"sep_id": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
@@ -163,18 +161,12 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
"extra_disks": schema.SetAttribute{
|
||||
Optional: true,
|
||||
//Computed: true,
|
||||
Validators: []validator.Set{
|
||||
setvalidator.SizeAtMost(constants.MaxExtraDisksPerCompute),
|
||||
},
|
||||
ElementType: types.Int64Type,
|
||||
Description: "Optional list of IDs of extra disks to attach to this compute. You may specify several extra disks.",
|
||||
},
|
||||
"network": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Validators: []validator.Set{
|
||||
setvalidator.SizeBetween(1, constants.MaxNetworksPerCompute),
|
||||
},
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Optional network connection(s) for this compute. You may specify several network blocks, one for each connection.",
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
@@ -195,6 +187,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
Description: "Optional IP address to assign to this connection. This IP should belong to the selected network and free for use.",
|
||||
},
|
||||
"mac": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "MAC address associated with this connection. MAC address is assigned automatically.",
|
||||
},
|
||||
@@ -216,6 +209,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"tags": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"key": schema.StringAttribute{
|
||||
@@ -229,6 +223,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"port_forwarding": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"public_port_start": schema.Int64Attribute{
|
||||
@@ -252,6 +247,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"user_access": schema.SetNestedAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"username": schema.StringAttribute{
|
||||
@@ -281,13 +277,9 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
},
|
||||
},
|
||||
"cd": schema.SingleNestedAttribute{
|
||||
"cd_image_id": schema.Int64Attribute{
|
||||
Optional: true,
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"cdrom_id": schema.Int64Attribute{
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
Computed: true,
|
||||
},
|
||||
"pin_to_stack": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
@@ -311,6 +303,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"pause": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
//Default: false,
|
||||
},
|
||||
"reset": schema.BoolAttribute{
|
||||
@@ -323,11 +316,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
Default: booldefault.StaticBool(true),
|
||||
//Default: true,
|
||||
},
|
||||
"auto_start": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
//Default: false,
|
||||
Description: "Flag for redeploy compute",
|
||||
},
|
||||
"force_stop": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
//Default: false,
|
||||
@@ -338,14 +326,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
//Default: false,
|
||||
Description: "Flag for resize compute",
|
||||
},
|
||||
"data_disks": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOf("KEEP", "DETACH", "DESTROY"),
|
||||
},
|
||||
//Default: "DETACH",
|
||||
Description: "Flag for redeploy compute",
|
||||
},
|
||||
"started": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
@@ -372,6 +352,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"numa_affinity": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOf("none", "strict", "loose"),
|
||||
},
|
||||
@@ -398,6 +379,7 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
},
|
||||
"pci_devices": schema.SetAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
Description: "ID of the connected pci devices",
|
||||
},
|
||||
@@ -415,6 +397,42 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
Description: "Flag for start compute after node exits from MAINTENANCE state",
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"snapshot_delete_async": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Flag for deleting snapshots asynchronously",
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"loader_type": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Type of VM",
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOfCaseInsensitive("unknown", "linux", "windows"),
|
||||
},
|
||||
},
|
||||
|
||||
"boot_type": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Type of image upload",
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOfCaseInsensitive("bios", "uefi"),
|
||||
},
|
||||
},
|
||||
"hot_resize": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Changing the size of a VM",
|
||||
},
|
||||
"network_interface_naming": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "Name of the network interface",
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOfCaseInsensitive("eth", "ens"),
|
||||
},
|
||||
},
|
||||
|
||||
// computed attributes
|
||||
"compute_id": schema.Int64Attribute{
|
||||
@@ -531,9 +549,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
"boot_disk_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"cd_image_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"clone_reference": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -804,9 +819,69 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
"user_managed": schema.BoolAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vgpus": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
"vgpus": schema.ListNestedAttribute{
|
||||
Computed: true,
|
||||
NestedObject: schema.NestedAttributeObject{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"gid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"mode": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"status": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"profile_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"ram": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"last_update_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"created_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"deleted_time": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"vmid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"pgpuid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"reference_id": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"account_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"rg_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"last_claimed_by": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"pci_slot": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"bus_number": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"guid": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"virtual_image_id": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
@@ -822,9 +897,6 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
|
||||
|
||||
func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
|
||||
return map[string]schema.Attribute{
|
||||
"ckey": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"acl": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
@@ -866,7 +938,7 @@ func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
|
||||
},
|
||||
"images": schema.ListAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.StringType,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
"iotune": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
@@ -942,7 +1014,7 @@ func MakeSchemaResourceComputeDisks() map[string]schema.Attribute {
|
||||
"pool": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
"present_to": schema.ListAttribute{
|
||||
"present_to": schema.MapAttribute{
|
||||
Computed: true,
|
||||
ElementType: types.Int64Type,
|
||||
},
|
||||
|
||||
@@ -37,6 +37,60 @@ func ComputeResourceCheckPresence(ctx context.Context, plan *models.ResourceComp
|
||||
return computeItem, nil
|
||||
}
|
||||
|
||||
func ResourceComputePCIDevicesListCheckPresence(ctx context.Context, id uint64, c *client.Client) (*compute.ListPCIDevices, error) {
|
||||
tflog.Info(ctx, "Get PCI devices info")
|
||||
|
||||
req := compute.ListPCIDeviceRequest{
|
||||
ComputeID: id,
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Check req", map[string]any{"req": req})
|
||||
|
||||
pciDevicesList, err := c.CloudAPI().Compute().ListPCIDevice(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Getting PCI devices info, successfully")
|
||||
return pciDevicesList, nil
|
||||
}
|
||||
|
||||
func ComputeResourceUserAccessGet(ctx context.Context, computeID uint64, c *client.Client) (*compute.ListUsers, error) {
|
||||
tflog.Info(ctx, "Get compute user access info")
|
||||
|
||||
req := compute.UserListRequest{
|
||||
ComputeID: computeID,
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Check req", map[string]any{"req": req})
|
||||
|
||||
userList, err := c.CloudAPI().Compute().UserList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Getting compute user access info, successfully")
|
||||
return userList, nil
|
||||
}
|
||||
|
||||
func ComputeResourcePFWListGet(ctx context.Context, computeID uint64, c *client.Client) (*compute.ListPFWs, error) {
|
||||
tflog.Info(ctx, "Get compute pfw list info")
|
||||
|
||||
req := compute.PFWListRequest{
|
||||
ComputeID: computeID,
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Check req", map[string]any{"req": req})
|
||||
|
||||
pfwList, err := c.CloudAPI().Compute().PFWList(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Getting compute pfw list info, successfully")
|
||||
return pfwList, nil
|
||||
}
|
||||
|
||||
func ComputeResourceCheckDetachDisks(state *models.ResourceComputeModel, recordCompute *compute.RecordCompute) bool {
|
||||
bootDiskId := uint64(state.BootDiskId.ValueInt64())
|
||||
extraDiskList := state.ExtraDisks.Elements()
|
||||
@@ -140,6 +194,10 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
|
||||
if ipSet {
|
||||
reqInterface.IPAddr = ipaddr.(types.String).ValueString()
|
||||
}
|
||||
macaddr, macSet := elemMap["mac"]
|
||||
if macSet {
|
||||
reqInterface.MAC = macaddr.(types.String).ValueString()
|
||||
}
|
||||
interfaces = append(interfaces, reqInterface)
|
||||
}
|
||||
|
||||
@@ -206,6 +264,37 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
|
||||
diags.AddError("CreateResourceCompute: unable to create KVM VP x86", err.Error())
|
||||
return 0, diags
|
||||
}
|
||||
|
||||
updateReq := compute.UpdateRequest{}
|
||||
|
||||
if !plan.LoaderType.IsNull() {
|
||||
updateReq.LoaderType = plan.LoaderType.ValueString()
|
||||
}
|
||||
|
||||
if !plan.BootType.IsNull() {
|
||||
updateReq.BootType = plan.BootType.ValueString()
|
||||
}
|
||||
|
||||
if !plan.HotResize.IsNull() {
|
||||
updateReq.HotResize = plan.HotResize.ValueBool()
|
||||
}
|
||||
|
||||
if !plan.NetworkInterfaceNaming.IsNull() {
|
||||
updateReq.NetworkInterfaceNaming = plan.NetworkInterfaceNaming.ValueString()
|
||||
}
|
||||
|
||||
if !plan.LoaderType.IsNull() ||
|
||||
!plan.BootType.IsNull() ||
|
||||
!plan.HotResize.IsNull() ||
|
||||
!plan.NetworkInterfaceNaming.IsNull() {
|
||||
updateReq.ComputeID = id
|
||||
tflog.Info(ctx, "CreateResourceCompute: creating Compute with LoaderType or BootType or HotResize or NetworkInterfaceNaming")
|
||||
_, err = c.CloudAPI().Compute().Update(ctx, updateReq)
|
||||
if err != nil {
|
||||
diags.AddWarning("CreateResourceCompute: unable to update LoaderType or BootType or HotResize or NetworkInterfaceNaming", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return id, diags
|
||||
|
||||
}
|
||||
@@ -520,8 +609,8 @@ func ComputeResourcePortForwarding(ctx context.Context, plan *models.ResourceCom
|
||||
PublicPortStart: uint64(itemPortForwarding.PublicPortStart.ValueInt64()),
|
||||
Proto: strings.ToLower(itemPortForwarding.Proto.ValueString()),
|
||||
}
|
||||
if itemPortForwarding.PublicPortStart.ValueInt64() != 0 {
|
||||
req.PublicPortStart = uint64(itemPortForwarding.PublicPortStart.ValueInt64())
|
||||
if itemPortForwarding.PublicPortEnd.ValueInt64() != 0 {
|
||||
req.PublicPortEnd = itemPortForwarding.PublicPortEnd.ValueInt64()
|
||||
}
|
||||
if itemPortForwarding.LocalPort.ValueInt64() != 0 {
|
||||
req.LocalBasePort = uint64(itemPortForwarding.LocalPort.ValueInt64())
|
||||
@@ -659,7 +748,7 @@ func ComputeResourceCDInsert(ctx context.Context, plan *models.ResourceComputeMo
|
||||
}
|
||||
|
||||
req := compute.CDInsertRequest{ComputeID: computeId}
|
||||
req.CDROMID = uint64(plan.CD.Attributes()["cdrom_id"].(types.Int64).ValueInt64())
|
||||
req.CDROMID = uint64(plan.CDImageID.ValueInt64())
|
||||
tflog.Info(ctx, "ComputeResourceCDInsert: before calling CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().CDInsert(ctx, req)
|
||||
tflog.Info(ctx, "ComputeResourceCDInsert: response from CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "response": res})
|
||||
|
||||
@@ -33,12 +33,13 @@ func differenceSimpleType(oldSet, newSet types.Set) (added, removed []any) {
|
||||
return
|
||||
}
|
||||
|
||||
func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map[string]attr.Value) {
|
||||
func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, changeMac, removed []map[string]attr.Value) {
|
||||
oldSlice := oldSet.Elements()
|
||||
newSlice := newSet.Elements()
|
||||
|
||||
added = make([]map[string]attr.Value, 0)
|
||||
changeIp = make([]map[string]attr.Value, 0)
|
||||
changeMac = make([]map[string]attr.Value, 0)
|
||||
removed = make([]map[string]attr.Value, 0)
|
||||
|
||||
for _, oldNetwork := range oldSlice {
|
||||
@@ -47,15 +48,19 @@ func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map
|
||||
for _, newNetwork := range newSlice {
|
||||
newMap := newNetwork.(types.Object).Attributes()
|
||||
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(types.Int64).ValueInt64() == 0) {
|
||||
if (newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(types.String).ValueString() != "") {
|
||||
found = true
|
||||
switch {
|
||||
case (newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && (newMap["ip_address"] != oldMap["ip_address"] && newMap["ip_address"].(types.String).ValueString() != ""):
|
||||
changeIp = append(changeIp, newMap)
|
||||
found = true
|
||||
break
|
||||
} else if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(types.String).ValueString() != "" {
|
||||
found = true
|
||||
break
|
||||
fallthrough
|
||||
case newMap["mac"] != oldMap["mac"] && newMap["mac"].(types.String).ValueString() != "":
|
||||
newMap["old_mac"] = oldMap["mac"]
|
||||
changeMac = append(changeMac, newMap)
|
||||
}
|
||||
}
|
||||
if found {
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
continue
|
||||
@@ -69,10 +74,8 @@ func differenceNetwork(oldSet, newSet types.Set) (added, changeIp, removed []map
|
||||
for _, oldNetwork := range oldSlice {
|
||||
oldMap := oldNetwork.(types.Object).Attributes()
|
||||
if newMap["net_type"] == oldMap["net_type"] && newMap["net_id"] == oldMap["net_id"] && newMap["weight"] == oldMap["weight"] && (newMap["mtu"] == oldMap["mtu"] || newMap["mtu"].(types.Int64).ValueInt64() == 0) {
|
||||
if newMap["ip_address"] == oldMap["ip_address"] || newMap["ip_address"].(types.String).ValueString() != "" || ((newMap["net_type"].(types.String).ValueString() == "EXTNET" || newMap["net_type"].(types.String).ValueString() == "VINS") && newMap["ip_address"] != oldMap["ip_address"]) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
|
||||
@@ -93,7 +93,7 @@ func ComputeResourceBootDiskResize(ctx context.Context, state *models.ResourceCo
|
||||
}
|
||||
|
||||
if state.BootDiskSize.ValueInt64() > plan.BootDiskSize.ValueInt64() {
|
||||
diags.AddError(fmt.Sprintf("ComputeResourceBootDiskResize: compute ID %d - shrinking boot disk is not allowed", computeId), "")
|
||||
diags.AddError(fmt.Sprintf("ComputeResourceBootDiskResize: compute ID %d - shrinking boot disk is not allowed, state: %d, plan: %d", computeId, state.BootDiskSize.ValueInt64(), plan.BootDiskSize.ValueInt64()), "")
|
||||
return diags
|
||||
}
|
||||
|
||||
@@ -159,17 +159,6 @@ func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceC
|
||||
return diags
|
||||
}
|
||||
|
||||
if len(detachSet) > 0 {
|
||||
tflog.Info(ctx, "ComputeResourceExtraDiskUpdate: stop compute", map[string]any{"compute_id": computeId})
|
||||
_, err = c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeId})
|
||||
if err != nil {
|
||||
diags.AddError(
|
||||
"ComputeResourceExtraDiskUpdate: cannot stop compute", err.Error(),
|
||||
)
|
||||
return diags
|
||||
}
|
||||
}
|
||||
|
||||
for _, disk := range detachSet {
|
||||
diskId := uint64(disk.(types.Int64).ValueInt64())
|
||||
tflog.Info(ctx, fmt.Sprintf("ComputeResourceExtraDiskUpdate: Start detach extra disk with ID - %d from compute with ID - %d", diskId, computeId))
|
||||
@@ -184,10 +173,6 @@ func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceC
|
||||
}
|
||||
}
|
||||
|
||||
if len(detachSet) > 0 && plan.Started.ValueBool() {
|
||||
diags = ComputeResourceStartStop(ctx, plan, c)
|
||||
}
|
||||
|
||||
if diags.HasError() {
|
||||
tflog.Error(ctx, "ComputeResourceExtraDiskUpdate: Errors occurred while managing disks")
|
||||
return diags
|
||||
@@ -207,7 +192,7 @@ func ComputeResourcePCIDeviceUpdate(ctx context.Context, state *models.ResourceC
|
||||
return diags
|
||||
}
|
||||
|
||||
attachSet, detachSet := differenceSimpleType(state.ExtraDisks, plan.ExtraDisks)
|
||||
attachSet, detachSet := differenceSimpleType(state.PCIDevices, plan.PCIDevices)
|
||||
|
||||
for _, pciDevice := range detachSet {
|
||||
pciDeviceId := pciDevice.(types.Int64).ValueInt64()
|
||||
@@ -256,7 +241,7 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
|
||||
return diags
|
||||
}
|
||||
|
||||
attachMap, changeIpMap, detachMap := differenceNetwork(state.Network, plan.Network)
|
||||
attachMap, changeIpMap, changeMacMap, detachMap := differenceNetwork(state.Network, plan.Network)
|
||||
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: start detach network(s) rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
|
||||
for _, network := range detachMap {
|
||||
@@ -302,7 +287,7 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
|
||||
|
||||
needStart := false
|
||||
// need stop to attach first network
|
||||
if len(detachMap) == len(state.Network.Elements()) || (len(state.Network.Elements()) < 1) && len(attachMap) > 0 {
|
||||
if len(detachMap) == len(state.Network.Elements()) || (len(state.Network.Elements()) < 1) && len(attachMap) > 0 || hasDPDKnetwork(attachMap) || len(changeMacMap) > 0 {
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: stop compute", map[string]any{"compute_id": computeId})
|
||||
_, err = c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeId})
|
||||
if err != nil {
|
||||
@@ -316,6 +301,27 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
|
||||
}
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: start change MAC address network(s) to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
|
||||
|
||||
for _, network := range changeMacMap {
|
||||
req := compute.ChangeMACRequest{
|
||||
ComputeID: computeId,
|
||||
NewMAC: network["mac"].(types.String).ValueString(),
|
||||
СurrentMAC: network["old_mac"].(types.String).ValueString(),
|
||||
}
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: before calling CloudAPI().Compute().ChangeMAC", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().ChangeMAC(ctx, req)
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: response from CloudAPI().Compute().ChangeMAC", map[string]any{"compute_id": plan.ID.ValueString(), "response": res})
|
||||
if err != nil {
|
||||
diags.AddError(fmt.Sprintf("ComputeResourceNetworkUpdate: failed to change Mac to net ID %d from Compute ID %d",
|
||||
network["net_id"].(types.Int64).ValueInt64(), computeId), err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
}
|
||||
|
||||
sort.Slice(attachMap, func(i, j int) bool {
|
||||
weightI := attachMap[i]["weight"].(types.Int64).ValueInt64()
|
||||
weightJ := attachMap[j]["weight"].(types.Int64).ValueInt64()
|
||||
@@ -341,6 +347,10 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
|
||||
if ipSet {
|
||||
req.IPAddr = ipaddr.(types.String).ValueString()
|
||||
}
|
||||
macaddr, macSet := network["mac"]
|
||||
if macSet {
|
||||
req.MACAddr = macaddr.(types.String).ValueString()
|
||||
}
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: before calling CloudAPI().Compute().NetAttach", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().NetAttach(ctx, req)
|
||||
tflog.Info(ctx, "ComputeResourceNetworkUpdate: response from CloudAPI().Compute().NetAttach", map[string]any{"compute_id": plan.ID.ValueString(), "response": res})
|
||||
@@ -367,6 +377,15 @@ func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceCom
|
||||
return nil
|
||||
}
|
||||
|
||||
func hasDPDKnetwork(networkAttachMap []map[string]attr.Value) bool {
|
||||
for _, elem := range networkAttachMap {
|
||||
if elem["net_type"].(types.String).ValueString() == "DPDK" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
|
||||
tflog.Info(ctx, "ComputeResourceComputeUpdate: start update compute parameters", map[string]any{"compute_id": plan.ID.ValueString()})
|
||||
diags := diag.Diagnostics{}
|
||||
@@ -389,13 +408,29 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
|
||||
req.Description = plan.Description.ValueString()
|
||||
}
|
||||
|
||||
if !plan.NumaAffinity.Equal(state.NumaAffinity) {
|
||||
if !plan.NumaAffinity.Equal(state.NumaAffinity) && !plan.NumaAffinity.IsUnknown() {
|
||||
req.NumaAffinity = plan.NumaAffinity.ValueString()
|
||||
}
|
||||
|
||||
req.CPUPin = plan.CPUPin.ValueBool()
|
||||
req.HPBacked = plan.HPBacked.ValueBool()
|
||||
req.AutoStart = plan.AutoStartWithNode.ValueBool()
|
||||
if !plan.CPUPin.Equal(state.CPUPin) && !plan.CPUPin.IsUnknown() {
|
||||
req.CPUPin = plan.CPUPin.ValueBool()
|
||||
}
|
||||
if !plan.HPBacked.Equal(state.HPBacked) && !plan.HPBacked.IsUnknown() {
|
||||
req.HPBacked = plan.HPBacked.ValueBool()
|
||||
}
|
||||
if !plan.LoaderType.Equal(state.LoaderType) && !plan.LoaderType.IsUnknown() {
|
||||
req.LoaderType = plan.LoaderType.ValueString()
|
||||
}
|
||||
|
||||
if !plan.BootType.Equal(state.BootType) && !plan.BootType.IsUnknown() {
|
||||
req.BootType = plan.BootType.ValueString()
|
||||
}
|
||||
if !plan.HotResize.Equal(state.HotResize) && !plan.HotResize.IsUnknown() {
|
||||
req.HotResize = plan.HotResize.ValueBool()
|
||||
}
|
||||
if !plan.NetworkInterfaceNaming.Equal(state.NetworkInterfaceNaming) && !plan.NetworkInterfaceNaming.IsUnknown() {
|
||||
req.NetworkInterfaceNaming = plan.NetworkInterfaceNaming.ValueString()
|
||||
}
|
||||
|
||||
if !plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset) {
|
||||
req.Chipset = plan.Chipset.ValueString()
|
||||
@@ -413,6 +448,10 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
|
||||
req.PreferredCPU = []int64{-1}
|
||||
}
|
||||
|
||||
if !plan.LoaderType.IsUnknown() && !plan.LoaderType.Equal(state.Description) {
|
||||
req.Description = plan.Description.ValueString()
|
||||
}
|
||||
|
||||
// Note bene: numa_affinity, cpu_pin and hp_backed are not allowed to be changed for compute in STARTED tech status.
|
||||
// If STARTED, we need to stop it before update
|
||||
|
||||
@@ -917,19 +956,35 @@ func ComputeResourceSnapshotUpdate(ctx context.Context, state *models.ResourceCo
|
||||
addedLabel, deleteLabel := differenceSnapshot(state.Snapshot, plan.Snapshot)
|
||||
|
||||
for _, label := range deleteLabel {
|
||||
req := compute.SnapshotDeleteRequest{ComputeID: computeId}
|
||||
objTag := label.(types.Object)
|
||||
tagMap := objTag.Attributes()
|
||||
req.Label = tagMap["label"].(types.String).ValueString()
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().SnapshotDelete(ctx, req)
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "response": res})
|
||||
if err != nil {
|
||||
diags.AddError(
|
||||
"ComputeResourceSnapshotUpdate: Unable to delete snapshot for Compute",
|
||||
err.Error(),
|
||||
)
|
||||
reqLabel := tagMap["label"].(types.String).ValueString()
|
||||
req := compute.SnapshotDeleteRequest{ComputeID: computeId, Label: reqLabel}
|
||||
if (state.SnapshotDeleteAsync).ValueBool() {
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDeleteAsync", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().SnapshotDeleteAsync(ctx, req)
|
||||
req.Label = reqLabel
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDeleteAsync", map[string]any{"compute_id": computeId, "response": res})
|
||||
if err != nil {
|
||||
diags.AddError(
|
||||
"ComputeResourceSnapshotUpdate: Unable to async delete snapshot for Compute",
|
||||
err.Error(),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: before calling CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().SnapshotDelete(ctx, req)
|
||||
req.Label = reqLabel
|
||||
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: response from CloudAPI().Compute().SnapshotDelete", map[string]any{"compute_id": computeId, "response": res})
|
||||
if err != nil {
|
||||
diags.AddError(
|
||||
"ComputeResourceSnapshotUpdate: Unable to delete snapshot for Compute",
|
||||
err.Error(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if diags.HasError() {
|
||||
@@ -1023,7 +1078,7 @@ func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeMo
|
||||
return diags
|
||||
}
|
||||
|
||||
if plan.CD.IsNull() {
|
||||
if plan.CDImageID.IsNull() {
|
||||
tflog.Info(ctx, "ComputeResourceCDUpdate: before calling CloudAPI().Compute().CDEject", map[string]any{"compute_id": computeId})
|
||||
res, err := c.CloudAPI().Compute().CDEject(ctx, compute.CDEjectRequest{ComputeID: computeId})
|
||||
tflog.Info(ctx, "ComputeResourceCDUpdate: response from CloudAPI().Compute().CDEject", map[string]any{"compute_id": computeId, "response": res})
|
||||
@@ -1036,7 +1091,7 @@ func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeMo
|
||||
}
|
||||
} else {
|
||||
req := compute.CDInsertRequest{ComputeID: computeId}
|
||||
req.CDROMID = uint64(plan.CD.Attributes()["cdrom_id"].(types.Int64).ValueInt64())
|
||||
req.CDROMID = uint64(plan.CDImageID.ValueInt64())
|
||||
tflog.Info(ctx, "ComputeResourceCDUpdate: before calling CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "req": req})
|
||||
res, err := c.CloudAPI().Compute().CDInsert(ctx, req)
|
||||
tflog.Info(ctx, "ComputeResourceCDUpdate: response from CloudAPI().Compute().CDInsert", map[string]any{"compute_id": computeId, "response": res})
|
||||
@@ -1188,17 +1243,14 @@ func ComputeResourceRedeploy(ctx context.Context, plan *models.ResourceComputeMo
|
||||
req := compute.RedeployRequest{
|
||||
ComputeID: computeId,
|
||||
ImageID: uint64(plan.ImageID.ValueInt64()),
|
||||
DataDisks: "detach",
|
||||
DataDisks: "KEEP",
|
||||
}
|
||||
|
||||
if !plan.BootDiskSize.IsNull() {
|
||||
req.DiskSize = uint64(plan.BootDiskSize.ValueInt64())
|
||||
}
|
||||
if !plan.DataDisks.IsNull() {
|
||||
req.DataDisks = plan.DataDisks.ValueString()
|
||||
}
|
||||
if !plan.AutoStart.IsNull() {
|
||||
req.AutoStart = plan.AutoStart.ValueBool()
|
||||
if !plan.Started.IsNull() {
|
||||
req.AutoStart = plan.Started.ValueBool()
|
||||
}
|
||||
if !plan.ForceStop.IsNull() {
|
||||
req.ForceStop = plan.ForceStop.ValueBool()
|
||||
|
||||
@@ -27,11 +27,11 @@ func LBResource(ctx context.Context, plan *models.ResourceLBModel, c *client.Cli
|
||||
acl, _ := json.Marshal(recordItemLB.ACL)
|
||||
|
||||
*plan = models.ResourceLBModel{
|
||||
RGID: plan.RGID,
|
||||
Name: plan.Name,
|
||||
ExtNetID: plan.ExtNetID,
|
||||
VINSID: plan.VINSID,
|
||||
Start: plan.Start,
|
||||
RGID: types.Int64Value(int64(recordItemLB.RGID)),
|
||||
Name: types.StringValue(recordItemLB.Name),
|
||||
ExtNetID: types.Int64Value(int64(recordItemLB.ExtNetID)),
|
||||
VINSID: types.Int64Value(int64(recordItemLB.VINSID)),
|
||||
Start: types.BoolValue(recordItemLB.TechStatus == "STARTED"),
|
||||
ID: plan.ID,
|
||||
|
||||
HAMode: types.BoolValue(recordItemLB.HAMode),
|
||||
@@ -41,7 +41,7 @@ func LBResource(ctx context.Context, plan *models.ResourceLBModel, c *client.Cli
|
||||
Permanently: plan.Permanently,
|
||||
Restore: plan.Restore,
|
||||
Restart: plan.Restart,
|
||||
Enable: plan.Enable,
|
||||
Enable: types.BoolValue(recordItemLB.Status == "ENABLED"),
|
||||
ConfigReset: plan.ConfigReset,
|
||||
|
||||
ACL: types.StringValue(string(acl)),
|
||||
|
||||
@@ -25,7 +25,7 @@ func LBBackendResource(ctx context.Context, plan *models.ResourceLBBackendModel,
|
||||
|
||||
*plan = models.ResourceLBBackendModel{
|
||||
LBID: plan.LBID,
|
||||
Name: plan.Name,
|
||||
Name: types.StringValue(recordItemBackend.Name),
|
||||
ID: plan.ID,
|
||||
Timeouts: plan.Timeouts,
|
||||
GUID: types.StringValue(recordItemBackend.GUID),
|
||||
|
||||
@@ -24,9 +24,10 @@ func LBBackendServerResource(ctx context.Context, plan *models.ResourceLBBackend
|
||||
*plan = models.ResourceLBBackendServerModel{
|
||||
LBID: plan.LBID,
|
||||
Backend: plan.Backend,
|
||||
Name: plan.Name,
|
||||
Address: plan.Address,
|
||||
Port: plan.Port,
|
||||
Name: types.StringValue(recordItemServer.Name),
|
||||
Address: types.StringValue(recordItemServer.Address),
|
||||
Port: types.Int64Value(int64(recordItemServer.Port)),
|
||||
GUID: types.StringValue(recordItemServer.GUID),
|
||||
ID: plan.ID,
|
||||
Timeouts: plan.Timeouts,
|
||||
Check: types.StringValue(recordItemServer.Check),
|
||||
|
||||
@@ -25,7 +25,7 @@ func LBFrontendResource(ctx context.Context, plan *models.ResourceLBFrontendMode
|
||||
|
||||
*plan = models.ResourceLBFrontendModel{
|
||||
LBID: plan.LBID,
|
||||
Name: plan.Name,
|
||||
Name: types.StringValue(recordItemFrontend.Name),
|
||||
Backend: plan.Backend,
|
||||
ID: plan.ID,
|
||||
Timeouts: plan.Timeouts,
|
||||
|
||||
@@ -22,14 +22,14 @@ func LBFrontendBindResource(ctx context.Context, plan *models.ResourceLBFrontend
|
||||
}
|
||||
|
||||
*plan = models.ResourceLBFrontendBindModel{
|
||||
Address: plan.Address,
|
||||
Address: types.StringValue(recordItemFrontendBind.Address),
|
||||
Frontend: plan.Frontend,
|
||||
LBID: plan.LBID,
|
||||
Name: plan.Name,
|
||||
Name: types.StringValue(recordItemFrontendBind.Name),
|
||||
ID: plan.ID,
|
||||
Timeouts: plan.Timeouts,
|
||||
GUID: types.StringValue(recordItemFrontendBind.GUID),
|
||||
Port: plan.Port,
|
||||
Port: types.Int64Value(int64(recordItemFrontendBind.Port)),
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "End flattens.LBFrontendBindResource", map[string]any{"name": plan.Name.ValueString()})
|
||||
|
||||
@@ -30,6 +30,7 @@ func MakeSchemaResourceLB() map[string]schema.Attribute {
|
||||
"ha_mode": schema.BoolAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Default: booldefault.StaticBool(false),
|
||||
},
|
||||
"desc": schema.StringAttribute{
|
||||
Optional: true,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user