Skip to content

Commit 6032c57

Browse files
committed
Merge pull request #16 from AsrOneSdk/sanjkuma-dev
Version change with few changes for smooth E2E VM/RP flow.
2 parents 7a3fe28 + 2b73a1d commit 6032c57

12 files changed

+171
-126
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public PSRecoveryServicesClient(AzureSubscription azureSubscription)
9595
AzureSession.ClientFactory.CreateClient<RecoveryServicesManagementClient>(azureSubscription, AzureEnvironment.Endpoint.ServiceManagement);
9696
}
9797

98+
9899
/// <summary>
99100
/// Retrieves Azure Cloud services.
100101
/// </summary>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ public JobResponse StartAzureSiteRecoveryCommitFailover(
172172
/// </summary>
173173
/// <param name="protectionContainerId">Protection Container ID</param>
174174
/// <param name="protectionEntityId">Recovery Plan ID</param>
175+
/// <param name="request">Re-protect request.</param>
175176
/// <returns>Job response</returns>
176177
public JobResponse StartAzureSiteRecoveryReprotection(
177178
string protectionContainerId,
178-
string protectionEntityId)
179+
string protectionEntityId,
180+
ReprotectRequest request)
179181
{
180-
var request = new ReprotectRequest();
181182
return this.GetSiteRecoveryClient().ProtectionEntity.Reprotect(
182183
protectionContainerId,
183184
protectionEntityId,

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ protected override void StopProcessing()
165165
/// </summary>
166166
private void EnterpriseToAzureProtectionProfileObject()
167167
{
168-
// Verify whether the storage account is associated with the account or not.
169-
// PSRecoveryServicesClientHelper.ValidateStorageAccountAssociation(this.RecoveryAzureStorageAccount);
168+
//// Verify whether the storage account is associated with the account or not.
169+
//// PSRecoveryServicesClientHelper.ValidateStorageAccountAssociation(this.RecoveryAzureStorageAccount);
170170

171-
// Verify whether the subscription is associated with the account or not.
172-
// PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
171+
//// Verify whether the subscription is associated with the account or not.
172+
//// PSRecoveryServicesClientHelper.ValidateSubscriptionAccountAssociation(this.RecoveryAzureSubscription);
173173

174174
this.ValidateReplicationStartTime(this.ReplicationStartTime);
175175

@@ -184,7 +184,6 @@ private void EnterpriseToAzureProtectionProfileObject()
184184
ReplicationFrequencyInSeconds = this.ReplicationFrequencyInSeconds,
185185
RecoveryPoints = this.RecoveryPoints,
186186
ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
187-
CompressionEnabled = this.CompressionEnabled,
188187
ReplicationPort = this.ReplicationPort,
189188
ReplicationStartTime = this.ReplicationStartTime,
190189
AllowReplicaDeletion = this.AllowReplicaDeletion

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ public override void ExecuteCmdlet()
208208

209209
input.ReplicationProviderInput = DataContractUtils.Serialize<AzureEnableProtectionInput>(azureInput);
210210
}
211+
else
212+
{
213+
input.ReplicationProviderInput = string.Empty;
214+
input.ProtectionProfileId = this.ProtectionProfile.ID;
215+
}
211216

212217
this.jobResponse =
213218
RecoveryServicesClient.EnableProtection(

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public class StartAzureSiteRecoveryCommitFailoverJob : RecoveryServicesCmdletBas
7070
[ValidateNotNullOrEmpty]
7171
public ASRProtectionEntity ProtectionEntity { get; set; }
7272

73+
/// <summary>
74+
/// Gets or sets Failover direction for the recovery plan.
75+
/// </summary>
76+
[Parameter(Mandatory = false)]
77+
[ValidateSet(
78+
Constants.PrimaryToRecovery,
79+
Constants.RecoveryToPrimary)]
80+
public string Direction { get; set; }
81+
7382
/// <summary>
7483
/// Gets or sets switch parameter. This is required to wait for job completion.
7584
/// </summary>
@@ -116,27 +125,19 @@ private void SetRpCommit()
116125
{
117126
var request = new CommitFailoverRequest();
118127

119-
if (this.ProtectionEntity == null)
128+
if (this.RecoveryPlan == null)
120129
{
121-
var pe = RecoveryServicesClient.GetAzureSiteRecoveryProtectionEntity(
122-
this.ProtectionContainerId,
123-
this.ProtectionEntityId);
124-
this.ProtectionEntity = new ASRProtectionEntity(pe.ProtectionEntity);
130+
var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan(
131+
this.RPId);
132+
this.RecoveryPlan = new ASRRecoveryPlan(rp.RecoveryPlan);
125133

126-
this.ValidateUsageById(this.ProtectionEntity.ReplicationProvider);
134+
this.ValidateUsageById(this.RecoveryPlan.ReplicationProvider);
127135
}
128136

129-
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
137+
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
130138
request.ReplicationProviderSettings = string.Empty;
131139

132-
if (this.ProtectionEntity.ActiveLocation == Constants.PrimaryLocation)
133-
{
134-
request.FailoverDirection = Constants.PrimaryToRecovery;
135-
}
136-
else
137-
{
138-
request.FailoverDirection = Constants.RecoveryToPrimary;
139-
}
140+
request.FailoverDirection = this.Direction;
140141

141142
this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryCommitFailover(
142143
this.RPId);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ private void StartPEPlannedFailover()
151151

152152
if (this.ProtectionEntity.ReplicationProvider == Constants.HyperVReplicaAzure)
153153
{
154-
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
155154
if (this.Direction == Constants.PrimaryToRecovery)
156155
{
157156
var blob = new AzureFailoverInput();
@@ -166,8 +165,14 @@ private void StartPEPlannedFailover()
166165
request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailbackInput>(blob);
167166
}
168167
}
168+
else
169+
{
170+
request.ReplicationProviderSettings = string.Empty;
171+
}
169172

173+
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
170174
request.FailoverDirection = this.Direction;
175+
171176
this.jobResponse =
172177
RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover(
173178
this.ProtectionContainerId,
@@ -199,7 +204,6 @@ private void StartRpPlannedFailover()
199204

200205
if (this.RecoveryPlan.ReplicationProvider == Constants.HyperVReplicaAzure)
201206
{
202-
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
203207
if (this.Direction == Constants.PrimaryToRecovery)
204208
{
205209
var blob = new AzureFailoverInput();
@@ -215,6 +219,7 @@ private void StartRpPlannedFailover()
215219
}
216220
}
217221

222+
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
218223
request.FailoverDirection = this.Direction;
219224

220225
this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover(

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ private void StartRpTestFailover()
188188
else
189189
{
190190
request.NetworkID = this.networkId;
191+
if (string.IsNullOrEmpty(this.networkType))
192+
{
193+
request.NetworkType = "DisconnectedVMNetworkTypeForTestFailover";
194+
}
191195
}
192196

193197
if (this.RecoveryPlan == null)
@@ -203,7 +207,6 @@ private void StartRpTestFailover()
203207

204208
if (this.RecoveryPlan.ReplicationProvider == Constants.HyperVReplicaAzure)
205209
{
206-
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
207210
if (this.Direction == Constants.PrimaryToRecovery)
208211
{
209212
var blob = new AzureFailoverInput();
@@ -212,18 +215,9 @@ private void StartRpTestFailover()
212215
}
213216
}
214217

218+
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
215219
request.FailoverDirection = this.Direction;
216220

217-
if (this.Network != null)
218-
{
219-
request.NetworkID = this.Network.ID;
220-
this.networkType = "UseVMNetworkTypeForTestFailover";
221-
}
222-
else
223-
{
224-
request.NetworkID = this.networkId;
225-
}
226-
227221
this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryTestFailover(
228222
this.RpId,
229223
request);
@@ -257,7 +251,6 @@ private void StartPETestFailover()
257251

258252
if (this.ProtectionEntity.ReplicationProvider == Constants.HyperVReplicaAzure)
259253
{
260-
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
261254
if (this.Direction == Constants.PrimaryToRecovery)
262255
{
263256
var blob = new AzureFailoverInput();
@@ -266,6 +259,7 @@ private void StartPETestFailover()
266259
}
267260
}
268261

262+
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
269263
request.FailoverDirection = this.Direction;
270264

271265
if (this.Network != null)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ private void StartPEUnplannedFailover()
152152
this.ValidateUsageById(this.ProtectionEntity.ReplicationProvider);
153153
}
154154

155+
request.ReplicationProviderSettings = string.Empty;
156+
155157
if (this.ProtectionEntity.ReplicationProvider == Constants.HyperVReplicaAzure)
156158
{
157159
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
@@ -163,6 +165,7 @@ private void StartPEUnplannedFailover()
163165
}
164166
}
165167

168+
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
166169
request.FailoverDirection = this.Direction;
167170
request.SourceSiteOperations = this.PerformSourceSiteOperations;
168171
this.jobResponse =
@@ -194,6 +197,8 @@ private void StartRpUnPlannedFailover()
194197
this.ValidateUsageById(this.RecoveryPlan.ReplicationProvider);
195198
}
196199

200+
request.ReplicationProviderSettings = string.Empty;
201+
197202
if (this.RecoveryPlan.ReplicationProvider == Constants.HyperVReplicaAzure)
198203
{
199204
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
@@ -205,6 +210,7 @@ private void StartRpUnPlannedFailover()
205210
}
206211
}
207212

213+
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
208214
request.FailoverDirection = this.Direction;
209215
request.PrimaryAction = this.PrimaryAction;
210216

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ public override void ExecuteCmdlet()
121121
/// </summary>
122122
private void SetRpReprotect()
123123
{
124+
var request = new ReprotectRequest();
125+
126+
if (this.RecoveryPlan == null)
127+
{
128+
var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan(
129+
this.RPId);
130+
this.RecoveryPlan = new ASRRecoveryPlan(rp.RecoveryPlan);
131+
132+
this.ValidateUsageById(this.RecoveryPlan.ReplicationProvider);
133+
}
134+
135+
request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
136+
request.ReplicationProviderSettings = string.Empty;
137+
138+
request.FailoverDirection = this.Direction;
139+
124140
this.jobResponse = RecoveryServicesClient.UpdateAzureSiteRecoveryProtection(
125141
this.RPId);
126142

@@ -137,16 +153,15 @@ private void SetRpReprotect()
137153
/// </summary>
138154
private void SetPEReprotect()
139155
{
140-
// Until RR is done active location remains same from where FO was initiated.
141156
if ((this.Direction == Constants.PrimaryToRecovery &&
142-
this.ProtectionEntity.ActiveLocation != Constants.RecoveryLocation) ||
157+
this.ProtectionEntity.ActiveLocation == Constants.RecoveryLocation) ||
143158
(this.Direction == Constants.RecoveryToPrimary &&
144-
this.ProtectionEntity.ActiveLocation != Constants.PrimaryLocation))
159+
this.ProtectionEntity.ActiveLocation == Constants.PrimaryLocation))
145160
{
146161
throw new ArgumentException("Parameter value is not correct.", "Direction");
147162
}
148163

149-
var request = new PlannedFailoverRequest();
164+
var request = new ReprotectRequest();
150165

151166
if (this.ProtectionEntity == null)
152167
{
@@ -158,9 +173,10 @@ private void SetPEReprotect()
158173
this.ValidateUsageById(this.ProtectionEntity.ReplicationProvider);
159174
}
160175

176+
request.ReplicationProviderSettings = string.Empty;
177+
161178
if (this.ProtectionEntity.ReplicationProvider == Constants.HyperVReplicaAzure)
162179
{
163-
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
164180
if (this.Direction == Constants.PrimaryToRecovery)
165181
{
166182
var blob = new AzureReProtectionInput();
@@ -174,11 +190,13 @@ private void SetPEReprotect()
174190
}
175191
}
176192

193+
request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider;
177194
request.FailoverDirection = this.Direction;
178195

179196
this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryReprotection(
180197
this.ProtectionContainerId,
181-
this.ProtectionEntityId);
198+
this.ProtectionEntityId,
199+
request);
182200

183201
this.WriteJob(this.jobResponse.Job);
184202

0 commit comments

Comments
 (0)