Skip to content

Introduced RefreshServer #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<Compile Include="Models\PSNetworkObjects.cs" />
<Compile Include="Network\GetAzureRMSiteRecoveryNetwork.cs" />
<Compile Include="Network\GetAzureRMSiteRecoveryNetworkMapping.cs" />
<Compile Include="Server\RefreshAzureSiteRecoveryServer.cs" />
<Compile Include="Network\NewAzureRMSiteRecoveryNetworkMapping.cs" />
<Compile Include="Network\RemoveAzureRMSiteRecoveryNetworkMapping.cs" />
<Compile Include="Server\RemoveAzureSiteRecoveryServer.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,16 @@ public LongRunningOperationResponse PurgeAzureSiteRecoveryProvider(string fabric
{
return this.GetSiteRecoveryClient().RecoveryServicesProvider.BeginPurging(fabricId, providerId, this.GetRequestHeaders());
}

/// <summary>
/// Refresh Azure Site Recovery Provider.
/// </summary>
/// <param name="fabricId">Fabric ID</param>
/// <param name="providerId">Provider ID</param>
/// <returns>Operation response</returns>
public LongRunningOperationResponse RefreshAzureSiteRecoveryProvider(string fabricId, string providerId)
{
return this.GetSiteRecoveryClient().RecoveryServicesProvider.BeginRefreshing(fabricId, providerId, this.GetRequestHeaders());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Management.Automation;
using Microsoft.Azure.Management.SiteRecovery.Models;

namespace Microsoft.Azure.Commands.SiteRecovery
{
/// <summary>
/// Retrieves Azure Site Recovery Server.
/// </summary>
[Cmdlet(VerbsData.Update, "AzureRmSiteRecoveryServer", DefaultParameterSetName = ASRParameterSets.Default)]
public class UpdateAzureRmSiteRecoveryServer : SiteRecoveryCmdletBase
{
#region Parameters

/// <summary>
/// Gets or sets the Server.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public ASRServer Server { get; set; }

#endregion Parameters

/// <summary>
/// ProcessRecord of the command.
/// </summary>
public override void ExecuteCmdlet()
{
try
{
RefreshServer();
}
catch (Exception exception)
{
this.HandleException(exception);
}
}

/// <summary>
/// Refresh Server
/// </summary>
private void RefreshServer()
{
if ((String.Compare(this.Server.FabricType, Constants.VMM) != 0 && String.Compare(this.Server.FabricType, Constants.HyperVSite) != 0))
{
throw new PSInvalidOperationException(Properties.Resources.InvalidServerType);
}

LongRunningOperationResponse response =
RecoveryServicesClient.RefreshAzureSiteRecoveryProvider(Utilities.GetValueFromArmId(this.Server.ID, ARMResourceTypeConstants.ReplicationFabrics), this.Server.Name);

JobResponse jobResponse =
RecoveryServicesClient
.GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

WriteObject(new ASRJob(jobResponse.Job));
}
}
}