This commit is contained in:
asteam
2025-01-21 12:16:49 +03:00
parent 76ea459b3d
commit 60e23338ad
751 changed files with 17877 additions and 1908 deletions

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceCompute() datasource.DataSource {
// dataSourceCompute is the data source implementation.
type dataSourceCompute struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceCompute) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeAudits() datasource.DataSource {
// dataSourceComputeAudits is the data source implementation.
type dataSourceComputeAudits struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeAudits) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeGetAudits() datasource.DataSource {
// dataSourceComputeGetAudits is the data source implementation.
type dataSourceComputeGetAudits struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeGetAudits) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeGetConsoleUrl() datasource.DataSource {
// dataSourceComputeGetConsoleUrl is the data source implementation.
type dataSourceComputeGetConsoleUrl struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeGetConsoleUrl) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeGetLog() datasource.DataSource {
// dataSourceComputeGetLog is the data source implementation.
type dataSourceComputeGetLog struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeGetLog) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeList() datasource.DataSource {
// dataSourceComputeList is the data source implementation.
type dataSourceComputeList struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeListDeleted() datasource.DataSource {
// dataSourceComputeListDeleted is the data source implementation.
type dataSourceComputeListDeleted struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeListDeleted) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputePciDeviceList() datasource.DataSource {
// dataSourceComputePciDeviceList is the data source implementation.
type dataSourceComputePciDeviceList struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputePciDeviceList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputePFWList() datasource.DataSource {
// dataSourceComputePFWList is the data source implementation.
type dataSourceComputePFWList struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputePFWList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeSnapshotUsage() datasource.DataSource {
// dataSourceComputeSnapshotUsage is the data source implementation.
type dataSourceComputeSnapshotUsage struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeSnapshotUsage) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeUserList() datasource.DataSource {
// dataSourceComputeUserList is the data source implementation.
type dataSourceComputeUserList struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeUserList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -7,7 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/constants"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/flattens"
@@ -26,7 +25,7 @@ func NewDataSourceComputeVGPUList() datasource.DataSource {
// dataSourceComputeVGPUList is the data source implementation.
type dataSourceComputeVGPUList struct {
client *decort.DecortClient
client *client.Client
}
func (d *dataSourceComputeVGPUList) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {

View File

@@ -9,14 +9,14 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/flattens"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceCompute")
diags := diag.Diagnostics{}
@@ -47,6 +47,7 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
AffinityWeight: types.Int64Value(int64(computeRecord.AffinityWeight)),
AntiAffinityRules: flattenAffinityRule(ctx, &computeRecord.AntiAffinityRules),
Architecture: types.StringValue(computeRecord.Architecture),
AutoStartWithNode: types.BoolValue(computeRecord.AutoStart),
Chipset: types.StringValue(computeRecord.Chipset),
BootDiskSize: types.Int64Value(int64(computeRecord.BootDiskSize)),
CdImageId: types.Int64Value(int64(computeRecord.CdImageId)),
@@ -103,6 +104,7 @@ func DataSourceCompute(ctx context.Context, state *models.RecordComputeModel, c
Userdata: types.StringValue(string(userdata)),
VirtualImageID: types.Int64Value(int64(computeRecord.VirtualImageID)),
VirtualImageName: types.StringValue(computeRecord.VirtualImageName),
VNCPassword: types.StringValue(computeRecord.VNCPassword),
}
state.BootOrder, diags = types.ListValueFrom(ctx, types.StringType, computeRecord.BootOrder)
if diags != nil {

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeAudits(ctx context.Context, state *models.ListAuditsModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeAudits(ctx context.Context, state *models.ListAuditsModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeAudits")
diags := diag.Diagnostics{}

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeGetAudits(ctx context.Context, state *models.GetAuditsModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeGetAudits(ctx context.Context, state *models.GetAuditsModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeGetAudits")
diags := diag.Diagnostics{}

View File

@@ -7,12 +7,12 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeGetConsoleUrl(ctx context.Context, state *models.GetConsoleUrlModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeGetConsoleUrl(ctx context.Context, state *models.GetConsoleUrlModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeGetConsoleUrl")
diags := diag.Diagnostics{}

View File

@@ -7,12 +7,12 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeGetLog(ctx context.Context, state *models.GetLogModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeGetLog(ctx context.Context, state *models.GetLogModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeGetLog")
diags := diag.Diagnostics{}

View File

@@ -9,13 +9,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeList(ctx context.Context, state *models.ListComputesModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeList(ctx context.Context, state *models.ListComputesModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeList")
diags := diag.Diagnostics{}
@@ -72,6 +72,7 @@ func flattenItemsList(ctx context.Context, computes *compute.ListComputes) []mod
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)),
CdImageId: types.Int64Value(int64(item.CdImageId)),
CloneReference: types.Int64Value(int64(item.CloneReference)),

View File

@@ -9,13 +9,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeListDeleted(ctx context.Context, state *models.ListDeletedComputesModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeListDeleted(ctx context.Context, state *models.ListDeletedComputesModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeListDeleted")
diags := diag.Diagnostics{}
@@ -70,6 +70,7 @@ func flattenItemsListDeleted(ctx context.Context, computes *compute.ListComputes
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)),
CdImageId: types.Int64Value(int64(item.CdImageId)),
Chipset: types.StringValue(item.Chipset),

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputePciDeviceList(ctx context.Context, state *models.ListPCIDevicesModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputePciDeviceList(ctx context.Context, state *models.ListPCIDevicesModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputePciDeviceList")
diags := diag.Diagnostics{}

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputePFWList(ctx context.Context, state *models.ListPFWsModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputePFWList(ctx context.Context, state *models.ListPFWsModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputePFWList")
diags := diag.Diagnostics{}

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeSnapshotUsage(ctx context.Context, state *models.ListSnapShotsModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeSnapshotUsage(ctx context.Context, state *models.ListSnapShotsModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeSnapshotUsage")
diags := diag.Diagnostics{}

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeUserList(ctx context.Context, state *models.ListUsersModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeUserList(ctx context.Context, state *models.ListUsersModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeUserList")
diags := diag.Diagnostics{}

View File

@@ -7,13 +7,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func DataSourceComputeVGPUList(ctx context.Context, state *models.ListVGPUsModel, c *decort.DecortClient) diag.Diagnostics {
func DataSourceComputeVGPUList(ctx context.Context, state *models.ListVGPUsModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start FlattenDataSourceComputeVGPUList")
diags := diag.Diagnostics{}

View File

@@ -8,15 +8,15 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/flattens"
disks "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/disks/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/utilities"
)
func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "Start flattens.ComputeResource")
diags := diag.Diagnostics{}
@@ -48,6 +48,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
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,
@@ -137,6 +138,7 @@ func ComputeResource(ctx context.Context, plan *models.ResourceComputeModel, c *
VGPUs: flattens.FlattenSimpleTypeToList(ctx, types.Int64Type, recordItemCompute.VGPUs),
VirtualImageID: types.Int64Value(int64(recordItemCompute.VirtualImageID)),
VirtualImageName: types.StringValue(recordItemCompute.VirtualImageName),
VNCPassword: types.StringValue(recordItemCompute.VNCPassword),
}
tflog.Info(ctx, "End flattens.ComputeResource", map[string]any{"id": plan.ID.ValueString()})

View File

@@ -8,13 +8,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/ic"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
// resourceComputeInputChecks checks if rg_id and image_id are valid.
func resourceComputeInputChecks(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func resourceComputeInputChecks(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
diags := diag.Diagnostics{}
rgID := uint64(plan.RGID.ValueInt64())

View File

@@ -19,6 +19,7 @@ type RecordComputeModel struct {
AffinityWeight types.Int64 `tfsdk:"affinity_weight"`
AntiAffinityRules []ItemRuleModel `tfsdk:"anti_affinity_rules"`
Architecture types.String `tfsdk:"arch"`
AutoStartWithNode types.Bool `tfsdk:"auto_start_w_node"`
Chipset types.String `tfsdk:"chipset"`
BootOrder types.List `tfsdk:"boot_order"`
BootDiskSize types.Int64 `tfsdk:"bootdisk_size"`
@@ -80,6 +81,7 @@ type RecordComputeModel struct {
VGPUs types.List `tfsdk:"vgpus"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
VirtualImageName types.String `tfsdk:"virtual_image_name"`
VNCPassword types.String `tfsdk:"vnc_password"`
}
type RecordACLModel struct {

View File

@@ -38,6 +38,7 @@ type ItemComputeModel struct {
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"`

View File

@@ -36,6 +36,7 @@ type ItemListDeletedComputeModel struct {
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"`

View File

@@ -22,6 +22,7 @@ type ResourceComputeModel struct {
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"`
@@ -113,6 +114,7 @@ type ResourceComputeModel struct {
VGPUs types.List `tfsdk:"vgpus"`
VirtualImageID types.Int64 `tfsdk:"virtual_image_id"`
VirtualImageName types.String `tfsdk:"virtual_image_name"`
VNCPassword types.String `tfsdk:"vnc_password"`
}
type RecordResourceACLModel struct {

View File

@@ -10,7 +10,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
@@ -33,7 +32,7 @@ func NewResourceCompute() resource.Resource {
// resourceCompute is the resource implementation.
type resourceCompute struct {
client *decort.DecortClient
client *client.Client
}
func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
@@ -148,10 +147,15 @@ func (r *resourceCompute) Create(ctx context.Context, req resource.CreateRequest
}
// pin to stack if needed, warnings added to resp.Diagnostics in case of failure.
if !plan.PinToStack.IsNull() && plan.PinToStack.ValueBool() {
if plan.PinToStack.ValueBool() {
resp.Diagnostics.Append(utilities.ComputeResourcePinToStack(ctx, &plan, r.client)...)
}
// set auto start_w_node if pin_to_stack == false
if !plan.PinToStack.ValueBool() && plan.AutoStartWithNode.ValueBool() {
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() {
resp.Diagnostics.Append(utilities.ComputeResourcePause(ctx, &plan, r.client)...)
@@ -335,7 +339,8 @@ 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.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) {
resp.Diagnostics.Append(utilities.ComputeResourceComputeUpdate(ctx, &state, &plan, r.client)...)
if resp.Diagnostics.HasError() {
tflog.Error(ctx, "Update resourceCompute: Error update compute parameters")
@@ -425,7 +430,7 @@ func (r *resourceCompute) Update(ctx context.Context, req resource.UpdateRequest
}
// pin to stack if needed
if !plan.PinToStack.Equal(state.PinToStack) && !plan.PinToStack.IsNull() {
if !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")

View File

@@ -160,6 +160,9 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"arch": schema.StringAttribute{
Computed: true,
},
"auto_start_w_node": schema.BoolAttribute{
Computed: true,
},
"chipset": schema.StringAttribute{
Computed: true,
},
@@ -708,5 +711,8 @@ func MakeSchemaDataSourceCompute() map[string]schema.Attribute {
"virtual_image_name": schema.StringAttribute{
Computed: true,
},
"vnc_password": schema.StringAttribute{
Computed: true,
},
}
}

View File

@@ -166,6 +166,9 @@ func MakeSchemaDataSourceComputeList() map[string]schema.Attribute {
"arch": schema.StringAttribute{
Computed: true,
},
"auto_start_w_node": schema.BoolAttribute{
Computed: true,
},
"chipset": schema.StringAttribute{
Computed: true,
},

View File

@@ -158,6 +158,9 @@ func MakeSchemaDataSourceComputeListDeleted() map[string]schema.Attribute {
"arch": schema.StringAttribute{
Computed: true,
},
"auto_start_w_node": schema.BoolAttribute{
Computed: true,
},
"chipset": schema.StringAttribute{
Computed: true,
},

View File

@@ -291,6 +291,8 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
"pin_to_stack": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
"description": schema.StringAttribute{
Optional: true,
@@ -345,23 +347,20 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Description: "Flag for redeploy compute",
},
"started": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
//Default: true,
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
Description: "Is compute started.",
},
"detach_disks": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
//Default: true,
},
"permanently": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
//Default: true,
},
"is": schema.StringAttribute{
Optional: true,
@@ -380,13 +379,15 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
Description: "Rule for VM placement with NUMA affinity.",
},
"cpu_pin": schema.BoolAttribute{
Optional: true,
//Default: false,
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "Run VM on dedicated CPUs. To use this feature, the system must be pre-configured by allocating CPUs on the physical node.",
},
"hp_backed": schema.BoolAttribute{
Optional: true,
//Default: false,
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "Use Huge Pages to allocate RAM of the virtual machine. The system must be pre-configured by allocating Huge Pages on the physical node.",
},
"pci_devices": schema.SetAttribute{
@@ -402,6 +403,12 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
},
Description: "Type of the emulated system, Q35 or i440fx",
},
"auto_start_w_node": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Flag for start compute after node exits from MAINTENANCE state",
Default: booldefault.StaticBool(false),
},
// computed attributes
"compute_id": schema.Int64Attribute{
@@ -801,6 +808,9 @@ func MakeSchemaResourceCompute() map[string]schema.Attribute {
"virtual_image_name": schema.StringAttribute{
Computed: true,
},
"vnc_password": schema.StringAttribute{
Computed: true,
},
}
}

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeCheckPresence(ctx context.Context, state *models.RecordComputeModel, c *decort.DecortClient) (*compute.RecordCompute, error) {
func ComputeCheckPresence(ctx context.Context, state *models.RecordComputeModel, c *client.Client) (*compute.RecordCompute, error) {
tflog.Info(ctx, "Get compute info")
req := compute.GetRequest{
@@ -27,7 +27,7 @@ func ComputeCheckPresence(ctx context.Context, state *models.RecordComputeModel,
return computeRecord, nil
}
func ComputePCIDevicesListCheckPresence(ctx context.Context, state *models.RecordComputeModel, c *decort.DecortClient) (*compute.ListPCIDevices, error) {
func ComputePCIDevicesListCheckPresence(ctx context.Context, state *models.RecordComputeModel, c *client.Client) (*compute.ListPCIDevices, error) {
tflog.Info(ctx, "Get PCI devices info")
req := compute.ListPCIDeviceRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeGetAuditsCheckPresence(ctx context.Context, state *models.GetAuditsModel, c *decort.DecortClient) (*compute.ListShortAudits, error) {
func ComputeGetAuditsCheckPresence(ctx context.Context, state *models.GetAuditsModel, c *client.Client) (*compute.ListShortAudits, error) {
tflog.Info(ctx, "Get compute short audits info")
req := compute.GetAuditsRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeAuditsCheckPresence(ctx context.Context, state *models.ListAuditsModel, c *decort.DecortClient) (*compute.ListAudits, error) {
func ComputeAuditsCheckPresence(ctx context.Context, state *models.ListAuditsModel, c *client.Client) (*compute.ListAudits, error) {
tflog.Info(ctx, "Get compute audits list info")
req := compute.AuditsRequest{

View File

@@ -5,12 +5,12 @@ import (
"strings"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeGetConsoleUrlCheckPresence(ctx context.Context, state *models.GetConsoleUrlModel, c *decort.DecortClient) (string, error) {
func ComputeGetConsoleUrlCheckPresence(ctx context.Context, state *models.GetConsoleUrlModel, c *client.Client) (string, error) {
tflog.Info(ctx, "Get compute console url")
req := compute.GetConsoleURLRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeGetLogCheckPresence(ctx context.Context, state *models.GetLogModel, c *decort.DecortClient) (string, error) {
func ComputeGetLogCheckPresence(ctx context.Context, state *models.GetLogModel, c *client.Client) (string, error) {
tflog.Info(ctx, "Get compute log")
req := compute.GetLogRequest{

View File

@@ -5,12 +5,12 @@ import (
"regexp"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeListCheckPresence(ctx context.Context, state *models.ListComputesModel, c *decort.DecortClient) (*compute.ListComputes, error) {
func ComputeListCheckPresence(ctx context.Context, state *models.ListComputesModel, c *client.Client) (*compute.ListComputes, error) {
tflog.Info(ctx, "Get compute list info")
req := compute.ListRequest{}

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeListDeletedCheckPresence(ctx context.Context, state *models.ListDeletedComputesModel, c *decort.DecortClient) (*compute.ListComputes, error) {
func ComputeListDeletedCheckPresence(ctx context.Context, state *models.ListDeletedComputesModel, c *client.Client) (*compute.ListComputes, error) {
tflog.Info(ctx, "Get compute list deleted info")
req := compute.ListDeletedRequest{}

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputePciDeviceListCheckPresence(ctx context.Context, state *models.ListPCIDevicesModel, c *decort.DecortClient) (*compute.ListPCIDevices, error) {
func ComputePciDeviceListCheckPresence(ctx context.Context, state *models.ListPCIDevicesModel, c *client.Client) (*compute.ListPCIDevices, error) {
tflog.Info(ctx, "Get compute pci device list info")
req := compute.ListPCIDeviceRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputePFWListCheckPresence(ctx context.Context, state *models.ListPFWsModel, c *decort.DecortClient) (*compute.ListPFWs, error) {
func ComputePFWListCheckPresence(ctx context.Context, state *models.ListPFWsModel, c *client.Client) (*compute.ListPFWs, error) {
tflog.Info(ctx, "Get compute pfw list info")
req := compute.PFWListRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeSnapshotUsageCheckPresence(ctx context.Context, state *models.ListSnapShotsModel, c *decort.DecortClient) (*compute.ListUsageSnapshots, error) {
func ComputeSnapshotUsageCheckPresence(ctx context.Context, state *models.ListSnapShotsModel, c *client.Client) (*compute.ListUsageSnapshots, error) {
tflog.Info(ctx, "Get compute snapshot usage info")
req := compute.SnapshotUsageRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeUserListCheckPresence(ctx context.Context, state *models.ListUsersModel, c *decort.DecortClient) (*compute.ListUsers, error) {
func ComputeUserListCheckPresence(ctx context.Context, state *models.ListUsersModel, c *client.Client) (*compute.ListUsers, error) {
tflog.Info(ctx, "Get compute user list info")
req := compute.UserListRequest{

View File

@@ -4,12 +4,12 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeVGPUListCheckPresence(ctx context.Context, state *models.ListVGPUsModel, c *decort.DecortClient) (*compute.ListVGPUs, error) {
func ComputeVGPUListCheckPresence(ctx context.Context, state *models.ListVGPUsModel, c *client.Client) (*compute.ListVGPUs, error) {
tflog.Info(ctx, "Get compute vgpu list info")
req := compute.ListVGPURequest{

View File

@@ -10,14 +10,14 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmx86"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/status"
)
func ComputeResourceCheckPresence(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) (*compute.RecordCompute, diag.Diagnostics) {
func ComputeResourceCheckPresence(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) (*compute.RecordCompute, diag.Diagnostics) {
tflog.Info(ctx, fmt.Sprintf("ComputeResourceCheckPresence: Get info about compute with ID - %v", plan.ID.ValueString()))
diags := diag.Diagnostics{}
@@ -54,7 +54,7 @@ func ComputeResourceCheckDetachDisks(state *models.ResourceComputeModel, recordC
return true
}
func ComputeResourceBootDiskCheckPresence(ctx context.Context, state *models.ResourceComputeModel, c *decort.DecortClient) (*compute.ItemComputeDisk, diag.Diagnostics) {
func ComputeResourceBootDiskCheckPresence(ctx context.Context, state *models.ResourceComputeModel, c *client.Client) (*compute.ItemComputeDisk, diag.Diagnostics) {
tflog.Info(ctx, "ComputeResourceBootDiskCheckPresence: Get info about boot disk")
diags := diag.Diagnostics{}
@@ -75,7 +75,7 @@ func ComputeResourceBootDiskCheckPresence(ctx context.Context, state *models.Res
return bootDisk, nil
}
func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) (uint64, diag.Diagnostics) {
func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) (uint64, diag.Diagnostics) {
tflog.Info(ctx, fmt.Sprintf("CreateResourceCompute: Start create ResourceCompute: name %s", plan.Name.ValueString()))
diags := diag.Diagnostics{}
@@ -183,11 +183,11 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
createReqX86.NumaAffinity = strings.ToLower(plan.NumaAffinity.ValueString())
}
if !plan.CPUPin.IsNull() && plan.CPUPin.ValueBool() {
if plan.CPUPin.ValueBool() {
createReqX86.CPUPin = true
}
if !plan.HPBacked.IsNull() && plan.HPBacked.ValueBool() {
if plan.HPBacked.ValueBool() {
createReqX86.HPBacked = true
}
@@ -201,7 +201,7 @@ func CreateResourceCompute(ctx context.Context, plan *models.ResourceComputeMode
}
func CleanupResourceCompute(ctx context.Context, computeId uint64, c *decort.DecortClient) {
func CleanupResourceCompute(ctx context.Context, computeId uint64, c *client.Client) {
tflog.Info(ctx, fmt.Sprintf("CleanupResourceCompute: Start delete ResourceCompute: id %d", computeId))
req := compute.DeleteRequest{
ComputeID: computeId,
@@ -214,7 +214,7 @@ func CleanupResourceCompute(ctx context.Context, computeId uint64, c *decort.Dec
}
}
func ComputeResourceExtraDiskCreate(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceExtraDiskCreate(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeExtraDiskCreate: Start added extra disk(s) from compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -243,7 +243,7 @@ func ComputeResourceExtraDiskCreate(ctx context.Context, plan *models.ResourceCo
return diags
}
func ComputeResourceEnableDisable(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceEnableDisable(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeEnableDisable: Start enabled/disabled compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -283,7 +283,7 @@ func ComputeResourceEnableDisable(ctx context.Context, plan *models.ResourceComp
return nil
}
func ComputeResourceStartStop(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceStartStop(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeStartStop: Start started/stopped compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -323,7 +323,7 @@ func ComputeResourceStartStop(ctx context.Context, plan *models.ResourceComputeM
return nil
}
func ComputeResourceAffinityLabel(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAffinityLabel(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeAffinityLabel: Start added affinity label to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -351,7 +351,7 @@ func ComputeResourceAffinityLabel(ctx context.Context, plan *models.ResourceComp
return nil
}
func ComputeResourceAffinityRules(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAffinityRules(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeAffinityRules: Start added affinity rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -401,7 +401,7 @@ func ComputeResourceAffinityRules(ctx context.Context, plan *models.ResourceComp
return nil
}
func ComputeResourceAntiAffinityRules(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAntiAffinityRules(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeAntiAffinityRules: Start added anti affinity rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -451,7 +451,7 @@ func ComputeResourceAntiAffinityRules(ctx context.Context, plan *models.Resource
return nil
}
func ComputeResourceTags(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceTags(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceTags: Start added tags to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -485,7 +485,7 @@ func ComputeResourceTags(ctx context.Context, plan *models.ResourceComputeModel,
return nil
}
func ComputeResourcePortForwarding(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePortForwarding(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePortForwarding: Start added port forwarding to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -537,7 +537,7 @@ func ComputeResourcePortForwarding(ctx context.Context, plan *models.ResourceCom
return nil
}
func ComputeResourceUserAccess(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceUserAccess(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceUserAccess: Start added user(s) access to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -571,7 +571,7 @@ func ComputeResourceUserAccess(ctx context.Context, plan *models.ResourceCompute
return nil
}
func ComputeResourceSnapshot(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceSnapshot(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceSnapshot: Start added snapshot to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -604,7 +604,7 @@ func ComputeResourceSnapshot(ctx context.Context, plan *models.ResourceComputeMo
return nil
}
func ComputeResourcePCIDevice(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePCIDevice(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePCIDevice: Start added PCI devices(s) to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -639,7 +639,7 @@ func ComputeResourcePCIDevice(ctx context.Context, plan *models.ResourceComputeM
return nil
}
func ComputeResourceCDInsert(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceCDInsert(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceCDInsert: Start added cd to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -666,7 +666,7 @@ func ComputeResourceCDInsert(ctx context.Context, plan *models.ResourceComputeMo
return nil
}
func ComputeResourcePinToStack(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePinToStack(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePinToStack: Start pin to stack compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -676,7 +676,12 @@ func ComputeResourcePinToStack(ctx context.Context, plan *models.ResourceCompute
return diags
}
_, err = c.CloudAPI().Compute().PinToStack(ctx, compute.PinToStackRequest{ComputeID: computeId})
req := compute.PinToStackRequest{
ComputeID: computeId,
AutoStart: plan.AutoStartWithNode.ValueBool(),
}
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
if err != nil {
diags.AddWarning(
"ComputeResourcePinToStack: cannot pin to stack compute", err.Error(),
@@ -688,7 +693,7 @@ func ComputeResourcePinToStack(ctx context.Context, plan *models.ResourceCompute
return nil
}
func ComputeResourcePause(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePause(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePause: Start pause compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -709,7 +714,7 @@ func ComputeResourcePause(ctx context.Context, plan *models.ResourceComputeModel
tflog.Info(ctx, "ComputeResourcePause: compute is successfully pause", map[string]any{"compute_id": computeId})
return nil
}
func ComputeReadStatus(ctx context.Context, state *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeReadStatus(ctx context.Context, state *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeReadStatus: Read status compute with ID", map[string]any{"rg_id": state.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -783,7 +788,7 @@ func ComputeReadStatus(ctx context.Context, state *models.ResourceComputeModel,
return nil
}
func RestoreCompute(ctx context.Context, computeId uint64, c *decort.DecortClient) diag.Diagnostics {
func RestoreCompute(ctx context.Context, computeId uint64, c *client.Client) diag.Diagnostics {
diags := diag.Diagnostics{}
restoreReq := compute.RestoreRequest{ComputeID: computeId}
@@ -802,3 +807,32 @@ func RestoreCompute(ctx context.Context, computeId uint64, c *decort.DecortClien
return nil
}
func ComputeResourceAutoStartWithNode(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceAutoStartWithNode: Start set auto start with node to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
computeId, err := strconv.ParseUint(plan.ID.ValueString(), 10, 64)
if err != nil {
diags.AddError("ComputeResourceAutoStartWithNode: cannot parsed ID compute from plan", err.Error())
return diags
}
req := compute.UpdateRequest{
ComputeID: computeId,
AutoStart: plan.AutoStartWithNode.ValueBool(),
CPUPin: plan.CPUPin.ValueBool(),
HPBacked: plan.HPBacked.ValueBool(),
}
_, err = c.CloudAPI().Compute().Update(ctx, req)
if err != nil {
diags.AddWarning(
"ComputeResourceAutoStartWithNode: cannot update compute", err.Error(),
)
return diags
}
tflog.Info(ctx, "ComputeResourceAutoStartWithNode: auto start with node set is successfully", map[string]any{"compute_id": computeId})
return nil
}

View File

@@ -12,13 +12,13 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/client"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/ic"
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/kvmvm/models"
)
func ComputeResourceResize(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceResize(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceResize: start resize compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -68,7 +68,7 @@ func ComputeResourceResize(ctx context.Context, state *models.ResourceComputeMod
return nil
}
func ComputeResourceBootDiskResize(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceBootDiskResize(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceBootDiskResize: start resize boot disk size", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -115,7 +115,7 @@ func ComputeResourceBootDiskResize(ctx context.Context, state *models.ResourceCo
return nil
}
func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceExtraDiskUpdate: start update extra disk(s) list to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -183,7 +183,7 @@ func ComputeResourceExtraDiskUpdate(ctx context.Context, state *models.ResourceC
return nil
}
func ComputeResourcePCIDeviceUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePCIDeviceUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePCIDeviceUpdate: start update PCI device(s) list to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -232,7 +232,7 @@ func ComputeResourcePCIDeviceUpdate(ctx context.Context, state *models.ResourceC
return nil
}
func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceNetworkUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceNetworkUpdate: start update network rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -358,7 +358,7 @@ func hasDPDKnetwork(networkAttachMap []map[string]attr.Value) bool {
return false
}
func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
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{}
@@ -384,17 +384,9 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
req.NumaAffinity = plan.NumaAffinity.ValueString()
}
if !plan.CPUPin.Equal(state.CPUPin) {
req.CPUPin = plan.CPUPin.ValueBool()
} else if state.CPUPin.ValueBool() {
req.CPUPin = state.CPUPin.ValueBool()
}
if !plan.HPBacked.Equal(state.HPBacked) {
req.HPBacked = plan.HPBacked.ValueBool()
} else if state.HPBacked.ValueBool() {
req.HPBacked = state.HPBacked.ValueBool()
}
req.CPUPin = plan.CPUPin.ValueBool()
req.HPBacked = plan.HPBacked.ValueBool()
req.AutoStart = plan.AutoStartWithNode.ValueBool()
if !plan.Chipset.IsUnknown() && !plan.Chipset.Equal(state.Chipset) {
req.Chipset = plan.Chipset.ValueString()
@@ -404,7 +396,7 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
// If STARTED, we need to stop it before update
var isStopRequred bool
if !plan.NumaAffinity.Equal(state.NumaAffinity) || !plan.CPUPin.Equal(state.CPUPin) || !plan.HPBacked.Equal(state.HPBacked) {
if !plan.NumaAffinity.Equal(state.NumaAffinity) || !plan.CPUPin.Equal(state.CPUPin) || !plan.HPBacked.Equal(state.HPBacked) || !plan.Chipset.Equal(state.Chipset) {
isStopRequred = true
tflog.Info(ctx, "ComputeResourceComputeUpdate: stop compute", map[string]any{"compute_id": computeId})
_, err = c.CloudAPI().Compute().Stop(ctx, compute.StopRequest{ComputeID: computeId})
@@ -440,7 +432,7 @@ func ComputeResourceComputeUpdate(ctx context.Context, state *models.ResourceCom
return nil
}
func ComputeResourceAffinityLabelUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAffinityLabelUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceAffinityLabelUpdate: start resize boot disk size", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -485,7 +477,7 @@ func ComputeResourceAffinityLabelUpdate(ctx context.Context, plan *models.Resour
return nil
}
func ComputeResourceAffinityRulesUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAffinityRulesUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceAffinityRulesUpdate: start update affinity rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -585,7 +577,7 @@ func ComputeResourceAffinityRulesUpdate(ctx context.Context, state *models.Resou
return nil
}
func ComputeResourceAntiAffinityRulesUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceAntiAffinityRulesUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceAntiAffinityRulesUpdate: start update affinity rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -685,7 +677,7 @@ func ComputeResourceAntiAffinityRulesUpdate(ctx context.Context, state *models.R
return nil
}
func ComputeResourceTagsUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceTagsUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceTagsUpdate: start update tags to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -742,7 +734,7 @@ func ComputeResourceTagsUpdate(ctx context.Context, state *models.ResourceComput
return nil
}
func ComputeResourcePortForwardingUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePortForwardingUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePortForwardingUpdate: start update port forwarding rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -834,7 +826,7 @@ func ComputeResourcePortForwardingUpdate(ctx context.Context, state *models.Reso
return nil
}
func ComputeResourceUserAccessUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceUserAccessUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceUserAccessUpdate: start update user access rules to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -891,7 +883,7 @@ func ComputeResourceUserAccessUpdate(ctx context.Context, state *models.Resource
return nil
}
func ComputeResourceSnapshotUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceSnapshotUpdate(ctx context.Context, state *models.ResourceComputeModel, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceSnapshotUpdate: start update snapshot(s) to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -947,7 +939,7 @@ func ComputeResourceSnapshotUpdate(ctx context.Context, state *models.ResourceCo
return nil
}
func ComputeResourceRollback(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceRollback(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceRollback: start rollback to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1000,7 +992,7 @@ func ComputeResourceRollback(ctx context.Context, plan *models.ResourceComputeMo
return nil
}
func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceCDUpdate: start update cd list to compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1039,7 +1031,7 @@ func ComputeResourceCDUpdate(ctx context.Context, plan *models.ResourceComputeMo
return nil
}
func ComputeResourcePinToStackUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePinToStackUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePinToStackUpdate: Start pin/unpin to stack compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1056,7 +1048,11 @@ func ComputeResourcePinToStackUpdate(ctx context.Context, plan *models.ResourceC
"pin_to_stack": pinToStack})
if pinToStack {
_, err = c.CloudAPI().Compute().PinToStack(ctx, compute.PinToStackRequest{ComputeID: computeId})
req := compute.PinToStackRequest{
ComputeID: computeId,
AutoStart: plan.AutoStartWithNode.ValueBool(),
}
_, err = c.CloudAPI().Compute().PinToStack(ctx, req)
tflog.Info(ctx, "ComputeResourcePinToStackUpdate: response from CloudAPI().Compute().PinToStack", map[string]any{"compute_id": computeId})
if err != nil {
diags.AddError(
@@ -1065,6 +1061,12 @@ func ComputeResourcePinToStackUpdate(ctx context.Context, plan *models.ResourceC
return diags
}
} else {
if plan.AutoStartWithNode.ValueBool() {
diags.AddError(
"ComputeResourcePinToStackUpdate: for unpin compute the auto_start_w_node parameter must be false", "",
)
return diags
}
_, err = c.CloudAPI().Compute().UnpinFromStack(ctx, compute.UnpinFromStackRequest{ComputeID: computeId})
tflog.Info(ctx, "ComputeResourcePinToStackUpdate: response from CloudAPI().Compute().UnpinFromStack", map[string]any{"compute_id": computeId})
if err != nil {
@@ -1079,7 +1081,7 @@ func ComputeResourcePinToStackUpdate(ctx context.Context, plan *models.ResourceC
return nil
}
func ComputeResourcePauseResumeCompute(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourcePauseResumeCompute(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourcePauseResumeCompute: Start pause/resume compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1119,7 +1121,7 @@ func ComputeResourcePauseResumeCompute(ctx context.Context, plan *models.Resourc
return nil
}
func ComputeResourceResetCompute(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceResetCompute(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceResetCompute: Start reset compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1143,7 +1145,7 @@ func ComputeResourceResetCompute(ctx context.Context, plan *models.ResourceCompu
return nil
}
func ComputeResourceRedeploy(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceRedeploy(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceRedeploy: Start redeploy compute with ID", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}
@@ -1203,7 +1205,7 @@ func ComputeResourceRedeploy(ctx context.Context, plan *models.ResourceComputeMo
return nil
}
func ComputeResourceCustomFieldUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *decort.DecortClient) diag.Diagnostics {
func ComputeResourceCustomFieldUpdate(ctx context.Context, plan *models.ResourceComputeModel, c *client.Client) diag.Diagnostics {
tflog.Info(ctx, "ComputeResourceCustomFieldUpdate: start update custom fields", map[string]any{"compute_id": plan.ID.ValueString()})
diags := diag.Diagnostics{}