Skip to content

Commit

Permalink
remove :
Browse files Browse the repository at this point in the history
me_installation_template
me_installation_templates
me_installation_template_partition*
migrate dedicated server install task to reinstall task
  • Loading branch information
bigbigbang committed Feb 18, 2025
1 parent cc939c8 commit dd43b15
Show file tree
Hide file tree
Showing 36 changed files with 6,153 additions and 4,044 deletions.
434 changes: 0 additions & 434 deletions ovh/data_me_installation_template.go

This file was deleted.

72 changes: 0 additions & 72 deletions ovh/data_me_installation_template_test.go

This file was deleted.

43 changes: 0 additions & 43 deletions ovh/data_me_installation_templates.go

This file was deleted.

70 changes: 0 additions & 70 deletions ovh/data_me_installation_templates_test.go

This file was deleted.

9 changes: 9 additions & 0 deletions ovh/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ func GetNilStringPointerFromData(data interface{}, id string) *string {
return nil
}

func GetMapFromData(data interface{}, id string) map[string]interface{} {
if resourceData, tok := data.(*schema.ResourceData); tok {
return resourceData.Get(id).(map[string]interface{})
} else if mapData, tok := data.(map[string]interface{}); tok {
return mapData[id].(map[string]interface{})
}
return nil
}

// GetNilIntPointerFromDataAndNilIfNotPresent similar to GetNilIntPointerFromData but use terraform function schema.ResourceData.Get instead of schema.ResourceData.GetOk
func GetNilIntPointerFromDataAndNilIfNotPresent(data interface{}, id string) *int {
if resourceData, tok := data.(*schema.ResourceData); tok {
Expand Down

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions ovh/import_me_installation_template_partition_scheme_test.go

This file was deleted.

32 changes: 0 additions & 32 deletions ovh/import_me_installation_template_test.go

This file was deleted.

8 changes: 1 addition & 7 deletions ovh/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ func Provider() *schema.Provider {
"ovh_me_identity_groups": dataSourceMeIdentityGroups(),
"ovh_me_identity_user": dataSourceMeIdentityUser(),
"ovh_me_identity_users": dataSourceMeIdentityUsers(),
"ovh_me_installation_template": dataSourceMeInstallationTemplate(),
"ovh_me_installation_templates": dataSourceMeInstallationTemplates(),
"ovh_me_paymentmean_bankaccount": dataSourceMePaymentmeanBankaccount(),
"ovh_me_paymentmean_creditcard": dataSourceMePaymentmeanCreditcard(),
"ovh_order_cart": dataSourceOrderCart(),
Expand Down Expand Up @@ -237,7 +235,7 @@ func Provider() *schema.Provider {
"ovh_dedicated_nasha_partition": resourceDedicatedNASHAPartition(),
"ovh_dedicated_nasha_partition_access": resourceDedicatedNASHAPartitionAccess(),
"ovh_dedicated_nasha_partition_snapshot": resourceDedicatedNASHAPartitionSnapshot(),
"ovh_dedicated_server_install_task": resourceDedicatedServerInstallTask(),
"ovh_dedicated_server_reinstall_task": resourceDedicatedServerReinstallTask(),
"ovh_dedicated_server_reboot_task": resourceDedicatedServerRebootTask(),
"ovh_dedicated_server_update": resourceDedicatedServerUpdate(),
"ovh_dedicated_server_networking": resourceDedicatedServerNetworking(),
Expand Down Expand Up @@ -271,10 +269,6 @@ func Provider() *schema.Provider {
"ovh_me_identity_group": resourceMeIdentityGroup(),
"ovh_me_api_oauth2_client": resourceApiOauth2Client(),
"ovh_me_identity_user": resourceMeIdentityUser(),
"ovh_me_installation_template": resourceMeInstallationTemplate(),
"ovh_me_installation_template_partition_scheme": resourceMeInstallationTemplatePartitionScheme(),
"ovh_me_installation_template_partition_scheme_hardware_raid": resourceMeInstallationTemplatePartitionSchemeHardwareRaid(),
"ovh_me_installation_template_partition_scheme_partition": resourceMeInstallationTemplatePartitionSchemePartition(),
"ovh_savings_plan": resourceSavingsPlan(),
"ovh_vrack": resourceVrack(),
"ovh_vrack_cloudproject": resourceVrackCloudProject(),
Expand Down
16 changes: 10 additions & 6 deletions ovh/resource_dedicated_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ func (r *dedicatedServerResource) Update(ctx context.Context, req resource.Updat
responseData.MergeWith(&planData)
responseData.MergeWith(&stateData)

// Explicitely set UserMetadata to what was defined in the plan
// Explicitely set Customizations/Properties/Storage to what was defined in the plan
// as we can't determine the right thing to do in MergeWith function
responseData.UserMetadata = planData.UserMetadata
responseData.Customizations = planData.Customizations
responseData.Properties = planData.Properties
responseData.Storage = planData.Storage

// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &responseData)...)
Expand Down Expand Up @@ -281,12 +283,14 @@ func (r *dedicatedServerResource) updateDedicatedServerResource(ctx context.Cont
// Check if server needs to be reinstalled
var shouldReinstall bool
if stateData != nil {
if stateData.TemplateName.ValueString() != planData.TemplateName.ValueString() ||
!stateData.UserMetadata.Equal(planData.UserMetadata) {
if stateData.OperatingSystem.ValueString() != planData.OperatingSystem.ValueString() ||
!stateData.Customizations.Equal(planData.Customizations) ||
!stateData.Storage.Equal(planData.Storage) ||
!stateData.Properties.Equal(planData.Properties) {
shouldReinstall = true
}
} else {
if planData.TemplateName.ValueString() != "" {
if planData.OperatingSystem.ValueString() != "" {
shouldReinstall = true
}
}
Expand All @@ -298,7 +302,7 @@ func (r *dedicatedServerResource) updateDedicatedServerResource(ctx context.Cont
}

// Trigger server reinstallation
endpoint := "/dedicated/server/" + url.PathEscape(serviceName) + "/install/start"
endpoint := "/dedicated/server/" + url.PathEscape(serviceName) + "/reinstall"
if shouldReinstall {
log.Print("Triggering server reinstallation")
task := DedicatedServerTask{}
Expand Down
Loading

0 comments on commit dd43b15

Please sign in to comment.