Skip to content

Commit 1b27986

Browse files
committed
Merge pull request #37 from AsrOneSdk/neha-dev
Bug fixes in new protection profile cmdlet
2 parents 7a72b59 + 28745db commit 1b27986

File tree

5 files changed

+9
-34
lines changed

5 files changed

+9
-34
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@
6363
<SpecificVersion>False</SpecificVersion>
6464
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
6565
</Reference>
66-
<Reference Include="Microsoft.WindowsAzure.Commands.ServiceManagement">
67-
<HintPath>..\..\..\Package\Debug\ServiceManagement\Azure\Compute\Microsoft.WindowsAzure.Commands.ServiceManagement.dll</HintPath>
68-
</Reference>
6966
<Reference Include="Microsoft.WindowsAzure.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7067
<SpecificVersion>False</SpecificVersion>
7168
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.dll</HintPath>

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17-
using System.Collections.ObjectModel;
18-
using System.Management.Automation;
19-
using Microsoft.WindowsAzure;
2017
using Microsoft.WindowsAzure.Commands.Common;
2118
using Microsoft.WindowsAzure.Commands.Common.Models;
22-
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
23-
using Microsoft.WindowsAzure.Management.Storage;
24-
using Microsoft.WindowsAzure.Management.Storage.Models;
2519

2620
namespace Microsoft.Azure.Commands.RecoveryServices
2721
{
@@ -81,25 +75,6 @@ public static void ValidateStorageAccountAssociation(string azureStorageAccount)
8175

8276
bool associatedAccount = false;
8377

84-
using (System.Management.Automation.PowerShell powerShellInstance = System.Management.Automation.PowerShell.Create())
85-
{
86-
powerShellInstance.AddCommand("Get-AzureStorageAccount");
87-
Collection<PSObject> powershellOutput = powerShellInstance.Invoke();
88-
89-
foreach (var storage in powershellOutput)
90-
{
91-
if (storage.BaseObject is StorageServicePropertiesOperationContext)
92-
{
93-
StorageServicePropertiesOperationContext storageAccount = (StorageServicePropertiesOperationContext)storage.BaseObject;
94-
if (azureStorageAccount.Equals(storageAccount.StorageAccountName, StringComparison.OrdinalIgnoreCase))
95-
{
96-
associatedAccount = true;
97-
break;
98-
}
99-
}
100-
}
101-
}
102-
10378
if (!associatedAccount)
10479
{
10580
throw new InvalidOperationException(

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft.Azure.Commands.RecoveryServices
2525
/// <summary>
2626
/// Creates Azure Site Recovery Protection Profile object in memory.
2727
/// </summary>
28-
[Cmdlet(VerbsCommon.New, "AzureSiteRecoveryProtectionProfileObject", DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
28+
[Cmdlet(VerbsCommon.New, "AzureSiteRecoveryProtectionProfileObject", DefaultParameterSetName = ASRParameterSets.EnterpriseToAzure)]
2929
[OutputType(typeof(ASRProtectionProfile))]
3030
public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCmdletBase
3131
{
@@ -76,8 +76,8 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
7676
/// <summary>
7777
/// Gets or sets Replication Frequency of the Protection Profile in seconds.
7878
/// </summary>
79-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
80-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure)]
79+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
80+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
8181
[ValidateNotNullOrEmpty]
8282
[ValidateSet(
8383
Constants.Thirty,
@@ -113,7 +113,7 @@ public class CreateAzureSiteRecoveryProtectionProfileObject : RecoveryServicesCm
113113
/// <summary>
114114
/// Gets or sets the Replication Port of the Protection Profile.
115115
/// </summary>
116-
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
116+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
117117
[ValidateNotNullOrEmpty]
118118
public ushort ReplicationPort { get; set; }
119119

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
170170
ReplicationFrequencyInSeconds = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationFrequencyInSeconds,
171171
OnlineReplicationStartTime = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationStartTime,
172172
CompressionEnabled = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.CompressionEnabled,
173-
OnlineReplicationMethod = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 1) ? true : false,
173+
OnlineReplicationMethod = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? true : false,
174174
RecoveryPoints = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.RecoveryPoints,
175175
ReplicationPort = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationPort,
176176
AllowReplicaDeletion = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.AllowReplicaDeletion,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public override void ExecuteCmdlet()
7171
case ASRParameterSets.EnterpriseToAzure:
7272
if (this.ProtectionProfile.ReplicationProvider != Constants.HyperVReplicaAzure)
7373
{
74-
throw new Exception("Please provide recovery contianer object.");
74+
throw new InvalidOperationException(
75+
string.Format(
76+
Properties.Resources.IncorrectReplicationProvider,
77+
this.ProtectionProfile.ReplicationProvider));
7578
}
7679
else
7780
{

0 commit comments

Comments
 (0)