12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
- using Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
16
- using Microsoft . Azure . Commands . RecoveryServices . Backup . Properties ;
17
15
using System ;
18
16
using System . Collections . Generic ;
17
+ using Microsoft . Azure . Commands . RecoveryServices . Backup . Cmdlets . Models ;
18
+ using Microsoft . Azure . Commands . RecoveryServices . Backup . Properties ;
19
19
using ServiceClientModel = Microsoft . Azure . Management . RecoveryServices . Backup . Models ;
20
20
21
21
namespace Microsoft . Azure . Commands . RecoveryServices . Backup . Helpers
@@ -55,11 +55,6 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta
55
55
{
56
56
containerModel = new AzureFileShareContainer ( protectionContainer ) ;
57
57
}
58
- else if ( protectionContainer . Properties . GetType ( ) ==
59
- typeof ( ServiceClientModel . AzureVMAppContainerProtectionContainer ) )
60
- {
61
- containerModel = new AzureVmWorkloadContainer ( protectionContainer ) ;
62
- }
63
58
}
64
59
65
60
return containerModel ;
@@ -195,7 +190,7 @@ public static PolicyBase GetPolicyModelForAzureSql(ServiceClientModel.Protection
195
190
ServiceClientModel . SimpleRetentionPolicy azureSqlRetentionPolicy =
196
191
( ServiceClientModel . SimpleRetentionPolicy ) azureSqlPolicy . RetentionPolicy ;
197
192
sqlPolicyModel . RetentionPolicy =
198
- PolicyHelpers . GetPSSimpleRetentionPolicy ( azureSqlRetentionPolicy , null , "AzureSql" ) ;
193
+ PolicyHelpers . GetPSSimpleRetentionPolicy ( azureSqlRetentionPolicy , null ) ;
199
194
return policyModel ;
200
195
}
201
196
@@ -241,86 +236,6 @@ public static PolicyBase GetPolicyModelForAzureFileShare(ServiceClientModel.Prot
241
236
return policyModel ;
242
237
}
243
238
244
- public static PolicyBase GetPolicyModelForAzureVmWorkload ( ServiceClientModel . ProtectionPolicyResource serviceClientResponse ,
245
- PolicyBase policyModel )
246
- {
247
- ServiceClientModel . AzureVmWorkloadProtectionPolicy azureVmWorkloadPolicy =
248
- ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ;
249
-
250
- foreach ( var policy in azureVmWorkloadPolicy . SubProtectionPolicy )
251
- {
252
- if ( string . Compare ( policy . PolicyType , "Full" ) == 0 )
253
- {
254
- if ( policy . SchedulePolicy . GetType ( ) !=
255
- typeof ( ServiceClientModel . SimpleSchedulePolicy ) )
256
- {
257
- Logger . Instance . WriteDebug ( "Unknown Schedule object received: " +
258
- policy . SchedulePolicy . GetType ( ) ) ;
259
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
260
- return null ;
261
- }
262
- if ( policy . RetentionPolicy . GetType ( ) !=
263
- typeof ( ServiceClientModel . LongTermRetentionPolicy ) )
264
- {
265
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
266
- policy . RetentionPolicy . GetType ( ) ) ;
267
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
268
- return null ;
269
- }
270
- }
271
- else if ( string . Compare ( policy . PolicyType , "Differential" ) == 0 )
272
- {
273
- if ( policy . SchedulePolicy . GetType ( ) !=
274
- typeof ( ServiceClientModel . SimpleSchedulePolicy ) )
275
- {
276
- Logger . Instance . WriteDebug ( "Unknown Schedule object received: " +
277
- policy . SchedulePolicy . GetType ( ) ) ;
278
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
279
- return null ;
280
- }
281
- if ( policy . RetentionPolicy . GetType ( ) !=
282
- typeof ( ServiceClientModel . SimpleRetentionPolicy ) )
283
- {
284
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
285
- policy . RetentionPolicy . GetType ( ) ) ;
286
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
287
- return null ;
288
- }
289
- }
290
- else if ( string . Compare ( policy . PolicyType , "Log" ) == 0 )
291
- {
292
- if ( policy . SchedulePolicy . GetType ( ) !=
293
- typeof ( ServiceClientModel . LogSchedulePolicy ) )
294
- {
295
- Logger . Instance . WriteDebug ( "Unknown Schedule object received: " +
296
- policy . SchedulePolicy . GetType ( ) ) ;
297
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
298
- return null ;
299
- }
300
- if ( policy . RetentionPolicy . GetType ( ) !=
301
- typeof ( ServiceClientModel . SimpleRetentionPolicy ) )
302
- {
303
- Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
304
- policy . RetentionPolicy . GetType ( ) ) ;
305
- Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
306
- return null ;
307
- }
308
- }
309
- }
310
-
311
- policyModel = new AzureVmWorkloadPolicy ( ) ;
312
- AzureVmWorkloadPolicy azureVmWorkloadPolicyModel = policyModel as AzureVmWorkloadPolicy ;
313
- azureVmWorkloadPolicyModel . WorkloadType = WorkloadType . MSSQL ;
314
- azureVmWorkloadPolicyModel . BackupManagementType = BackupManagementType . AzureWorkload ;
315
- azureVmWorkloadPolicyModel . IsCompression =
316
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . IsCompression ;
317
- azureVmWorkloadPolicyModel . IsDifferentialBackupEnabled = false ;
318
- azureVmWorkloadPolicyModel . IsLogBackupEnabled = false ;
319
- GetPSSubProtectionPolicy ( azureVmWorkloadPolicyModel , serviceClientResponse ,
320
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone ) ;
321
- return policyModel ;
322
- }
323
-
324
239
/// <summary>
325
240
/// Helper function to convert ps backup policy model from service response.
326
241
/// </summary>
@@ -348,11 +263,6 @@ public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResou
348
263
{
349
264
policyModel = GetPolicyModelForAzureFileShare ( serviceClientResponse , policyModel ) ;
350
265
}
351
- else if ( serviceClientResponse . Properties . GetType ( ) ==
352
- typeof ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) )
353
- {
354
- policyModel = GetPolicyModelForAzureVmWorkload ( serviceClientResponse , policyModel ) ;
355
- }
356
266
else
357
267
{
358
268
// we will enter this case when service supports new workload and customer
@@ -428,38 +338,8 @@ public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource pro
428
338
{
429
339
itemModel = GetAzureFileShareItemModel ( protectedItem ) ;
430
340
}
431
-
432
- if ( protectedItem . Properties . GetType ( ) ==
433
- typeof ( ServiceClientModel . AzureVmWorkloadSQLDatabaseProtectedItem ) )
434
- {
435
- itemModel = GetAzureVmWorkloadItemModel ( protectedItem ) ;
436
- }
437
- }
438
-
439
- return itemModel ;
440
- }
441
-
442
- private static ItemBase GetAzureVmWorkloadItemModel ( ServiceClientModel . ProtectedItemResource protectedItem )
443
- {
444
- ItemBase itemModel ;
445
- string policyName = null ;
446
- string policyId = ( ( ServiceClientModel . AzureVmWorkloadSQLDatabaseProtectedItem ) protectedItem . Properties ) . PolicyId ;
447
- if ( ! string . IsNullOrEmpty ( policyId ) )
448
- {
449
- Dictionary < UriEnums , string > keyValueDict =
450
- HelperUtils . ParseUri ( policyId ) ;
451
- policyName = HelperUtils . GetPolicyNameFromPolicyId ( keyValueDict , policyId ) ;
452
341
}
453
342
454
- string containerUri = HelperUtils . GetContainerUri (
455
- HelperUtils . ParseUri ( protectedItem . Id ) ,
456
- protectedItem . Id ) ;
457
-
458
- itemModel = new AzureWorkloadSQLDatabaseProtectedItem (
459
- protectedItem ,
460
- containerUri ,
461
- ContainerType . AzureVMAppContainer ,
462
- policyName ) ;
463
343
return itemModel ;
464
344
}
465
345
@@ -538,42 +418,7 @@ private static ItemBase GetAzureVmItemModel(ServiceClientModel.ProtectedItemReso
538
418
}
539
419
540
420
/// <summary>
541
- /// Helper function to convert ps protectable item from service response.
542
- /// </summary>
543
- public static ProtectableItemBase GetProtectableItemModel ( ServiceClientModel . WorkloadProtectableItemResource protectableItem )
544
- {
545
- ProtectableItemBase itemModel = null ;
546
-
547
- if ( protectableItem != null &&
548
- protectableItem . Properties != null )
549
- {
550
- if ( protectableItem . Properties . GetType ( ) . IsSubclassOf ( typeof ( ServiceClientModel . AzureVmWorkloadProtectableItem ) ) )
551
- {
552
- itemModel = GetAzureWorkloadProtectableItemModel ( protectableItem ) ;
553
- }
554
- }
555
-
556
- return itemModel ;
557
- }
558
-
559
- private static ProtectableItemBase GetAzureWorkloadProtectableItemModel ( ServiceClientModel . WorkloadProtectableItemResource protectableItem )
560
- {
561
- ProtectableItemBase itemModel ;
562
-
563
- string containerUri = HelperUtils . GetContainerUri (
564
- HelperUtils . ParseUri ( protectableItem . Id ) ,
565
- protectableItem . Id ) ;
566
-
567
- itemModel = new AzureWorkloadProtectableItem (
568
- protectableItem ,
569
- containerUri ,
570
- ContainerType . AzureVMAppContainer ) ;
571
-
572
- return itemModel ;
573
- }
574
-
575
- /// <summary>
576
- /// Helper function to convert ps item list from service response.
421
+ /// Helper function to convert ps backup policy item list from service response.
577
422
/// </summary>
578
423
public static List < ItemBase > GetItemModelList ( IEnumerable < ServiceClientModel . ProtectedItemResource > protectedItems )
579
424
{
@@ -586,60 +431,6 @@ public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.Pro
586
431
587
432
return itemModels ;
588
433
}
589
-
590
- public static void GetPSSubProtectionPolicy ( AzureVmWorkloadPolicy azureVmWorkloadPolicyModel ,
591
- ServiceClientModel . ProtectionPolicyResource serviceClientResponse , string timeZone )
592
- {
593
- foreach ( var subProtectionPolicy in
594
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . SubProtectionPolicy )
595
- {
596
- if ( string . Compare ( subProtectionPolicy . PolicyType , "Full" ) == 0 )
597
- {
598
- azureVmWorkloadPolicyModel . FullBackupSchedulePolicy = PolicyHelpers . GetPSSimpleSchedulePolicy (
599
- ( ServiceClientModel . SimpleSchedulePolicy ) subProtectionPolicy . SchedulePolicy ,
600
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone ) ;
601
-
602
- azureVmWorkloadPolicyModel . FullBackupRetentionPolicy = PolicyHelpers . GetPSLongTermRetentionPolicy (
603
- ( ServiceClientModel . LongTermRetentionPolicy ) subProtectionPolicy . RetentionPolicy ,
604
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone ) ;
605
- }
606
- else if ( string . Compare ( subProtectionPolicy . PolicyType , "Differential" ) == 0 )
607
- {
608
- azureVmWorkloadPolicyModel . DifferentialBackupSchedulePolicy = PolicyHelpers . GetPSSimpleSchedulePolicy (
609
- ( ServiceClientModel . SimpleSchedulePolicy ) subProtectionPolicy . SchedulePolicy ,
610
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone ) ;
611
- azureVmWorkloadPolicyModel . DifferentialBackupRetentionPolicy = PolicyHelpers . GetPSSimpleRetentionPolicy (
612
- ( ServiceClientModel . SimpleRetentionPolicy ) subProtectionPolicy . RetentionPolicy ,
613
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone , "AzureWorkload" ) ;
614
- azureVmWorkloadPolicyModel . IsDifferentialBackupEnabled = true ;
615
- }
616
- else if ( string . Compare ( subProtectionPolicy . PolicyType , "Log" ) == 0 )
617
- {
618
- azureVmWorkloadPolicyModel . LogBackupSchedulePolicy = PolicyHelpers . GetPSLogSchedulePolicy ( ( ServiceClientModel . LogSchedulePolicy )
619
- subProtectionPolicy . SchedulePolicy ,
620
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone ) ;
621
- azureVmWorkloadPolicyModel . LogBackupRetentionPolicy = PolicyHelpers . GetPSSimpleRetentionPolicy ( ( ServiceClientModel . SimpleRetentionPolicy )
622
- subProtectionPolicy . RetentionPolicy ,
623
- ( ( ServiceClientModel . AzureVmWorkloadProtectionPolicy ) serviceClientResponse . Properties ) . Settings . TimeZone , "AzureWorkload" ) ;
624
- azureVmWorkloadPolicyModel . IsLogBackupEnabled = true ;
625
- }
626
- }
627
- }
628
-
629
- /// <summary>
630
- /// Helper function to convert ps protectable item list from service response.
631
- /// </summary>
632
- public static List < ProtectableItemBase > GetProtectableItemModelList ( IEnumerable < ServiceClientModel . WorkloadProtectableItemResource > protectableItems )
633
- {
634
- List < ProtectableItemBase > itemModels = new List < ProtectableItemBase > ( ) ;
635
-
636
- foreach ( var protectableItem in protectableItems )
637
- {
638
- itemModels . Add ( GetProtectableItemModel ( protectableItem ) ) ;
639
- }
640
-
641
- return itemModels ;
642
- }
643
434
#endregion
644
435
}
645
436
}
0 commit comments