Skip to content

Commit 586626d

Browse files
committed
Merge pull request #22 from AsrOneSdk/neha-dev
StartAzureSiteRecoveryProtectionProfileDissociationJob cmdlet
2 parents 1b8aec8 + 057605b commit 586626d

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
<Compile Include="Service\SetAzureSiteRecoveryProtectionEntity.cs" />
166166
<Compile Include="Service\StartAzureSiteRecoveryCommitFailoverJob.cs" />
167167
<Compile Include="Service\StartAzureSiteRecoveryPlannedFailoverJob.cs" />
168+
<Compile Include="Service\StartAzureSiteRecoveryProtectionProfileDissociationJob.cs" />
168169
<Compile Include="Service\StartAzureSiteRecoveryTestFailoverJob.cs" />
169170
<Compile Include="Service\StartAzureSiteRecoveryUnPlannedFailoverJob.cs" />
170171
<Compile Include="Service\StopAzureSiteRecoveryJob.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.RecoveryServices.SiteRecovery;
18+
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
19+
20+
namespace Microsoft.Azure.Commands.RecoveryServices
21+
{
22+
/// <summary>
23+
/// Adds Azure Site Recovery Protection Profile settings to a Protection Container.
24+
/// </summary>
25+
[Cmdlet(VerbsLifecycle.Start, "AzureSiteRecoveryProtectionProfileDissociationJob", DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise)]
26+
[OutputType(typeof(ASRJob))]
27+
public class StartAzureSiteRecoveryProtectionProfileDissociationJob : RecoveryServicesCmdletBase
28+
{
29+
/// <summary>
30+
/// Job response.
31+
/// </summary>
32+
private JobResponse jobResponse = null;
33+
34+
#region Parameters
35+
36+
/// <summary>
37+
/// Gets or sets Protection Profile object.
38+
/// </summary>
39+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
40+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
41+
[ValidateNotNullOrEmpty]
42+
public ASRProtectionProfile ProtectionProfile { get; set; }
43+
44+
/// <summary>
45+
/// Gets or sets Protection Container to be removed the Protection Profile settings off.
46+
/// </summary>
47+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
48+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToAzure, Mandatory = true)]
49+
[ValidateNotNullOrEmpty]
50+
public ASRProtectionContainer PrimaryProtectionContainer { get; set; }
51+
52+
/// <summary>
53+
/// Gets or sets Protection Container to be removed the Protection Profile settings off.
54+
/// </summary>
55+
[Parameter(ParameterSetName = ASRParameterSets.EnterpriseToEnterprise, Mandatory = true)]
56+
[ValidateNotNullOrEmpty]
57+
public ASRProtectionContainer RecoveryProtectionContainer { get; set; }
58+
59+
#endregion Parameters
60+
61+
/// <summary>
62+
/// ProcessRecord of the command.
63+
/// </summary>
64+
public override void ExecuteCmdlet()
65+
{
66+
try
67+
{
68+
ProtectionProfileAssociationInput protectionProfileAssociationInput =
69+
new ProtectionProfileAssociationInput(
70+
this.PrimaryProtectionContainer.ID,
71+
this.RecoveryProtectionContainer.ID);
72+
73+
this.jobResponse = RecoveryServicesClient.StartDeleteAndDissociateAzureSiteRecoveryProtectionProfileJob(
74+
this.ProtectionProfile.ID,
75+
protectionProfileAssociationInput);
76+
77+
this.WriteJob(this.jobResponse.Job);
78+
}
79+
catch (Exception exception)
80+
{
81+
this.HandleException(exception);
82+
}
83+
}
84+
85+
/// <summary>
86+
/// Handles interrupts.
87+
/// </summary>
88+
protected override void StopProcessing()
89+
{
90+
// Ctrl + C and etc
91+
base.StopProcessing();
92+
this.StopProcessingFlag = true;
93+
}
94+
95+
/// <summary>
96+
/// Writes Job
97+
/// </summary>
98+
/// <param name="job">Job object</param>
99+
private void WriteJob(Microsoft.WindowsAzure.Management.SiteRecovery.Models.Job job)
100+
{
101+
this.WriteObject(new ASRJob(job));
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)