Skip to content

Commit

Permalink
Merge pull request #4 from RecoveryServicesOneSDK/vishak-lrs
Browse files Browse the repository at this point in the history
These changes looks fine from ARS perspective. Merging.
  • Loading branch information
avneeshraiusit committed Apr 13, 2016
2 parents ca483e5 + e8b4c44 commit b35042b
Show file tree
Hide file tree
Showing 11 changed files with 644 additions and 4,493 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\RecoveryServicesDLL\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Recovery Services Vault CRUD Tests
function Test-RecoveryServicesVaultCRUDTests
{
# Create vault
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName S91-1 -Location westus
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName vishakintdrg -Location westus
Assert-NotNull($vaultCreationResponse.Name)
Assert-NotNull($vaultCreationResponse.ID)
Assert-NotNull($vaultCreationResponse.Type)
Expand All @@ -37,14 +37,19 @@ function Test-RecoveryServicesVaultCRUDTests
Assert-NotNull($vault.Type)
}

$vaultBackupProperties = Get-AzureRmRecoveryServicesBackupProperties -Vault $vaultCreationResponse
Assert-NotNull($vaultBackupProperties.BackupStorageRedundancy)

Set-AzureRmRecoveryServicesBackupProperties -Vault $vaultCreationResponse -BackupStorageRedundancy "LocallyRedundant"

# Get the created vault
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName vishakintdrg -Name rsv1
Assert-NotNull($vaultToBeRemoved.Name)
Assert-NotNull($vaultToBeRemoved.ID)
Assert-NotNull($vaultToBeRemoved.Type)

# Remove Vault
Remove-AzureRmRecoveryServicesVault -Vault $vaultToBeRemoved
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName vishakintdrg -Name rsv1
Assert-True { $vaults.Count -eq 0 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static T GetServiceClient<T>() where T : class
if (testEnvironment.UsesCustomUri())
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServicesBVTD2",
"Microsoft.RecoveryServicesBVTD",
testEnvironment.Credentials as SubscriptionCloudCredentials,
testEnvironment.BaseUri);
}
else
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServicesBVTD2",
"Microsoft.RecoveryServicesBVTD",
testEnvironment.Credentials as SubscriptionCloudCredentials);
}
return GetServiceClient<T>(factory, client);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<Private>True</Private>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\RecoveryServicesDLL\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
Expand Down Expand Up @@ -129,10 +129,12 @@
</Compile>
<Compile Include="Utilities\CertUtils.cs" />
<Compile Include="Utilities\Utilities.cs" />
<Compile Include="Vault\GetAzureRmRecoveryServicesBackupProperties.cs" />
<Compile Include="Vault\GetAzureRmRecoveryServicesVaults.cs" />
<Compile Include="Vault\GetAzureRmRecoveryServicesVaultSettingsFile.cs" />
<Compile Include="Vault\NewAzureRmRecoveryServicesVault.cs" />
<Compile Include="Vault\RemoveAzureRmRecoveryServicesVault.cs" />
<Compile Include="Vault\SetAzureRmRecoveryServicesBackupProperties.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,31 @@ public ResourceGroupListResponse GetResouceGroups()
{
return this.GetRecoveryServicesClient.ResourceGroup.List();
}


/// <summary>
/// Method to Update Azure Recovery Services Vault Backup Properties
/// </summary>
/// <param name="resouceGroupName">Name of the resouce group</param>
/// <param name="vaultName">Name of the vault</param>
/// <param name="vaultStorageUpdateRequest">Backup Properties Update</param>
/// <returns>Azure Operation response object.</returns>
public AzureOperationResponse UpdateVaultStorageType(string resouceGroupName, string vaultName, UpdateVaultStorageTypeRequest vaultStorageUpdateRequest)
{
return this.recoveryServicesClient.Vaults.UpdateStorageType(resouceGroupName, vaultName,
vaultStorageUpdateRequest, this.GetRequestHeaders());
}

/// <summary>
/// Method to Get Azure Recovery Services Vault Backup Properties
/// </summary>
/// <param name="resouceGroupName">Name of the resouce group</param>
/// <param name="vaultName">Name of the vault</param>
/// <returns>Azure Resource Storage response object.</returns>
public GetResourceStorageConfigResponse GetVaultStorageType(string resouceGroupName, string vaultName)
{
return this.recoveryServicesClient.Vaults.GetResourceStorageConfig(resouceGroupName, vaultName, this.GetRequestHeaders());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class ARMExceptionDetails
DefaultValueHandling = DefaultValueHandling.Ignore)]
public string ClientRequestId { get; private set; }

/// <summary>
/// <summary>
/// Gets the activity Id for the session.
/// </summary>
[JsonProperty(PropertyName = "activityId")]
Expand Down Expand Up @@ -520,9 +520,10 @@ public class AcsNamespace
/// <param name="acsDetails">authenticating service Details name</param>
public AcsNamespace(UploadCertificateResponse acsDetails)
{
this.HostName = acsDetails.Properties.GlobalAcsHostName;
this.Namespace = acsDetails.Properties.GlobalAcsNamespace;
this.ResourceProviderRealm = acsDetails.Properties.GlobalAcsRPRealm;
this.HostName = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsHostName;
this.Namespace = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsNamespace;
this.ResourceProviderRealm = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsRPRealm;

}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public ARSVault(VaultCreateResponse vault)
public class ASRVaultProperties
{
#region Properties

/// <summary>
/// Gets or sets Provisioning State.
/// </summary>
Expand All @@ -144,6 +144,18 @@ public class ASRVaultProperties
#endregion
}

public class ASRVaultBackupProperties
{
#region Properties

/// <summary>
/// Gets or sets BackupStorageRedundancy type.
/// </summary>
public string BackupStorageRedundancy { get; set; }

#endregion
}

/// <summary>
/// Class to define the output of the vault settings file generation.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// ----------------------------------------------------------------------------------
//
// 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.Get, "AzureRmRecoveryServicesBackupProperties")]
[OutputType(typeof(ASRVaultBackupProperties))]
public class GetAzureRmRecoveryServicesBackupProperties : RecoveryServicesCmdletBase
{
#region Parameters

/// <summary>
/// Gets or sets vault Object.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public ARSVault Vault { get; set; }

#endregion

/// <summary>
/// ProcessRecord of the command.
/// </summary>
public override void ExecuteCmdlet()
{
try
{
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name);
ASRVaultBackupProperties vaultBackupProperties = new ASRVaultBackupProperties();
vaultBackupProperties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
this.WriteObject(vaultBackupProperties);
}
catch (Exception exception)
{
this.HandleException(exception);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// ----------------------------------------------------------------------------------
//
// 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, "AzureRmRecoveryServicesBackupProperties")]
public class SetAzureRmRecoveryServicesBackupProperties : 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; }

#endregion Parameters

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

0 comments on commit b35042b

Please sign in to comment.