Skip to content

Commit e766f60

Browse files
Merge pull request #8499 from Azure/revert-8349-mercury_dev_test
Revert "Backup Support for SQL Server in Azure VM"
2 parents 8c3b2d1 + c3b4ad0 commit e766f60

File tree

103 files changed

+389
-2483490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+389
-2483490
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 4 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16-
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
1715
using System;
1816
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
18+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
1919
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2020

2121
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
@@ -55,11 +55,6 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta
5555
{
5656
containerModel = new AzureFileShareContainer(protectionContainer);
5757
}
58-
else if (protectionContainer.Properties.GetType() ==
59-
typeof(ServiceClientModel.AzureVMAppContainerProtectionContainer))
60-
{
61-
containerModel = new AzureVmWorkloadContainer(protectionContainer);
62-
}
6358
}
6459

6560
return containerModel;
@@ -195,7 +190,7 @@ public static PolicyBase GetPolicyModelForAzureSql(ServiceClientModel.Protection
195190
ServiceClientModel.SimpleRetentionPolicy azureSqlRetentionPolicy =
196191
(ServiceClientModel.SimpleRetentionPolicy)azureSqlPolicy.RetentionPolicy;
197192
sqlPolicyModel.RetentionPolicy =
198-
PolicyHelpers.GetPSSimpleRetentionPolicy(azureSqlRetentionPolicy, null, "AzureSql");
193+
PolicyHelpers.GetPSSimpleRetentionPolicy(azureSqlRetentionPolicy, null);
199194
return policyModel;
200195
}
201196

@@ -241,86 +236,6 @@ public static PolicyBase GetPolicyModelForAzureFileShare(ServiceClientModel.Prot
241236
return policyModel;
242237
}
243238

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-
324239
/// <summary>
325240
/// Helper function to convert ps backup policy model from service response.
326241
/// </summary>
@@ -348,11 +263,6 @@ public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResou
348263
{
349264
policyModel = GetPolicyModelForAzureFileShare(serviceClientResponse, policyModel);
350265
}
351-
else if (serviceClientResponse.Properties.GetType() ==
352-
typeof(ServiceClientModel.AzureVmWorkloadProtectionPolicy))
353-
{
354-
policyModel = GetPolicyModelForAzureVmWorkload(serviceClientResponse, policyModel);
355-
}
356266
else
357267
{
358268
// we will enter this case when service supports new workload and customer
@@ -428,38 +338,8 @@ public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource pro
428338
{
429339
itemModel = GetAzureFileShareItemModel(protectedItem);
430340
}
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);
452341
}
453342

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);
463343
return itemModel;
464344
}
465345

@@ -538,42 +418,7 @@ private static ItemBase GetAzureVmItemModel(ServiceClientModel.ProtectedItemReso
538418
}
539419

540420
/// <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.
577422
/// </summary>
578423
public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.ProtectedItemResource> protectedItems)
579424
{
@@ -586,60 +431,6 @@ public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.Pro
586431

587432
return itemModels;
588433
}
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-
}
643434
#endregion
644435
}
645436
}

src/RecoveryServices/RecoveryServices.Backup.Helpers/Conversions/JobConversions.cs

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public static CmdletModel.JobBase GetPSJob(JobResource serviceClientJob)
4747
{
4848
response = GetPSAzureFileShareJob(serviceClientJob);
4949
}
50-
else if (serviceClientJob.Properties.GetType() == typeof(AzureWorkloadJob))
51-
{
52-
response = GetPSAzureWorkloadJob(serviceClientJob);
53-
}
5450

5551
return response;
5652
}
@@ -238,88 +234,6 @@ private static CmdletModel.AzureJobErrorInfo GetPSAzureFileShareErrorInfo(AzureS
238234
return psErrorInfo;
239235
}
240236

