Skip to content

Commit 24827f7

Browse files
committed
RefreshServer
1 parent e586593 commit 24827f7

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Commands.SiteRecovery.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
<Compile Include="Models\PSNetworkObjects.cs" />
135135
<Compile Include="Network\GetAzureRMSiteRecoveryNetwork.cs" />
136136
<Compile Include="Network\GetAzureRMSiteRecoveryNetworkMapping.cs" />
137+
<Compile Include="Server\RefreshAzureSiteRecoveryServer.cs" />
137138
<Compile Include="Network\NewAzureRMSiteRecoveryNetworkMapping.cs" />
138139
<Compile Include="Network\RemoveAzureRMSiteRecoveryNetworkMapping.cs" />
139140
<Compile Include="Server\RemoveAzureSiteRecoveryServer.cs" />

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Common/PSSiteRecoveryRecoveryServicesProviderClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,16 @@ public LongRunningOperationResponse PurgeAzureSiteRecoveryProvider(string fabric
6666
{
6767
return this.GetSiteRecoveryClient().RecoveryServicesProvider.BeginPurging(fabricId, providerId, this.GetRequestHeaders());
6868
}
69+
70+
/// <summary>
71+
/// Refresh Azure Site Recovery Provider.
72+
/// </summary>
73+
/// <param name="fabricId">Fabric ID</param>
74+
/// <param name="providerId">Provider ID</param>
75+
/// <returns>Operation response</returns>
76+
public LongRunningOperationResponse RefreshAzureSiteRecoveryProvider(string fabricId, string providerId)
77+
{
78+
return this.GetSiteRecoveryClient().RecoveryServicesProvider.BeginRefreshing(fabricId, providerId, this.GetRequestHeaders());
79+
}
6980
}
7081
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.Management.SiteRecovery.Models;
18+
19+
namespace Microsoft.Azure.Commands.SiteRecovery
20+
{
21+
/// <summary>
22+
/// Retrieves Azure Site Recovery Server.
23+
/// </summary>
24+
[Cmdlet(VerbsData.Update, "AzureRmSiteRecoveryServer", DefaultParameterSetName = ASRParameterSets.Default)]
25+
public class UpdateAzureRmSiteRecoveryServer : SiteRecoveryCmdletBase
26+
{
27+
#region Parameters
28+
29+
/// <summary>
30+
/// Gets or sets the Server.
31+
/// </summary>
32+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
33+
[ValidateNotNullOrEmpty]
34+
public ASRServer Server { get; set; }
35+
36+
#endregion Parameters
37+
38+
/// <summary>
39+
/// ProcessRecord of the command.
40+
/// </summary>
41+
public override void ExecuteCmdlet()
42+
{
43+
try
44+
{
45+
RefreshServer();
46+
}
47+
catch (Exception exception)
48+
{
49+
this.HandleException(exception);
50+
}
51+
}
52+
53+
/// <summary>
54+
/// Refresh Server
55+
/// </summary>
56+
private void RefreshServer()
57+
{
58+
if ((String.Compare(this.Server.FabricType, Constants.VMM) != 0 && String.Compare(this.Server.FabricType, Constants.HyperVSite) != 0))
59+
{
60+
throw new PSInvalidOperationException(Properties.Resources.InvalidServerType);
61+
}
62+
63+
LongRunningOperationResponse response =
64+
RecoveryServicesClient.RefreshAzureSiteRecoveryProvider(Utilities.GetValueFromArmId(this.Server.ID, ARMResourceTypeConstants.ReplicationFabrics), this.Server.Name);
65+
66+
JobResponse jobResponse =
67+
RecoveryServicesClient
68+
.GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));
69+
70+
WriteObject(new ASRJob(jobResponse.Job));
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)