Skip to content

Commit 0e0cb60

Browse files
committed
Merge pull request #15 from AsrOneSdk/neha-dev
Bug fixes and Associate protection profile skeleton
2 parents e7da461 + 592b2fe commit 0e0cb60

File tree

12 files changed

+393
-44
lines changed

12 files changed

+393
-44
lines changed

setup/azurecmdfiles.wxi

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,9 @@
11341134
<Component Id="cmp1E1EACEE941A7D7B9B2649BB3AC9ABC3" Guid="*">
11351135
<File Id="fil7BC44111780DA333D7D3C421E0660012" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.Azure.Commands.RecoveryServices.dll-help.xml" />
11361136
</Component>
1137+
<Component Id="cmpDA7CDC821E753EE8914AE51FB8C79B9E" Guid="*">
1138+
<File Id="fil0330F8C95B2B662142B4BFBDEE4B63F3" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.Azure.RecoveryServices.dll" />
1139+
</Component>
11371140
<Component Id="cmp6842A5697846B92CCF6ED50688A26C1A" Guid="*">
11381141
<File Id="filFA33C5B86A806E7029B5DFF9E2F5C12B" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.Azure.ResourceManager.dll" />
11391142
</Component>
@@ -1161,12 +1164,15 @@
11611164
<Component Id="cmpD7A9F76B2346156CA8F83F41A302B714" Guid="*">
11621165
<File Id="fil0218D7505353104A9DB742A55A839351" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Management.dll" />
11631166
</Component>
1164-
<Component Id="cmp4D3E383B38EF4392E70E981B7CA033D7" Guid="*">
1165-
<File Id="fil3D6B846AC421D38C5A9CB40A58B058B6" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Management.SiteRecovery.dll" />
1167+
<Component Id="cmp50D44814DFFEA762A53D9DEDCE48F689" Guid="*">
1168+
<File Id="fil80C14207B99E14F4567B92038EDC8715" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Management.Storage.dll" />
11661169
</Component>
11671170
<Component Id="cmp439E7C155DEEFC3877653E4ED11F66AC" Guid="*">
11681171
<File Id="filE3D7ECC5C92739687FAA34CCE9DFB4A3" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Newtonsoft.Json.dll" />
11691172
</Component>
1173+
<Component Id="cmp9B4CB06D327ECA8FA60032F98004D8BA" Guid="*">
1174+
<File Id="filC935CDA00FB3E840369825B599C84E28" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Security.Cryptography.dll" />
1175+
</Component>
11701176
<Component Id="cmp5278A11908DC26651A78E55522C71DF3" Guid="*">
11711177
<File Id="fil3C9995984C13EAB542D813B85C917916" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\System.Net.Http.Extensions.dll" />
11721178
</Component>
@@ -1176,6 +1182,11 @@
11761182
<Component Id="cmp2A0B3E88742D800F88F70A714BAC94B5" Guid="*">
11771183
<File Id="fil8B5C2678B7FAC0061799DCBFF4AFE27E" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\System.Net.Http.Primitives.dll" />
11781184
</Component>
1185+
<Directory Id="dirB2E733E5A07F5CBD9FFA437A83782545" Name="lib">
1186+
<Component Id="cmpE3495C0DD75A31199E40EAA7E5128E6C" Guid="*">
1187+
<File Id="fil269C9C56525316A4AB13CC9240BF5FE6" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\lib\Security.Cryptography.dll" />
1188+
</Component>
1189+
</Directory>
11791190
</Directory>
11801191
<Directory Id="dir5A14F7172D6373ACE47493BAD054EEF3" Name="Services">
11811192
<Component Id="cmp5F55270F607737A772BFBE2D8F6B76E4" Guid="*">
@@ -2353,6 +2364,7 @@
23532364
<ComponentRef Id="cmpCC09A82900E1A278F48DB77993C40967" />
23542365
<ComponentRef Id="cmpCA80C6C0F5670291AF2F3560D36B1EA3" />
23552366
<ComponentRef Id="cmp1E1EACEE941A7D7B9B2649BB3AC9ABC3" />
2367+
<ComponentRef Id="cmpDA7CDC821E753EE8914AE51FB8C79B9E" />
23562368
<ComponentRef Id="cmp6842A5697846B92CCF6ED50688A26C1A" />
23572369
<ComponentRef Id="cmpEFBAA8731C08B69493F16C6511A3FBC8" />
23582370
<ComponentRef Id="cmp4A98D12853680B70EA13B558FF5B66BE" />
@@ -2362,11 +2374,13 @@
23622374
<ComponentRef Id="cmpA0A697DEB7822A0EC30F3D359EE930A6" />
23632375
<ComponentRef Id="cmpBE209ED6509A7E857FD9F9078051DC6A" />
23642376
<ComponentRef Id="cmpD7A9F76B2346156CA8F83F41A302B714" />
2365-
<ComponentRef Id="cmp4D3E383B38EF4392E70E981B7CA033D7" />
2377+
<ComponentRef Id="cmp50D44814DFFEA762A53D9DEDCE48F689" />
23662378
<ComponentRef Id="cmp439E7C155DEEFC3877653E4ED11F66AC" />
2379+
<ComponentRef Id="cmp9B4CB06D327ECA8FA60032F98004D8BA" />
23672380
<ComponentRef Id="cmp5278A11908DC26651A78E55522C71DF3" />
23682381
<ComponentRef Id="cmp4ED39EDE761ED68263635882802FB1B5" />
23692382
<ComponentRef Id="cmp2A0B3E88742D800F88F70A714BAC94B5" />
2383+
<ComponentRef Id="cmpE3495C0DD75A31199E40EAA7E5128E6C" />
23702384
<ComponentRef Id="cmp5F55270F607737A772BFBE2D8F6B76E4" />
23712385
<ComponentRef Id="cmp9EF03D7C53CEE400751AD1905625B82B" />
23722386
<ComponentRef Id="cmpC4F524A9EBF63DAC78B9678CF113D652" />

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@
6868
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework">
6969
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
7070
</Reference>
71-
<Reference Include="Microsoft.WindowsAzure.Management.SiteRecovery, Version=0.9.0.0, Culture=neutral, PublicKeyToken=c66ce9294aae1300, processorArchitecture=MSIL">
72-
<SpecificVersion>False</SpecificVersion>
73-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.0.2.2-preview\lib\net40\Microsoft.WindowsAzure.Management.SiteRecovery.dll</HintPath>
74-
</Reference>
7571
<Reference Include="Microsoft.WindowsAzure.Testing, Version=1.0.5417.13285, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7672
<SpecificVersion>False</SpecificVersion>
7773
<HintPath>..\..\..\packages\Hydra.SpecTestSupport.1.0.5417.13285-prerelease\lib\net45\Microsoft.WindowsAzure.Testing.dll</HintPath>

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<packages>
33
<package id="Hydra.HttpRecorder" version="1.0.5417.13285-prerelease" targetFramework="net45" />
44
<package id="Hydra.SpecTestSupport" version="1.0.5417.13285-prerelease" targetFramework="net45" />
5-
<package id="Microsoft.Azure.Management.RecoveryServices" version="0.2.2-preview" targetFramework="net45" />
65
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
76
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
87
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@
7171
<SpecificVersion>False</SpecificVersion>
7272
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
7373
</Reference>
74-
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
75-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.3.1.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
74+
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75+
<SpecificVersion>False</SpecificVersion>
76+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.3.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
7677
</Reference>
7778
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
7879
<SpecificVersion>False</SpecificVersion>
@@ -142,6 +143,7 @@
142143
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesVMClient.cs" />
143144
<Compile Include="RecoveryServicesCmdletBase.cs" />
144145
<Compile Include="Properties\AssemblyInfo.cs" />
146+
<Compile Include="Service\StartAzureSiteRecoveryProtectionProfileAssociationJob.cs" />
145147
<Compile Include="Service\CreateAzureSiteRecoveryProtectionProfileObject.cs" />
146148
<Compile Include="Service\CreateAzureSiteRecoveryVault.cs" />
147149
<Compile Include="Service\GetAzureSiteRecoveryStorage.cs" />

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesClientHelper.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public class PSRecoveryServicesClientHelper
3333
/// <param name="azureSubscriptionId">Azure Subscription ID</param>
3434
public static void ValidateSubscriptionAccountAssociation(string azureSubscriptionId)
3535
{
36+
if (string.IsNullOrEmpty(azureSubscriptionId))
37+
{
38+
throw new InvalidOperationException(
39+
string.Format(
40+
Properties.Resources.SubscriptionIdIsNotValid));
41+
}
42+
3643
bool associatedSubscription = false;
3744
ProfileClient pc = new ProfileClient();
3845
List<AzureSubscription> subscriptions =
@@ -62,6 +69,13 @@ public static void ValidateSubscriptionAccountAssociation(string azureSubscripti
6269
/// <param name="azureStorageAccount">Storage Account details</param>
6370
public static void ValidateStorageAccountAssociation(string azureStorageAccount)
6471
{
72+
if (string.IsNullOrEmpty(azureStorageAccount))
73+
{
74+
throw new InvalidOperationException(
75+
string.Format(
76+
Properties.Resources.StorageAccountNameIsNotValid));
77+
}
78+
6579
bool associatedAccount = false;
6680

6781
SubscriptionCloudCredentials creds

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

Lines changed: 27 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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,13 @@ ClientRequestId: {3}</value>
212212
<data name="VaultCreationSuccessMessage" xml:space="preserve">
213213
<value>Vault has been created</value>
214214
</data>
215+
<data name="ReplicationStartTimeInvalid" xml:space="preserve">
216+
<value>Replication Start Time span value cannot be greater then 24 hours.</value>
217+
</data>
218+
<data name="StorageAccountNameIsNotValid" xml:space="preserve">
219+
<value>Please enter the storage account name details in the protection profile.</value>
220+
</data>
221+
<data name="SubscriptionIdIsNotValid" xml:space="preserve">
222+
<value>Please enter the subscription ID details.</value>
223+
</data>
215224
</root>

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

Lines changed: 48 additions & 23 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;
@@ -33,7 +34,8 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
3334
/// <summary>
3435
/// Gets or sets Replication Provider of the Protection Profile.
3536
/// </summary>
36-
[Parameter(ParameterSetName = ASRParameterSets.Default, Mandatory = true)]
37+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
38+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
3739
[ValidateNotNullOrEmpty]
3840
[ValidateSet(
3941
Constants.HyperVReplica,
@@ -43,8 +45,7 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
4345
/// <summary>
4446
/// Gets or sets a value for Replication Method of the Protection Profile.
4547
/// </summary>
46-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
47-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
48+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
4849
[ValidateNotNullOrEmpty]
4950
[ValidateSet(
5051
Constants.OnlineReplicationMethod,
@@ -68,59 +69,61 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
6869
/// <summary>
6970
/// Gets or sets Replication Frequency of the Protection Profile in seconds.
7071
/// </summary>
71-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
72-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
72+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
73+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
7374
[ValidateNotNullOrEmpty]
74-
public int ReplicationFrequencyInSeconds { get; set; }
75+
[DefaultValue(300)]
76+
public ushort ReplicationFrequencyInSeconds { get; set; }
7577

7678
/// <summary>
7779
/// Gets or sets Recovery Points of the Protection Profile.
7880
/// </summary>
79-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
80-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
81+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
82+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
8183
[ValidateNotNullOrEmpty]
84+
[DefaultValue(0)]
8285
public int RecoveryPoints { get; set; }
8386

8487
/// <summary>
8588
/// Gets or sets Application Consistent Snapshot Frequency of the Protection Profile in hours.
8689
/// </summary>
87-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
88-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
90+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
91+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
8992
[ValidateNotNullOrEmpty]
93+
[DefaultValue(0)]
9094
public int ApplicationConsistentSnapshotFrequencyInHours { get; set; }
9195

9296
/// <summary>
9397
/// Gets or sets a value indicating whether Compression needs to be Enabled on the Protection Profile.
9498
/// </summary>
95-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
96-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
97-
[ValidateNotNullOrEmpty]
98-
public bool CompressionEnabled { get; set; }
99+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
100+
[DefaultValue(true)]
101+
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)]
122-
[ValidateNotNullOrEmpty]
123-
public bool AllowReplicaDeletion { get; set; }
124+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
125+
[DefaultValue(false)]
126+
public SwitchParameter AllowReplicaDeletion { get; set; }
124127

125128
#endregion Parameters
126129

@@ -163,10 +166,12 @@ protected override void StopProcessing()
163166
private void EnterpriseToAzureProtectionProfileObject()
164167
{
165168
// Verify whether the storage account is associated with the account or not.
166-
PSRecoveryServicesClientHelper.ValidateStorageAccountAssociation(this.RecoveryAzureStorageAccount);
169+
// PSRecoveryServicesClientHelper.ValidateStorageAccountAssociation(this.RecoveryAzureStorageAccount);
167170

168171
// Verify whether the subscription is associated with the account or not.
169-
PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
172+
// PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
173+
174+
this.ValidateReplicationStartTime(this.ReplicationStartTime);
170175

171176
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
172177
{
@@ -190,11 +195,31 @@ private void EnterpriseToAzureProtectionProfileObject()
190195
this.WriteObject(protectionProfile);
191196
}
192197

198+
/// <summary>
199+
/// Validates if the time span object has a valid value.
200+
/// </summary>
201+
/// <param name="timeSpan">Time span object to be validated</param>
202+
private void ValidateReplicationStartTime(TimeSpan? timeSpan)
203+
{
204+
if (timeSpan == null)
205+
{
206+
return;
207+
}
208+
209+
if (TimeSpan.Compare(timeSpan.Value, new TimeSpan(24, 0, 0)) == 1)
210+
{
211+
throw new InvalidOperationException(
212+
string.Format(Properties.Resources.ReplicationStartTimeInvalid));
213+
}
214+
}
215+
193216
/// <summary>
194217
/// Creates an E2E Protection Profile object
195218
/// </summary>
196219
private void EnterpriseToEnterpriseProtectionProfileObject()
197220
{
221+
this.ValidateReplicationStartTime(this.ReplicationStartTime);
222+
198223
ASRProtectionProfile protectionProfile = new ASRProtectionProfile()
199224
{
200225
ReplicationProvider = this.ReplicationProvider,

0 commit comments

Comments
 (0)