Skip to content

Commit

Permalink
[Get/Set AzureRmRecoveryServicesvault] Adding Missing Files and some …
Browse files Browse the repository at this point in the history
…code changes
  • Loading branch information
vishak-ms committed Apr 7, 2016
1 parent f16d5cd commit b003b74
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ private void WriteVaults(IList<Vault> vaults)
{
foreach (Vault vault in vaults)
{
if (0 == string.Compare(this.Name, vault.Name, true))
if (0 == string.Compare(this.Name, vault.Name, true) || string.IsNullOrEmpty(this.Name))
{
ARSVault rsVault = new ARSVault(vault);
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, vault.Name);
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(rsVault.ResouceGroupName, rsVault.Name);
rsVault.Properties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
rsVault.Properties.BackupStorageDeduplication = getStorageResponse.Properties.DedupState;
this.WriteObject(new ARSVault(vault));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// ----------------------------------------------------------------------------------
//
// 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.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using Microsoft.Azure.Management.RecoveryServices.Models;

namespace Microsoft.Azure.Commands.RecoveryServices
{
/// <summary>
/// Retrieves Azure Recovery Services Vault.
/// </summary>
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesVault")]
public class SetAzureRmRecoveryServicesVaults : RecoveryServicesCmdletBase
{
#region Parameters
/// <summary>
/// Gets or sets vault Object.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public ARSVault Vault { get; set; }
/// <summary>
/// Gets or sets BackupStorageRedundancy type.
/// </summary>
[Parameter(Mandatory = false)]
public string BackupStorageRedundancy { get; set; }

/// <summary>
/// Gets or sets BackupStorageDeduplication type.
/// </summary>
[Parameter(Mandatory = false)]
public string BackupStorageDeduplication { get; set; }
#endregion Parameters

/// <summary>
/// ProcessRecord of the command.
/// </summary>
public override void ExecuteCmdlet()
{
try
{
if (!(string.IsNullOrEmpty(this.BackupStorageRedundancy) && string.IsNullOrEmpty(this.BackupStorageDeduplication)))
{
UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest();
vaultStorageRequest.Properties = new StorageTypeProperties();
vaultStorageRequest.Properties.StorageModelType = BackupStorageRedundancy;
vaultStorageRequest.Properties.DedupState = BackupStorageDeduplication;
AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name, vaultStorageRequest);
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
}
}
}

0 comments on commit b003b74

Please sign in to comment.