Skip to content

Commit 6b5309b

Browse files
committed
Bug fixes and contract updation
Create ProtectionProfileObject - Default values added to parameters New contract for ProtectionProfile Association input updated
1 parent ebdb880 commit 6b5309b

File tree

5 files changed

+139
-49
lines changed

5 files changed

+139
-49
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/CreateAzureSiteRecoveryProtectionProfileObject.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.ComponentModel;
1617
using System.Management.Automation;
1718
using Microsoft.Azure.Commands.RecoveryServices.SiteRecovery;
1819
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
@@ -44,8 +45,7 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
4445
/// <summary>
4546
/// Gets or sets a value for Replication Method of the Protection Profile.
4647
/// </summary>
47-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
48-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
48+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
4949
[ValidateNotNullOrEmpty]
5050
[ValidateSet(
5151
Constants.OnlineReplicationMethod,
@@ -69,56 +69,60 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
6969
/// <summary>
7070
/// Gets or sets Replication Frequency of the Protection Profile in seconds.
7171
/// </summary>
72-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
73-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
72+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
73+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
7474
[ValidateNotNullOrEmpty]
75-
public int ReplicationFrequencyInSeconds { get; set; }
75+
[DefaultValue(300)]
76+
public ushort ReplicationFrequencyInSeconds { get; set; }
7677

7778
/// <summary>
7879
/// Gets or sets Recovery Points of the Protection Profile.
7980
/// </summary>
80-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
81-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
81+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
82+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
8283
[ValidateNotNullOrEmpty]
84+
[DefaultValue(0)]
8385
public int RecoveryPoints { get; set; }
8486

8587
/// <summary>
8688
/// Gets or sets Application Consistent Snapshot Frequency of the Protection Profile in hours.
8789
/// </summary>
88-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
89-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
90+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
91+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
9092
[ValidateNotNullOrEmpty]
93+
[DefaultValue(0)]
9194
public int ApplicationConsistentSnapshotFrequencyInHours { get; set; }
9295

9396
/// <summary>
9497
/// Gets or sets a value indicating whether Compression needs to be Enabled on the Protection Profile.
9598
/// </summary>
96-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
97-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
99+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
100+
[DefaultValue(true)]
98101
public SwitchParameter CompressionEnabled { get; set; }
99102

100103
/// <summary>
101104
/// Gets or sets the Replication Port of the Protection Profile.
102105
/// </summary>
103-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
104-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
106+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
105107
[ValidateNotNullOrEmpty]
106-
public int ReplicationPort { get; set; }
108+
[DefaultValue(8084)]
109+
public ushort ReplicationPort { get; set; }
107110

108111
/// <summary>
109112
/// Gets or sets Replication Start time of the Protection Profile.
110113
/// </summary>
111114
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
112115
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
113116
[ValidateNotNullOrEmpty]
117+
[DefaultValue(null)]
114118
public TimeSpan? ReplicationStartTime { get; set; }
115119

116120
/// <summary>
117121
/// Gets or sets a value indicating whether Replica should be Deleted on
118122
/// disabling protection of a protection entity protected by the Protection Profile.
119123
/// </summary>
120-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
121-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
124+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
125+
[DefaultValue(false)]
122126
public SwitchParameter AllowReplicaDeletion { get; set; }
123127

124128
#endregion Parameters

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/SetAzureSiteRecoveryProtectionProfile.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ private void EnterpriseToAzureUpdate()
154154
HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput
155155
= new HyperVReplicaAzureProtectionProfileInput()
156156
{
157-
AppConsistencyFreq = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
157+
ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
158158
ReplicationInterval = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds,
159-
OnlineIrStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime
159+
OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime,
160+
RecoveryPointHistoryDuration = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryPoints,
160161
};
161162

162163
UpdateProtectionProfileInput updateProtectionProfileInput =
@@ -175,17 +176,22 @@ HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInpu
175176
/// </summary>
176177
private void EnterpriseToEnterpriseUpdate()
177178
{
178-
HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput
179-
= new HyperVReplicaAzureProtectionProfileInput()
180-
{
181-
AppConsistencyFreq = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
182-
ReplicationInterval = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds,
183-
OnlineIrStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime
184-
};
179+
HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
180+
= new HyperVReplicaProtectionProfileInput()
181+
{
182+
ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
183+
ReplicationFrequencyInSeconds = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationFrequencyInSeconds,
184+
OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationStartTime,
185+
CompressionEnabled = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.CompressionEnabled,
186+
OnlineReplicationMethod = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 1) ? true : false,
187+
RecoveryPoints = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.RecoveryPoints,
188+
ReplicationPort = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationPort,
189+
AllowReplicaDeletion = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.AllowReplicaDeletion
190+
};
185191

186192
UpdateProtectionProfileInput updateProtectionProfileInput =
187193
new UpdateProtectionProfileInput(
188-
DataContractUtils<HyperVReplicaAzureProtectionProfileInput>.Serialize(hyperVReplicaAzureProtectionProfileInput));
194+
DataContractUtils<HyperVReplicaProtectionProfileInput>.Serialize(hyperVReplicaProtectionProfileInput));
189195

190196
this.jobResponse = RecoveryServicesClient.UpdateAzureSiteRecoveryProtectionProfile(
191197
updateProtectionProfileInput,

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/StartAzureSiteRecoveryProtectionProfileAssociationJob.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ private void EnterpriseToAzureAssociation()
9999
HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput
100100
= new HyperVReplicaAzureProtectionProfileInput()
101101
{
102-
AppConsistencyFreq = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
102+
ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
103103
ReplicationInterval = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds,
104-
OnlineIrStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime
104+
OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime,
105+
RecoveryPointHistoryDuration = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryPoints,
105106
};
106107

107108
var storageAccount = new CustomerStorageAccount();
@@ -136,24 +137,24 @@ HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInpu
136137
/// </summary>
137138
private void EnterpriseToEnterpriseAssociation()
138139
{
139-
HyperVReplicaAzureProtectionProfileInput hyperVReplicaAzureProtectionProfileInput
140-
= new HyperVReplicaAzureProtectionProfileInput()
140+
HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
141+
= new HyperVReplicaProtectionProfileInput()
141142
{
142-
AppConsistencyFreq = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
143-
ReplicationInterval = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds,
144-
OnlineIrStartTime = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationStartTime
143+
ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
144+
ReplicationFrequencyInSeconds = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationFrequencyInSeconds,
145+
OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationStartTime,
146+
CompressionEnabled = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.CompressionEnabled,
147+
OnlineReplicationMethod = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 1) ? true : false,
148+
RecoveryPoints = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.RecoveryPoints,
149+
ReplicationPort = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationPort,
150+
AllowReplicaDeletion = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.AllowReplicaDeletion
145151
};
146152

147-
var storageAccount = new CustomerStorageAccount();
148-
storageAccount.StorageAccountName = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryAzureStorageAccountName;
149-
storageAccount.SubscriptionId = this.ProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryAzureSubscription;
150-
hyperVReplicaAzureProtectionProfileInput.StorageAccounts.Add(storageAccount);
151-
152153
CreateProtectionProfileInput createProtectionProfileInput =
153154
new CreateProtectionProfileInput(
154155
this.ProtectionProfile.Name,
155156
this.ProtectionProfile.ReplicationProvider,
156-
DataContractUtils<HyperVReplicaAzureProtectionProfileInput>.Serialize(hyperVReplicaAzureProtectionProfileInput));
157+
DataContractUtils<HyperVReplicaProtectionProfileInput>.Serialize(hyperVReplicaProtectionProfileInput));
157158

158159
ProtectionProfileAssociationInput protectionProfileAssociationInput =
159160
new ProtectionProfileAssociationInput(

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/lib/PSContracts.cs

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public class HyperVReplicaAzureProtectionProfileInput
577577
/// application consistent snapshot within the VM.
578578
/// </summary>
579579
[DataMember]
580-
public int AppConsistencyFreq { get; set; }
580+
public int ApplicationConsistentSnapshotFrequencyInHours { get; set; }
581581

582582
/// <summary>
583583
/// Gets or sets the replication interval.
@@ -590,7 +590,7 @@ public class HyperVReplicaAzureProtectionProfileInput
590590
/// is Null, the initial replication starts immediately.
591591
/// </summary>
592592
[DataMember]
593-
public TimeSpan? OnlineIrStartTime { get; set; }
593+
public TimeSpan? OnlineReplicationStartTime { get; set; }
594594

595595
/// <summary>
596596
/// Gets or sets the list of storage accounts to which the VMs in the primary cloud can
@@ -600,11 +600,90 @@ public class HyperVReplicaAzureProtectionProfileInput
600600
public List<CustomerStorageAccount> StorageAccounts { get; set; }
601601

602602
/// <summary>
603-
/// Gets or sets a value indicating whether encryption needs to be enabled for
604-
/// Virtual machines in this cloud.
603+
/// Gets or sets a value indicating whether encryption needs to be enabled for virtual machines in this cloud.
605604
/// </summary>
606605
[DataMember]
607-
public bool IsEncryptionEnabled { get; set; }
606+
public bool EncryptionEnabled { get; set; }
607+
}
608+
609+
/// <summary>
610+
/// Hyper-V Replica specific protection profile Input.
611+
/// </summary>
612+
[DataContract(Namespace = "http://schemas.microsoft.com/windowsazure")]
613+
public class HyperVReplicaSP1ProtectionProfileInput
614+
{
615+
/// <summary>
616+
/// Gets or sets a value indicating the number of recovery points.
617+
/// </summary>
618+
[DataMember]
619+
public int RecoveryPoints { get; set; }
620+
621+
/// <summary>
622+
/// Gets or sets a value indicating the application consistent frequency.
623+
/// </summary>
624+
[DataMember]
625+
public int ApplicationConsistentSnapshotFrequencyInHours { get; set; }
626+
627+
/// <summary>
628+
/// Gets or sets a value indicating whether compression has to be enabled.
629+
/// </summary>
630+
[DataMember]
631+
public bool CompressionEnabled { get; set; }
632+
633+
/// <summary>
634+
/// Gets or sets a value indicating whether IR is online.
635+
/// </summary>
636+
[DataMember]
637+
public bool OnlineReplicationMethod { get; set; }
638+
639+
/// <summary>
640+
/// Gets or sets a value indicating the online IR start time.
641+
/// </summary>
642+
[DataMember]
643+
public TimeSpan? OnlineReplicationStartTime { get; set; }
644+
645+
/// <summary>
646+
/// Gets or sets a value indicating the offline IR import path.
647+
/// </summary>
648+
[DataMember]
649+
public string OfflineReplicationImportPath { get; set; }
650+
651+
/// <summary>
652+
/// Gets or sets a value indicating the offline IR export path.
653+
/// </summary>
654+
[DataMember]
655+
public string OfflineReplicationExportPath { get; set; }
656+
657+
/// <summary>
658+
/// Gets or sets a value indicating the recovery HTTPS port.
659+
/// </summary>
660+
[DataMember]
661+
public ushort ReplicationPort { get; set; }
662+
663+
/// <summary>
664+
/// Gets or sets a value indicating the authentication type.
665+
/// </summary>
666+
[DataMember]
667+
public ushort AllowedAuthenticationType { get; set; }
668+
669+
/// <summary>
670+
/// Gets or sets a value indicating whether the VM has to be auto deleted.
671+
/// </summary>
672+
[DataMember]
673+
public bool AllowReplicaDeletion { get; set; }
674+
}
675+
676+
/// <summary>
677+
/// Hyper-V Replica specific protection profile Input.
678+
/// </summary>
679+
[DataContract(Namespace = "http://schemas.microsoft.com/windowsazure")]
680+
public class HyperVReplicaProtectionProfileInput : HyperVReplicaSP1ProtectionProfileInput
681+
{
682+
/// <summary>
683+
/// Gets or sets a value indicating the replication interval.
684+
/// </summary>
685+
[DataMember]
686+
public ushort ReplicationFrequencyInSeconds { get; set; }
608687
}
609688

610689
/// <summary>
@@ -776,7 +855,7 @@ public HyperVReplicaProviderSettings()
776855
/// <summary>
777856
/// Gets or sets Replication Frequency in seconds.
778857
/// </summary>
779-
public int ReplicationFrequencyInSeconds { get; set; }
858+
public ushort ReplicationFrequencyInSeconds { get; set; }
780859

781860
/// <summary>
782861
/// Gets or sets Recovery Points.
@@ -796,7 +875,7 @@ public HyperVReplicaProviderSettings()
796875
/// <summary>
797876
/// Gets or sets the replication port.
798877
/// </summary>
799-
public int ReplicationPort { get; set; }
878+
public ushort ReplicationPort { get; set; }
800879

801880
/// <summary>
802881
/// Gets or sets Replication Start Time.
@@ -857,7 +936,7 @@ public HyperVReplicaAzureProviderSettings()
857936
/// <summary>
858937
/// Gets or sets Replication Frequency in seconds.
859938
/// </summary>
860-
public int ReplicationFrequencyInSeconds { get; set; }
939+
public ushort ReplicationFrequencyInSeconds { get; set; }
861940

862941
/// <summary>
863942
/// Gets or sets Recovery Points.
@@ -877,7 +956,7 @@ public HyperVReplicaAzureProviderSettings()
877956
/// <summary>
878957
/// Gets or sets the replication port.
879958
/// </summary>
880-
public int ReplicationPort { get; set; }
959+
public ushort ReplicationPort { get; set; }
881960

882961
/// <summary>
883962
/// Gets or sets Replication Start Time.

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/lib/PSObjects.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public ASRProtectionContainer(ProtectionContainer pc)
342342
details.ActiveStorageAccount.StorageAccountName;
343343
asrProtectionProfile.HyperVReplicaAzureProviderSettingsObject.RecoveryAzureSubscription =
344344
details.ActiveStorageAccount.SubscriptionId;
345-
asrProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds = details.ReplicationInterval;
345+
asrProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationFrequencyInSeconds = (ushort)details.ReplicationInterval;
346346
asrProtectionProfile.HyperVReplicaAzureProviderSettingsObject.ReplicationMethod = details.OnlineIrStartTime.HasValue ?
347347
Constants.OnlineReplicationMethod :
348348
Constants.OfflineReplicationMethod;

0 commit comments

Comments
 (0)