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

@@ -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")