Skip to content

Commit

Permalink
Merge pull request #89 from MabOneSdk/csm-pragrawa
Browse files Browse the repository at this point in the history
LTR Policy changes
  • Loading branch information
pragrawa committed Jul 27, 2015
2 parents 2f1c45f + 3d0057f commit 88fbb2e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public override void ExecuteCmdlet()
{
updateProtectionPolicyRequest.Properties.LtrRetentionPolicy =
protectionPolicy.ConvertToCSMRetentionPolicyObject(RetentionPolicies, backupSchedule);
ProtectionPolicyHelpers.ValidateRetentionPolicy(RetentionPolicies, backupSchedule.scheduleRun);
ProtectionPolicyHelpers.ValidateRetentionPolicy(RetentionPolicies, backupSchedule.ScheduleRun);
}
else
{
updateProtectionPolicyRequest.Properties.LtrRetentionPolicy =
protectionPolicy.ConvertToCSMRetentionPolicyObject(policyInfo.RetentionPolicyList, backupSchedule);
ProtectionPolicyHelpers.ValidateRetentionPolicy(policyInfo.RetentionPolicyList, backupSchedule.scheduleRun);
ProtectionPolicyHelpers.ValidateRetentionPolicy(policyInfo.RetentionPolicyList, backupSchedule.ScheduleRun);
}

var operationId = AzureBackupClient.UpdateProtectionPolicy(policyInfo.Name, updateProtectionPolicyRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\RemoveAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\SetAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureBackupRetentionPolicyObject.cs" />
<Compile Include="Cmdlets\RecoveryPoint\GetAzureBackupRecoveryPoint.cs" />
<Compile Include="Cmdlets\Restore\TriggerRestore.cs" />
<Compile Include="Cmdlets\VaultCredentials\GetAzureBackupVaultCredentials.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static AzureBackupProtectionPolicy GetCmdletPolicy(CmdletModel.AzurePSBac
return null;
}

return new AzureBackupProtectionPolicy(vault, sourcePolicy.Properties);
return new AzureBackupProtectionPolicy(vault, sourcePolicy.Properties, sourcePolicy.Id);
}

public static IEnumerable<AzureBackupProtectionPolicy> GetCmdletPolicies(CmdletModel.AzurePSBackupVault vault, IEnumerable<CSMProtectionPolicyResponse> sourcePolicyList)
Expand All @@ -78,19 +78,19 @@ public static CSMBackupSchedule FillCSMBackupSchedule(string scheduleType, DateT
{
var backupSchedule = new CSMBackupSchedule();

backupSchedule.backupType = BackupType.Full.ToString();
backupSchedule.BackupType = BackupType.Full.ToString();

scheduleType = FillScheduleType(scheduleType, scheduleRunDays);
backupSchedule.scheduleRun = scheduleType;
backupSchedule.ScheduleRun = scheduleType;

if (string.Compare(scheduleType, ScheduleType.Weekly.ToString(), true) == 0)
{
backupSchedule.scheduleRunDays = ParseScheduleRunDays(scheduleRunDays);
backupSchedule.ScheduleRunDays = ParseScheduleRunDays(scheduleRunDays);
}

DateTime scheduleRunTime = ParseScheduleRunTime(scheduleStartTime);

backupSchedule.scheduleRunTimes = new List<DateTime> { scheduleRunTime };
backupSchedule.ScheduleRunTimes = new List<DateTime> { scheduleRunTime };

return backupSchedule;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public enum WorkloadType
VM = 1
}

public enum RetentionFormat
{
Daily,
Weekly
}

public enum BackupType
{
Invalid = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class AzureBackupProtectionPolicy : AzureBackupVaultContextObject
/// <summary>
/// Name of the azurebackup object
/// </summary>

public string PolicyId { get; set; }

public string Name { get; set; }

public string WorkloadType { get; set; }
Expand All @@ -42,15 +45,16 @@ public AzureBackupProtectionPolicy()
{
}

public AzureBackupProtectionPolicy(AzurePSBackupVault vault, CSMProtectionPolicyProperties sourcePolicy)
public AzureBackupProtectionPolicy(AzurePSBackupVault vault, CSMProtectionPolicyProperties sourcePolicy, string policyId)
: base(vault)
{
PolicyId = policyId;
Name = sourcePolicy.PolicyName;
WorkloadType = sourcePolicy.WorkloadType;
ScheduleType = sourcePolicy.backupSchedule.scheduleRun;
ScheduleRunTimes = ConvertScheduleRunTimes(sourcePolicy.backupSchedule.scheduleRunTimes);
ScheduleRunDays = ConvertScheduleRunDays(sourcePolicy.backupSchedule.scheduleRunDays);
RetentionPolicyList = ConvertCSMRetentionPolicyListToPowershell(sourcePolicy.LTRRetentionPolicy);
ScheduleType = sourcePolicy.BackupSchedule.ScheduleRun;
ScheduleRunTimes = ConvertScheduleRunTimes(sourcePolicy.BackupSchedule.ScheduleRunTimes);
ScheduleRunDays = ConvertScheduleRunDays(sourcePolicy.BackupSchedule.ScheduleRunDays);
RetentionPolicyList = ConvertCSMRetentionPolicyListToPowershell(sourcePolicy.LtrRetentionPolicy);
}

private IList<AzureBackupRetentionPolicy> ConvertCSMRetentionPolicyListToPowershell(CSMLongTermRetentionPolicy LTRRetentionPolicy)
Expand Down Expand Up @@ -223,22 +227,22 @@ public CSMLongTermRetentionPolicy ConvertToCSMRetentionPolicyObject(IList<AzureB
if(retentionPolicy.RetentionType == "Daily")
{
csmLongTermRetentionPolicy.DailySchedule = ConvertToCSMDailyRetentionObject((AzureBackupDailyRetentionPolicy)retentionPolicy,
backupSchedule.scheduleRunTimes);
backupSchedule.ScheduleRunTimes);
}
if(retentionPolicy.RetentionType == "Weekly")
{
csmLongTermRetentionPolicy.WeeklySchedule = ConvertToCSMWeeklyRetentionObject((AzureBackupWeeklyRetentionPolicy)retentionPolicy,
backupSchedule.scheduleRunTimes);
backupSchedule.ScheduleRunTimes);
}
if(retentionPolicy.RetentionType == "Monthly")
{
csmLongTermRetentionPolicy.MonthlySchedule = ConvertToGetCSMMonthlyRetentionObject((AzureBackupMonthlyRetentionPolicy)retentionPolicy,
backupSchedule.scheduleRunTimes);
backupSchedule.ScheduleRunTimes);
}
if(retentionPolicy.RetentionType == "Yearly")
{
csmLongTermRetentionPolicy.YearlySchedule = ConvertToCSMYearlyRetentionObject((AzureBackupYearlyRetentionPolicy)retentionPolicy,
backupSchedule.scheduleRunTimes);
backupSchedule.ScheduleRunTimes);
}
}

Expand Down

0 comments on commit 88fbb2e

Please sign in to comment.