@@ -127,6 +127,115 @@ public static List<BackupEngineBase> GetBackupEngineModelList(
127
127
128
128
#region policy
129
129
130
+ /// <summary>
131
+ /// Helper function to convert ps backup policy model for AzureVM from service response.
132
+ /// </summary>
133
+ public static PolicyBase GetPolicyModelForAzureIaaSVM ( ServiceClientModel . ProtectionPolicyResource serviceClientResponse ,
134
+ PolicyBase policyModel )
135
+ {
136
+ if ( ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy . GetType ( ) !=
137
+ typeof ( ServiceClientModel . LongTermRetentionPolicy ) )
138
+ {
139
+ Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
140
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy . GetType ( ) ) ;
141
+ Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
142
+ return null ;
143
+ }
144
+
145
+ if ( ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy . GetType ( ) !=
146
+ typeof ( ServiceClientModel . SimpleSchedulePolicy ) )
147
+ {
148
+ Logger . Instance . WriteDebug ( "Unknown SchedulePolicy object received: " +
149
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy . GetType ( ) ) ;
150
+ Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
151
+ return null ;
152
+ }
153
+
154
+ policyModel = new AzureVmPolicy ( ) ;
155
+ AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy ;
156
+ iaasPolicyModel . WorkloadType = WorkloadType . AzureVM ;
157
+ iaasPolicyModel . BackupManagementType = BackupManagementType . AzureVM ;
158
+ iaasPolicyModel . RetentionPolicy = PolicyHelpers . GetPSLongTermRetentionPolicy ( ( ServiceClientModel . LongTermRetentionPolicy )
159
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy ,
160
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
161
+ iaasPolicyModel . SchedulePolicy = PolicyHelpers . GetPSSimpleSchedulePolicy ( ( ServiceClientModel . SimpleSchedulePolicy )
162
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy ,
163
+ ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
164
+ return policyModel ;
165
+ }
166
+
167
+ /// <summary>
168
+ /// Helper function to convert ps backup policy model for AzureSql from service response.
169
+ /// </summary>
170
+ public static PolicyBase GetPolicyModelForAzureSql ( ServiceClientModel . ProtectionPolicyResource serviceClientResponse ,
171
+ PolicyBase policyModel )
172
+ {
173
+ ServiceClientModel . AzureSqlProtectionPolicy azureSqlPolicy =
174
+ ( ServiceClientModel . AzureSqlProtectionPolicy ) serviceClientResponse . Properties ;
175
+
176
+ if ( azureSqlPolicy . RetentionPolicy . GetType ( ) !=
177
+ typeof ( ServiceClientModel . SimpleRetentionPolicy ) )
178
+ {
179
+ Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
180
+ azureSqlPolicy . RetentionPolicy . GetType ( ) ) ;
181
+ Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
182
+ return null ;
183
+ }
184
+
185
+ policyModel = new AzureSqlPolicy ( ) ;
186
+ AzureSqlPolicy sqlPolicyModel = policyModel as AzureSqlPolicy ;
187
+ sqlPolicyModel . WorkloadType = WorkloadType . AzureSQLDatabase ;
188
+ sqlPolicyModel . BackupManagementType = BackupManagementType . AzureSQL ;
189
+
190
+ ServiceClientModel . SimpleRetentionPolicy azureSqlRetentionPolicy =
191
+ ( ServiceClientModel . SimpleRetentionPolicy ) azureSqlPolicy . RetentionPolicy ;
192
+ sqlPolicyModel . RetentionPolicy =
193
+ PolicyHelpers . GetPSSimpleRetentionPolicy ( azureSqlRetentionPolicy , null ) ;
194
+ return policyModel ;
195
+ }
196
+
197
+ /// <summary>
198
+ /// Helper function to convert ps backup policy model for Azure FileShare from service response.
199
+ /// </summary>
200
+ public static PolicyBase GetPolicyModelForAzureFileShare ( ServiceClientModel . ProtectionPolicyResource serviceClientResponse ,
201
+ PolicyBase policyModel )
202
+ {
203
+ ServiceClientModel . AzureFileShareProtectionPolicy azureFileSharePolicy =
204
+ ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ;
205
+
206
+ if ( azureFileSharePolicy . RetentionPolicy . GetType ( ) !=
207
+ typeof ( ServiceClientModel . LongTermRetentionPolicy ) )
208
+ {
209
+ Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
210
+ azureFileSharePolicy . RetentionPolicy . GetType ( ) ) ;
211
+ Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
212
+ return null ;
213
+ }
214
+
215
+ if ( azureFileSharePolicy . SchedulePolicy . GetType ( ) !=
216
+ typeof ( ServiceClientModel . SimpleSchedulePolicy ) )
217
+ {
218
+ Logger . Instance . WriteDebug ( "Unknown SchedulePolicy object received: " +
219
+ azureFileSharePolicy . SchedulePolicy . GetType ( ) ) ;
220
+ Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
221
+ return null ;
222
+ }
223
+
224
+
225
+ policyModel = new AzureFileSharePolicy ( ) ;
226
+ AzureFileSharePolicy fileSharePolicyModel = policyModel as AzureFileSharePolicy ;
227
+ fileSharePolicyModel . WorkloadType = WorkloadType . AzureFiles ;
228
+ fileSharePolicyModel . BackupManagementType = BackupManagementType . AzureStorage ;
229
+ fileSharePolicyModel . RetentionPolicy =
230
+ PolicyHelpers . GetPSLongTermRetentionPolicy ( ( ServiceClientModel . LongTermRetentionPolicy ) ( ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy ,
231
+ ( ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
232
+ fileSharePolicyModel . SchedulePolicy =
233
+ PolicyHelpers . GetPSSimpleSchedulePolicy ( ( ServiceClientModel . SimpleSchedulePolicy )
234
+ ( ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy ,
235
+ ( ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
236
+ return policyModel ;
237
+ }
238
+
130
239
/// <summary>
131
240
/// Helper function to convert ps backup policy model from service response.
132
241
/// </summary>
@@ -142,84 +251,17 @@ public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResou
142
251
143
252
if ( serviceClientResponse . Properties . GetType ( ) == typeof ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) )
144
253
{
145
- if ( ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy . GetType ( ) !=
146
- typeof ( ServiceClientModel . LongTermRetentionPolicy ) )
147
- {
148
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
149
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy . GetType ( ) ) ;
150
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
151
- return null ;
152
- }
153
-
154
- if ( ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy . GetType ( ) !=
155
- typeof ( ServiceClientModel . SimpleSchedulePolicy ) )
156
- {
157
- Logger . Instance . WriteDebug ( "Unknown SchedulePolicy object received: " +
158
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy . GetType ( ) ) ;
159
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
160
- return null ;
161
- }
162
-
163
- policyModel = new AzureVmPolicy ( ) ;
164
- AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy ;
165
- iaasPolicyModel . WorkloadType = WorkloadType . AzureVM ;
166
- iaasPolicyModel . BackupManagementType = BackupManagementType . AzureVM ;
167
- iaasPolicyModel . RetentionPolicy = PolicyHelpers . GetPSLongTermRetentionPolicy ( ( ServiceClientModel . LongTermRetentionPolicy )
168
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . RetentionPolicy ,
169
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
170
- iaasPolicyModel . SchedulePolicy = PolicyHelpers . GetPSSimpleSchedulePolicy ( ( ServiceClientModel . SimpleSchedulePolicy )
171
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . SchedulePolicy ,
172
- ( ( ServiceClientModel . AzureIaaSVMProtectionPolicy ) serviceClientResponse . Properties ) . TimeZone ) ;
254
+ policyModel = GetPolicyModelForAzureIaaSVM ( serviceClientResponse , policyModel ) ;
173
255
}
174
256
else if ( serviceClientResponse . Properties . GetType ( ) ==
175
257
typeof ( ServiceClientModel . AzureSqlProtectionPolicy ) )
176
258
{
177
- ServiceClientModel . AzureSqlProtectionPolicy azureSqlPolicy =
178
- ( ServiceClientModel . AzureSqlProtectionPolicy ) serviceClientResponse . Properties ;
179
-
180
- if ( azureSqlPolicy . RetentionPolicy . GetType ( ) !=
181
- typeof ( ServiceClientModel . SimpleRetentionPolicy ) )
182
- {
183
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
184
- azureSqlPolicy . RetentionPolicy . GetType ( ) ) ;
185
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
186
- return null ;
187
- }
188
-
189
- policyModel = new AzureSqlPolicy ( ) ;
190
- AzureSqlPolicy sqlPolicyModel = policyModel as AzureSqlPolicy ;
191
- sqlPolicyModel . WorkloadType = WorkloadType . AzureSQLDatabase ;
192
- sqlPolicyModel . BackupManagementType = BackupManagementType . AzureSQL ;
193
-
194
- ServiceClientModel . SimpleRetentionPolicy azureSqlRetentionPolicy =
195
- ( ServiceClientModel . SimpleRetentionPolicy ) azureSqlPolicy . RetentionPolicy ;
196
- sqlPolicyModel . RetentionPolicy =
197
- PolicyHelpers . GetPSSimpleRetentionPolicy ( azureSqlRetentionPolicy , null ) ;
259
+ policyModel = GetPolicyModelForAzureSql ( serviceClientResponse , policyModel ) ;
198
260
}
199
261
else if ( serviceClientResponse . Properties . GetType ( ) ==
200
262
typeof ( ServiceClientModel . AzureFileShareProtectionPolicy ) )
201
263
{
202
- ServiceClientModel . AzureFileShareProtectionPolicy azureFileSharePolicy =
203
- ( ServiceClientModel . AzureFileShareProtectionPolicy ) serviceClientResponse . Properties ;
204
-
205
- if ( azureFileSharePolicy . RetentionPolicy . GetType ( ) !=
206
- typeof ( ServiceClientModel . LongTermRetentionPolicy ) )
207
- {
208
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
209
- azureFileSharePolicy . RetentionPolicy . GetType ( ) ) ;
210
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
211
- return null ;
212
- }
213
-
214
- policyModel = new AzureFileSharePolicy ( ) ;
215
- AzureFileSharePolicy fileSharePolicyModel = policyModel as AzureFileSharePolicy ;
216
- fileSharePolicyModel . WorkloadType = WorkloadType . AzureFiles ;
217
- fileSharePolicyModel . BackupManagementType = BackupManagementType . AzureStorage ;
218
-
219
- ServiceClientModel . LongTermRetentionPolicy azureFileShareRetentionPolicy =
220
- ( ServiceClientModel . LongTermRetentionPolicy ) azureFileSharePolicy . RetentionPolicy ;
221
- fileSharePolicyModel . RetentionPolicy =
222
- PolicyHelpers . GetPSLongTermRetentionPolicy ( azureFileShareRetentionPolicy , null ) ;
264
+ policyModel = GetPolicyModelForAzureFileShare ( serviceClientResponse , policyModel ) ;
223
265
}
224
266
else
225
267
{
0 commit comments