-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlvm upgrade include new features #15945
Changes from 24 commits
7d10f36
e838ed9
0f2da95
5940a09
730ae2f
64b24ba
eca962d
916fee7
e673a25
764987d
5520ecb
8f6b48d
67fd530
482e02d
26805c9
f93d58b
94db1e0
1ff4bba
cac7f1e
69867b5
76824cd
1df346f
87b8b23
4ace720
c37f24a
b55d31c
de7c092
4e967bf
4ed6162
8bf6a2f
89d2631
5d3d88e
13c8454
8ef3957
42e7810
6397155
9bdef9c
87d5c95
43afd2e
a877a5f
c7ac9e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -180,6 +180,45 @@ func resourceMsSqlVirtualMachine() *pluginsdk.Resource { | |||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
|
||||||||||
"assessment_settings": { | ||||||||||
Type: pluginsdk.TypeList, | ||||||||||
Optional: true, | ||||||||||
MaxItems: 1, | ||||||||||
Elem: &pluginsdk.Resource{ | ||||||||||
Schema: map[string]*pluginsdk.Schema{ | ||||||||||
"schedule": { | ||||||||||
Type: pluginsdk.TypeList, | ||||||||||
Optional: true, | ||||||||||
MaxItems: 1, | ||||||||||
Elem: &pluginsdk.Resource{ | ||||||||||
"weekly_interval": { | ||||||||||
Type: pluginsdk.TypeInt, | ||||||||||
Optional: true, | ||||||||||
}, | ||||||||||
"monthly_occurrence ": { | ||||||||||
Type: pluginsdk.TypeInt, | ||||||||||
Optional: true, | ||||||||||
}, | ||||||||||
"day_of_week ": { | ||||||||||
Type: pluginsdk.TypeInt, | ||||||||||
Optional: true, | ||||||||||
}, | ||||||||||
"start_time ": { | ||||||||||
Type: pluginsdk.TypeString, | ||||||||||
Optional: true, | ||||||||||
}, | ||||||||||
), | ||||||||||
}, | ||||||||||
|
||||||||||
"run_immediately": { | ||||||||||
Type: pluginsdk.TypeBool, | ||||||||||
Optional: true, | ||||||||||
Default: false, | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
|
||||||||||
"key_vault_credential": { | ||||||||||
Type: pluginsdk.TypeList, | ||||||||||
|
@@ -285,7 +324,12 @@ func resourceMsSqlVirtualMachine() *pluginsdk.Resource { | |||||||||
}, | ||||||||||
"data_settings": helper.StorageSettingSchema(), | ||||||||||
"log_settings": helper.StorageSettingSchema(), | ||||||||||
"temp_db_settings": helper.StorageSettingSchema(), | ||||||||||
"temp_db_settings": helper.SQLTempDBStorageSettingSchema(), | ||||||||||
tikicoder marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
"system_db_on_datadisk_enabled": { | ||||||||||
Type: pluginsdk.TypeBool, | ||||||||||
Optional: true, | ||||||||||
Default: false, | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
|
@@ -359,6 +403,7 @@ func resourceMsSqlVirtualMachineCreateUpdate(d *pluginsdk.ResourceData, meta int | |||||||||
SQLManagement: sqlvirtualmachine.SQLManagementModeFull, | ||||||||||
AutoBackupSettings: expandSqlVirtualMachineAutoBackupSettings(d.Get("auto_backup").([]interface{})), | ||||||||||
AutoPatchingSettings: expandSqlVirtualMachineAutoPatchingSettings(d.Get("auto_patching").([]interface{})), | ||||||||||
AssessmentSettings: expandSqlVirtualMachineAssessmentSettings(d.Get("assessment_settings").([]interface{})), | ||||||||||
KeyVaultCredentialSettings: expandSqlVirtualMachineKeyVaultCredential(d.Get("key_vault_credential").([]interface{})), | ||||||||||
ServerConfigurationsManagementSettings: &sqlvirtualmachine.ServerConfigurationsManagementSettings{ | ||||||||||
AdditionalFeaturesServerConfigurations: &sqlvirtualmachine.AdditionalFeaturesServerConfigurations{ | ||||||||||
|
@@ -724,6 +769,70 @@ func flattenSqlVirtualMachineAutoPatching(autoPatching *sqlvirtualmachine.AutoPa | |||||||||
}, | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func expandSqlVirtualMachineAssessmentSettings(input []interface{}) *sqlvirtualmachine.AssessmentSettings { | ||||||||||
if len(input) == 0 { | ||||||||||
return nil | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return empty AssessmentSettings so that it can be updated to empty?
Suggested change
Suggested change
|
||||||||||
} | ||||||||||
assessmentSetting := input[0].(map[string]interface{}) | ||||||||||
|
||||||||||
if len(assessmentSetting["schedule"]) == 0 { | ||||||||||
schedule_data := nil | ||||||||||
} | ||||||||||
else { | ||||||||||
schedule_data := &sqlvirtualmachine.Schedule{ | ||||||||||
Enable: utils.Bool(true), | ||||||||||
WeeklyInterval: utils.Int32(int32(autoPatchingSetting["weekly_interval"].(int))), | ||||||||||
MonthlyOccurrence: utils.Int32(int32(autoPatchingSetting["monthly_occurrence"].(int))), | ||||||||||
DayOfWeek: sqlvirtualmachine.DayOfWeek(autoPatchingSetting["day_of_week"].(string)), | ||||||||||
StartTime: autoPatchingSetting["start_time"] | ||||||||||
} | ||||||||||
} | ||||||||||
return &sqlvirtualmachine.AssessmentSettings{ | ||||||||||
Enable: utils.Bool(true), | ||||||||||
RunImmediately: utils.Bool(assessmentSetting["run_immediately"].(bool)), | ||||||||||
schedule: schedule_data, | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func flattenSqlVirtualMachineAssessmentSettings(assessmentSettings *sqlvirtualmachine.AssessmentSettings) []interface{} { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the invocation in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @myc2h6o Ok I just updated it thanks |
||||||||||
if assessmentSettings == nil || assessmentSettings.Enable == nil || !*assessmentSettings.Enable { | ||||||||||
return []interface{}{} | ||||||||||
} | ||||||||||
|
||||||||||
var runImmediately bool | ||||||||||
if assessmentSettings.RunImmediately != nil { | ||||||||||
runImmediately = *assessmentSettings.RunImmediately | ||||||||||
} | ||||||||||
|
||||||||||
var schedule *sqlvirtualmachine.Schedule | ||||||||||
if assessmentSettings.Schedule != nil { | ||||||||||
var weeklyInterval int32 | ||||||||||
var monthlyOccurrence int32 | ||||||||||
if assessmentSettings.Schedule.WeeklyInterval != nil { | ||||||||||
weeklyInterval = *assessmentSettings.Schedule.WeeklyInterval | ||||||||||
} | ||||||||||
if assessmentSettings.Schedule.MonthlyOccurrence != nil { | ||||||||||
monthlyOccurrence = *assessmentSettings.Schedule.MonthlyOccurrence | ||||||||||
} | ||||||||||
|
||||||||||
schedule = map[string]interface{}{ | ||||||||||
"weekly_interval": weeklyInterval, | ||||||||||
"schedule": schedule, | ||||||||||
"day_of_week": string(assessmentSettings.Schedule.DayOfWeek), | ||||||||||
"start_time": string(assessmentSettings.Schedule.StartTime ), | ||||||||||
} | ||||||||||
|
||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty line |
||||||||||
} | ||||||||||
|
||||||||||
return []interface{}{ | ||||||||||
map[string]interface{}{ | ||||||||||
"run_immediately": runImmediately, | ||||||||||
"schedule": schedule, | ||||||||||
}, | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func expandSqlVirtualMachineKeyVaultCredential(input []interface{}) *sqlvirtualmachine.KeyVaultCredentialSettings { | ||||||||||
if len(input) == 0 { | ||||||||||
|
@@ -798,6 +907,7 @@ func expandSqlVirtualMachineStorageConfigurationSettings(input []interface{}) *s | |||||||||
SQLDataSettings: expandSqlVirtualMachineDataStorageSettings(storageSettings["data_settings"].([]interface{})), | ||||||||||
SQLLogSettings: expandSqlVirtualMachineDataStorageSettings(storageSettings["log_settings"].([]interface{})), | ||||||||||
SQLTempDbSettings: expandSqlVirtualMachineTempDbSettings(storageSettings["temp_db_settings"].([]interface{})), | ||||||||||
SQLSystemDbOnDataDisk: utils.Bool(storageSettings["sql_system_db_on_datadisk"].(bool)), | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -807,11 +917,12 @@ func flattenSqlVirtualMachineStorageConfigurationSettings(input *sqlvirtualmachi | |||||||||
} | ||||||||||
|
||||||||||
output := map[string]interface{}{ | ||||||||||
"storage_workload_type": storageWorkloadType, | ||||||||||
"disk_type": string(input.DiskConfigurationType), | ||||||||||
"data_settings": flattenSqlVirtualMachineStorageSettings(input.SQLDataSettings), | ||||||||||
"log_settings": flattenSqlVirtualMachineStorageSettings(input.SQLLogSettings), | ||||||||||
"temp_db_settings": flattenSqlVirtualMachineTempDbSettings(input.SQLTempDbSettings), | ||||||||||
"storage_workload_type": storageWorkloadType, | ||||||||||
"disk_type": string(input.DiskConfigurationType), | ||||||||||
"data_settings": flattenSqlVirtualMachineStorageSettings(input.SQLDataSettings), | ||||||||||
"log_settings": flattenSqlVirtualMachineStorageSettings(input.SQLLogSettings), | ||||||||||
"temp_db_settings": flattenSqlVirtualMachineTempDbSettings(input.SQLTempDbSettings), | ||||||||||
"sql_system_db_on_datadisk": input.SQLSystemDbOnDataDisk, | ||||||||||
} | ||||||||||
|
||||||||||
if output["storage_workload_type"].(string) == "" && output["disk_type"] == "" && | ||||||||||
|
@@ -868,11 +979,16 @@ func expandSqlVirtualMachineTempDbSettings(input []interface{}) *sqlvirtualmachi | |||||||||
if len(input) == 0 || input[0] == nil { | ||||||||||
return nil | ||||||||||
} | ||||||||||
dataStorageSettings := input[0].(map[string]interface{}) | ||||||||||
tempDbSettings := input[0].(map[string]interface{}) | ||||||||||
|
||||||||||
return &sqlvirtualmachine.SQLTempDbSettings{ | ||||||||||
Luns: expandSqlVirtualMachineStorageSettingsLuns(dataStorageSettings["luns"].([]interface{})), | ||||||||||
DefaultFilePath: utils.String(dataStorageSettings["default_file_path"].(string)), | ||||||||||
Luns: expandSqlVirtualMachineStorageSettingsLuns(tempDbSettings["luns"].([]interface{})), | ||||||||||
DataFileCount: utils.Int32(int32(tempDbSettings["data_file_count"].(int))), | ||||||||||
DataFileSize: utils.Int32(int32(tempDbSettings["data_file_size_mb"].(int))), | ||||||||||
DataGrowth: utils.Int32(int32(tempDbSettings["data_file_growth_in_mb"].(int))), | ||||||||||
DefaultFilePath: utils.String(tempDbSettings["default_file_path"].(string)), | ||||||||||
LogFileSize: utils.Int32(int32(tempDbSettings["log_file_size_mb"].(int))), | ||||||||||
LogGrowth: utils.Int32(int32(tempDbSettings["log_file_growth_mb"].(int))), | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -886,9 +1002,29 @@ func flattenSqlVirtualMachineTempDbSettings(input *sqlvirtualmachine.SQLTempDbSe | |||||||||
attrs["luns"] = *input.Luns | ||||||||||
} | ||||||||||
|
||||||||||
if input.DataFileCount != nil { | ||||||||||
attrs["data_file_count"] = *input.DataFileCount | ||||||||||
} | ||||||||||
|
||||||||||
if input.DataFileSize != nil { | ||||||||||
attrs["data_file_size_mb"] = *input.DataFileSize | ||||||||||
} | ||||||||||
|
||||||||||
if input.DataGrowth != nil { | ||||||||||
attrs["data_file_growth_in_mb"] = *input.DataGrowth | ||||||||||
} | ||||||||||
|
||||||||||
if input.DefaultFilePath != nil { | ||||||||||
attrs["default_file_path"] = *input.DefaultFilePath | ||||||||||
} | ||||||||||
|
||||||||||
if input.LogFileSize != nil { | ||||||||||
attrs["log_file_size_mb"] = *input.LogFileSize | ||||||||||
} | ||||||||||
|
||||||||||
if input.LogGrowth != nil { | ||||||||||
attrs["log_file_growth_mb"] = *input.LogGrowth | ||||||||||
} | ||||||||||
|
||||||||||
return []interface{}{attrs} | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -631,10 +631,13 @@ resource "azurerm_virtual_machine_data_disk_attachment" "test" { | |
resource "azurerm_mssql_virtual_machine" "test" { | ||
virtual_machine_id = azurerm_virtual_machine.test.id | ||
sql_license_type = "PAYG" | ||
|
||
|
||
assessment_settings {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is a new block of property, maybe it worth writing a separate test for it with testing the update scenario as well. |
||
|
||
storage_configuration { | ||
disk_type = "NEW" | ||
storage_workload_type = "OLTP" | ||
disk_type = "NEW" | ||
storage_workload_type = "OLTP" | ||
system_db_on_datadisk_enabled = true | ||
|
||
data_settings { | ||
luns = [0] | ||
|
@@ -649,6 +652,7 @@ resource "azurerm_mssql_virtual_machine" "test" { | |
temp_db_settings { | ||
luns = [0] | ||
default_file_path = "F:\\SQLTemp" | ||
log_file_size_mb = 512 | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra spaces need to be removed from
"monthly_occurrence "
,"day_of_week "
and"start_time "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@myc2h6o thanks this should be resolved