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

@@ -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{}