241-
private static CmdletModel.JobBase GetPSAzureWorkloadJob(JobResource serviceClientJob)
242-
{
243-
CmdletModel.AzureVmWorkloadJob response;
244-
245-
AzureWorkloadJob workloadJob = serviceClientJob.Properties as AzureWorkloadJob;
246-
247-
if (workloadJob.ExtendedInfo != null)
248-
{
249-
response = new CmdletModel.AzureVmWorkloadJobDetails();
250-
}
251-
else
252-
{
253-
response = new CmdletModel.AzureVmWorkloadJob();
254-
}
255-
256-
response.JobId = GetLastIdFromFullId(serviceClientJob.Id);
257-
response.StartTime = GetJobStartTime(workloadJob.StartTime);
258-
response.EndTime = workloadJob.EndTime;
259-
response.Duration = GetJobDuration(workloadJob.Duration);
260-
response.Status = workloadJob.Status;
261-
response.WorkloadName = workloadJob.EntityFriendlyName;
262-
response.ActivityId = workloadJob.ActivityId;
263-
response.BackupManagementType =
264-
CmdletModel.ConversionUtils.GetPsBackupManagementType(workloadJob.BackupManagementType);
265-
response.Operation = workloadJob.Operation;
266-
267-
if (workloadJob.ErrorDetails != null)
268-
{
269-
response.ErrorDetails = new List<CmdletModel.AzureJobErrorInfo>();
270-
foreach (var workloadError in workloadJob.ErrorDetails)
271-
{
272-
response.ErrorDetails.Add(GetPSAzureWorkloadErrorInfo(workloadError));
273-
}
274-
}
275-
276-
// fill extended info if present
277-
if (workloadJob.ExtendedInfo != null)
278-
{
279-
CmdletModel.AzureVmWorkloadJobDetails detailedResponse =
280-
response as CmdletModel.AzureVmWorkloadJobDetails;
281-
282-
detailedResponse.DynamicErrorMessage = workloadJob.ExtendedInfo.DynamicErrorMessage;
283-
if (workloadJob.ExtendedInfo.PropertyBag != null)
284-
{
285-
detailedResponse.Properties = new Dictionary<string, string>();
286-
foreach (var key in workloadJob.ExtendedInfo.PropertyBag.Keys)
287-
{
288-
detailedResponse.Properties.Add(key, workloadJob.ExtendedInfo.PropertyBag[key]);
289-
}
290-
}
291-
292-
if (workloadJob.ExtendedInfo.TasksList != null)
293-
{
294-
detailedResponse.SubTasks = new List<CmdletModel.AzureVmWorkloadJobSubTask>();
295-
foreach (var workloadJobTask in workloadJob.ExtendedInfo.TasksList)
296-
{
297-
detailedResponse.SubTasks.Add(new CmdletModel.AzureVmWorkloadJobSubTask()
298-
{
299-
Name = workloadJobTask.TaskId,
300-
Status = workloadJobTask.Status
301-
});
302-
}
303-
}
304-
}
305-
306-
return response;
307-
}
308-
309-
private static CmdletModel.AzureJobErrorInfo GetPSAzureWorkloadErrorInfo(AzureWorkloadErrorInfo workloadError)
310-
{
311-
CmdletModel.AzureVmWorkloadJobErrorInfo psErrorInfo = new CmdletModel.AzureVmWorkloadJobErrorInfo();
312-
psErrorInfo.ErrorCode = GetJobErrorCode(workloadError.ErrorCode);
313-
psErrorInfo.ErrorMessage = workloadError.ErrorString;
314-
if (workloadError.Recommendations != null)
315-
{
316-
psErrorInfo.Recommendations = new List<string>();
317-
psErrorInfo.Recommendations.AddRange(workloadError.Recommendations);
318-
}
319-
320-
return psErrorInfo;
321-
}
322-
323237
private static int GetJobErrorCode(int? errorCode)
324238
{
325239
return errorCode ?? default(int);

0 commit comments

Comments
 (0)