Skip to content

Commit d18c187

Browse files
committed
New cmdlets for Pool pairing (SAN)
1 parent 8bb31e3 commit d18c187

File tree

6 files changed

+483
-0
lines changed

6 files changed

+483
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<DesignTime>True</DesignTime>
123123
<DependentUpon>Resources.resx</DependentUpon>
124124
</Compile>
125+
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesStoragePoolMappingClient.cs" />
125126
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesCloudServiceClient.cs" />
126127
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesProtectionProfileClient.cs" />
127128
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesClientHelper.cs" />
@@ -144,6 +145,9 @@
144145
<Compile Include="PSRecoveryServicesClient\PSRecoveryServicesVMClient.cs" />
145146
<Compile Include="RecoveryServicesCmdletBase.cs" />
146147
<Compile Include="Properties\AssemblyInfo.cs" />
148+
<Compile Include="Service\NewAzureSiteRecoveryStoragePoolMapping.cs" />
149+
<Compile Include="Service\RemoveAzureSiteRecoveryStoragePoolMapping.cs" />
150+
<Compile Include="Service\GetAzureSiteRecoveryStoragePoolMapping.cs" />
147151
<Compile Include="Service\NewAzureSiteRecoverySite.cs" />
148152
<Compile Include="Service\GetAzureSiteRecoverySite.cs" />
149153
<Compile Include="Service\SetAzureSiteRecoveryVM.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 Microsoft.WindowsAzure;
17+
using Microsoft.WindowsAzure.Management.SiteRecovery;
18+
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
19+
20+
namespace Microsoft.Azure.Commands.RecoveryServices
21+
{
22+
/// <summary>
23+
/// Recovery services convenience client.
24+
/// </summary>
25+
public partial class PSRecoveryServicesClient
26+
{
27+
/// <summary>
28+
/// Gets Azure Site Recovery Storage pool mappings.
29+
/// </summary>
30+
/// <param name="primaryServerId">Primary server ID</param>
31+
/// <param name="recoveryServerId">Recovery server ID</param>
32+
/// <returns>Storage pool mapping list response</returns>
33+
public StoragePoolMappingListResponse GetAzureSiteRecoveryStoragePoolMappings(
34+
string primaryServerId,
35+
string recoveryServerId)
36+
{
37+
return this.GetSiteRecoveryClient()
38+
.StoragePoolMappings
39+
.List(primaryServerId, recoveryServerId, this.GetRequestHeaders());
40+
}
41+
42+
/// <summary>
43+
/// Create Azure Site Recovery Storage pool mapping.
44+
/// </summary>
45+
/// <param name="primaryServerId">Primary server Id</param>
46+
/// <param name="primaryArrayId">Primary array Id</param>
47+
/// <param name="primaryStoragePoolId">Primary storage pool Id</param>
48+
/// <param name="recoveryServerId">Recovery server Id</param>
49+
/// <param name="recoveryArrayId">Recovery array Id</param>
50+
/// <param name="recoveryStoragePoolId">Recovery storage pool Id</param>
51+
/// <returns>Job response</returns>
52+
public JobResponse NewAzureSiteRecoveryStoragePoolMapping(
53+
string primaryServerId,
54+
string primaryArrayId,
55+
string primaryStoragePoolId,
56+
string recoveryServerId,
57+
string recoveryArrayId,
58+
string recoveryStoragePoolId)
59+
{
60+
StoragePoolMappingInput parameters = new StoragePoolMappingInput();
61+
parameters.PrimaryServerId = primaryServerId;
62+
parameters.PrimaryArrayId = primaryArrayId;
63+
parameters.PrimaryStoragePoolId = primaryStoragePoolId;
64+
parameters.RecoveryServerId = recoveryServerId;
65+
parameters.RecoveryArrayId = recoveryArrayId;
66+
parameters.RecoveryStoragePoolId = recoveryStoragePoolId;
67+
68+
return this.GetSiteRecoveryClient()
69+
.StoragePoolMappings
70+
.Create(parameters, this.GetRequestHeaders());
71+
}
72+
73+
/// <summary>
74+
/// Delete Azure Site Recovery Storage pool mapping.
75+
/// </summary>
76+
/// <param name="primaryServerId">Primary server Id</param>
77+
/// <param name="primaryArrayId">Primary array Id</param>
78+
/// <param name="primaryStoragePoolId">Primary storage pool Id</param>
79+
/// <param name="recoveryServerId">Recovery server Id</param>
80+
/// <param name="recoveryArrayId">Recovery array Id</param>
81+
/// <param name="recoveryStoragePoolId">Recovery storage pool Id</param>
82+
/// <returns>Job response</returns>
83+
public JobResponse RemoveAzureSiteRecoveryStoragePoolMapping(
84+
string primaryServerId,
85+
string primaryArrayId,
86+
string primaryStoragePoolId,
87+
string recoveryServerId,
88+
string recoveryArrayId,
89+
string recoveryStoragePoolId)
90+
{
91+
StoragePoolMappingInput parameters = new StoragePoolMappingInput();
92+
parameters.PrimaryServerId = primaryServerId;
93+
parameters.PrimaryArrayId = primaryArrayId;
94+
parameters.PrimaryStoragePoolId = primaryStoragePoolId;
95+
parameters.RecoveryServerId = recoveryServerId;
96+
parameters.RecoveryArrayId = recoveryArrayId;
97+
parameters.RecoveryStoragePoolId = recoveryStoragePoolId;
98+
99+
return this.GetSiteRecoveryClient()
100+
.StoragePoolMappings
101+
.Delete(parameters, this.GetRequestHeaders());
102+
}
103+
}
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.RecoveryServices.SiteRecovery;
20+
using Microsoft.WindowsAzure;
21+
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices
24+
{
25+
/// <summary>
26+
/// Retrieves Azure Site Recovery Storage pool mappings.
27+
/// </summary>
28+
[Cmdlet(VerbsCommon.Get, "AzureSiteRecoveryStoragePoolMapping")]
29+
[OutputType(typeof(IEnumerable<ASRStorageMapping>))]
30+
public class GetAzureSiteRecoveryStoragePoolMapping : RecoveryServicesCmdletBase
31+
{
32+
#region Parameters
33+
/// <summary>
34+
/// Gets or sets Primary Server object.
35+
/// </summary>
36+
[Parameter(Mandatory = true)]
37+
[ValidateNotNullOrEmpty]
38+
public ASRServer PrimaryServer { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets Recovery Server object.
42+
/// </summary>
43+
[Parameter(Mandatory = true)]
44+
[ValidateNotNullOrEmpty]
45+
public ASRServer RecoveryServer { get; set; }
46+
47+
#endregion Parameters
48+
49+
/// <summary>
50+
/// ProcessRecord of the command.
51+
/// </summary>
52+
public override void ExecuteCmdlet()
53+
{
54+
try
55+
{
56+
StoragePoolMappingListResponse storagePoolMappingListResponse =
57+
RecoveryServicesClient
58+
.GetAzureSiteRecoveryStoragePoolMappings(this.PrimaryServer.ID, this.RecoveryServer.ID);
59+
60+
this.WriteStoragePoolMappings(storagePoolMappingListResponse.StoragePoolMappings);
61+
}
62+
catch (Exception exception)
63+
{
64+
this.HandleException(exception);
65+
}
66+
}
67+
68+
/// <summary>
69+
/// Write Storage pool mappings.
70+
/// </summary>
71+
/// <param name="storagePoolMappings">List of Storage pool mappings</param>
72+
private void WriteStoragePoolMappings(IList<StoragePoolMapping> storagePoolMappings)
73+
{
74+
this.WriteObject(storagePoolMappings.Select(spm => new ASRStoragePoolMapping(spm)), true);
75+
}
76+
}
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.RecoveryServices.SiteRecovery;
20+
using Microsoft.WindowsAzure;
21+
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices
24+
{
25+
/// <summary>
26+
/// Creates Azure Site Recovery Storage pool mapping.
27+
/// </summary>
28+
[Cmdlet(VerbsCommon.New, "AzureSiteRecoveryStoragePoolMapping")]
29+
[OutputType(typeof(ASRJob))]
30+
public class NewAzureSiteRecoveryStoragePoolMapping : RecoveryServicesCmdletBase
31+
{
32+
#region Parameters
33+
/// <summary>
34+
/// Job response.
35+
/// </summary>
36+
private JobResponse jobResponse = null;
37+
38+
/// <summary>
39+
/// Gets or sets Primary Storage object.
40+
/// </summary>
41+
[Parameter(Mandatory = true)]
42+
[ValidateNotNullOrEmpty]
43+
public ASRStorage PrimaryStorage { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets Primary Storage pool id.
47+
/// </summary>
48+
[Parameter(Mandatory = true)]
49+
[ValidateNotNullOrEmpty]
50+
public string PrimaryStoragePoolId { get; set; }
51+
52+
/// <summary>
53+
/// Gets or sets Recovery Storage object.
54+
/// </summary>
55+
[Parameter(Mandatory = true)]
56+
[ValidateNotNullOrEmpty]
57+
public ASRStorage RecoveryStorage { get; set; }
58+
59+
/// <summary>
60+
/// Gets or sets Recovery Storage pool id.
61+
/// </summary>
62+
[Parameter(Mandatory = true)]
63+
[ValidateNotNullOrEmpty]
64+
public string RecoveryStoragePoolId { get; set; }
65+
#endregion Parameters
66+
67+
/// <summary>
68+
/// ProcessRecord of the command.
69+
/// </summary>
70+
public override void ExecuteCmdlet()
71+
{
72+
try
73+
{
74+
this.jobResponse =
75+
RecoveryServicesClient
76+
.NewAzureSiteRecoveryStoragePoolMapping(
77+
this.PrimaryStorage.ServerId,
78+
this.PrimaryStorage.ID,
79+
this.PrimaryStoragePoolId,
80+
this.RecoveryStorage.ServerId,
81+
this.RecoveryStorage.ID,
82+
this.RecoveryStoragePoolId);
83+
84+
this.WriteJob(this.jobResponse.Job);
85+
}
86+
catch (Exception exception)
87+
{
88+
this.HandleException(exception);
89+
}
90+
}
91+
92+
/// <summary>
93+
/// Writes Job.
94+
/// </summary>
95+
/// <param name="job">JOB object</param>
96+
private void WriteJob(Microsoft.WindowsAzure.Management.SiteRecovery.Models.Job job)
97+
{
98+
this.WriteObject(new ASRJob(job));
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)