Skip to content

Commit ebdb880

Browse files
committed
Bug fixes and modifications
1 parent f5c40c6 commit ebdb880

7 files changed

+47
-11
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@
142142
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesVMClient.cs" />
143143
<Compile Include="RecoveryServicesCmdletBase.cs" />
144144
<Compile Include="Properties\AssemblyInfo.cs" />
145+
<Compile Include="Service\SetAzureSiteRecoveryProtectionProfile.cs" />
146+
<Compile Include="Service\StartAzureSiteRecoveryProtectionProfileDissociationJob.cs" />
147+
<Compile Include="Service\StartAzureSiteRecoveryProtectionProfileAssociationJob.cs" />
145148
<Compile Include="Service\CreateAzureSiteRecoveryProtectionProfileObject.cs" />
146149
<Compile Include="Service\CreateAzureSiteRecoveryVault.cs" />
147150
<Compile Include="Service\GetAzureSiteRecoveryStorage.cs" />

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,7 @@ ClientRequestId: {3}</value>
209209
<data name="VaultCreationSuccessMessage" xml:space="preserve">
210210
<value>Vault has been created</value>
211211
</data>
212+
<data name="ReplicationStartTimeInvalid" xml:space="preserve">
213+
<value>Replication Start Time span value cannot be greater then 24 hours.</value>
214+
</data>
212215
</root>

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
3333
/// <summary>
3434
/// Gets or sets Replication Provider of the Protection Profile.
3535
/// </summary>
36-
[Parameter(ParameterSetName = ASRParameterSets.Default, Mandatory = true)]
36+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
37+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
3738
[ValidateNotNullOrEmpty]
3839
[ValidateSet(
3940
Constants.HyperVReplica,
@@ -94,8 +95,7 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
9495
/// </summary>
9596
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
9697
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
97-
[ValidateNotNullOrEmpty]
98-
public bool CompressionEnabled { get; set; }
98+
public SwitchParameter CompressionEnabled { get; set; }
9999

100100
/// <summary>
101101
/// Gets or sets the Replication Port of the Protection Profile.
@@ -119,8 +119,7 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
119119
/// </summary>
120120
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
121121
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
122-
[ValidateNotNullOrEmpty]
123-
public bool AllowReplicaDeletion { get; set; }
122+
public SwitchParameter AllowReplicaDeletion { get; set; }
124123

125124
#endregion Parameters
126125

@@ -168,6 +167,8 @@ private void EnterpriseToAzureProtectionProfileObject()
168167
// Verify whether the subscription is associated with the account or not.
169168
PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
170169

170+
this.ValidateReplicationStartTime(this.ReplicationStartTime);
171+
171172
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
172173
{
173174
ReplicationProvider = this.ReplicationProvider,
@@ -190,11 +191,31 @@ private void EnterpriseToAzureProtectionProfileObject()
190191
this.WriteObject(protectionProfile);
191192
}
192193

194+
/// <summary>
195+
/// Validates if the time span object has a valid value.
196+
/// </summary>
197+
/// <param name="timeSpan">Time span object to be validated</param>
198+
private void ValidateReplicationStartTime(TimeSpan? timeSpan)
199+
{
200+
if (timeSpan == null)
201+
{
202+
return;
203+
}
204+
205+
if (TimeSpan.Compare(timeSpan.Value, new TimeSpan(24, 0, 0)) == 1)
206+
{
207+
throw new InvalidOperationException(
208+
string.Format(Properties.Resources.ReplicationStartTimeInvalid));
209+
}
210+
}
211+
193212
/// <summary>
194213
/// Creates an E2E Protection Profile object
195214
/// </summary>
196215
private void EnterpriseToEnterpriseProtectionProfileObject()
197216
{
217+
this.ValidateReplicationStartTime(this.ReplicationStartTime);
218+
198219
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
199220
{
200221
ReplicationProvider = this.ReplicationProvider,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ namespace Microsoft.Azure.Commands.RecoveryServices
2929
[OutputType(typeof(ASRJob))]
3030
public class SetAzureSiteRecoveryProtectionProfile : RecoveryServicesCmdletBase
3131
{
32-
#region Parameters
33-
3432
/// <summary>
3533
/// Job response.
3634
/// </summary>
3735
private JobResponse jobResponse = null;
3836

37+
#region Parameters
38+
3939
/// <summary>
4040
/// Gets or sets Protection Profile object.
4141
/// </summary>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ namespace Microsoft.Azure.Commands.RecoveryServices
2727
[OutputType(typeof(ASRJob))]
2828
public class StartAzureSiteRecoveryProtectionProfileJob : RecoveryServicesCmdletBase
2929
{
30-
#region Parameters
31-
3230
/// <summary>
3331
/// Job response.
3432
/// </summary>
3533
private JobResponse jobResponse = null;
3634

35+
#region Parameters
36+
3737
/// <summary>
3838
/// Gets or sets Protection Container to be applied the Protection Profile settings on.
3939
/// </summary>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ namespace Microsoft.Azure.Commands.RecoveryServices
2626
[OutputType(typeof(ASRJob))]
2727
public class StartAzureSiteRecoveryProtectionProfileDissociationJob : RecoveryServicesCmdletBase
2828
{
29-
#region Parameters
30-
3129
/// <summary>
3230
/// Job response.
3331
/// </summary>
3432
private JobResponse jobResponse = null;
3533

34+
#region Parameters
35+
3636
/// <summary>
3737
/// Gets or sets Protection Container to be removed the Protection Profile settings off.
3838
/// </summary>

0 commit comments

Comments
 (0)