Skip to content

Commit

Permalink
Get/Set AzureRmRecoveryServices changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vishak-ms committed Apr 7, 2016
1 parent e586593 commit f16d5cd
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 20 deletions.
8 changes: 8 additions & 0 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<RestorePackages>true</RestorePackages>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\ResourceManager\RecoveryServices\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -189,4 +190,11 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,11 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,11 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,11 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
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>..\..\..\..\..\..\SafeHaven-1604\dll\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 Expand Up @@ -166,4 +166,11 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static T GetServiceClient<T>() where T : class
if (testEnvironment.UsesCustomUri())
{
client = new RecoveryServicesManagementClient(
"Microsoft.RecoveryServicesBVTD2",
"Microsoft.RecoveryServicesBVTD",
testEnvironment.Credentials as SubscriptionCloudCredentials,
testEnvironment.BaseUri);
}
Expand Down
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>..\..\..\..\..\..\SafeHaven-1604\dll\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,6 +129,7 @@
</Compile>
<Compile Include="Utilities\CertUtils.cs" />
<Compile Include="Utilities\Utilities.cs" />
<Compile Include="Vault\SetAzureRmRecoveryServicesVaults.cs" />
<Compile Include="Vault\GetAzureRmRecoveryServicesVaults.cs" />
<Compile Include="Vault\GetAzureRmRecoveryServicesVaultSettingsFile.cs" />
<Compile Include="Vault\NewAzureRmRecoveryServicesVault.cs" />
Expand Down Expand Up @@ -165,4 +166,11 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,29 @@ 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 @@ -520,9 +520,9 @@ 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,12 +135,22 @@ public ARSVault(VaultCreateResponse vault)
public class ASRVaultProperties
{
#region Properties

/// <summary>
/// Gets or sets Provisioning State.
/// </summary>
public string ProvisioningState { get; set; }

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

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

#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,15 @@ private void GetVaultsUnderAllResourceGroups()
/// <param name="vaults">List of Vaults</param>
private void WriteVaults(IList<Vault> vaults)
{
if (string.IsNullOrEmpty(this.Name))
foreach (Vault vault in vaults)
{
this.WriteObject(vaults.Select(v => new ARSVault(v)), true);
}
else
{
foreach (Vault vault in vaults)
if (0 == string.Compare(this.Name, vault.Name, true))
{
if (0 == string.Compare(this.Name, vault.Name, true))
{
this.WriteObject(new ARSVault(vault));
}
ARSVault rsVault = new ARSVault(vault);
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, vault.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
Expand Up @@ -47,6 +47,19 @@ public class NewAzureRmRecoveryServicesVault : RecoveryServicesCmdletBase
[ValidateNotNullOrEmpty]
public string Location { 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

/// <summary>
Expand All @@ -64,7 +77,28 @@ public override void ExecuteCmdlet()

VaultCreateResponse response = RecoveryServicesClient.CreateVault(this.ResourceGroupName, this.Name, vaultCreateArgs);

this.WriteObject(new ARSVault(response));
if (!(string.IsNullOrEmpty(this.BackupStorageRedundancy) && string.IsNullOrEmpty(this.BackupStorageDeduplication)))
{
UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest();
vaultStorageRequest.Properties = new StorageTypeProperties();
vaultStorageRequest.Properties.StorageModelType = this.BackupStorageRedundancy;
vaultStorageRequest.Properties.DedupState = this.BackupStorageDeduplication;
AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.ResourceGroupName, this.Name, vaultStorageRequest);
}

VaultListResponse vaultList = RecoveryServicesClient.GetVaultsInResouceGroup(this.ResourceGroupName);
foreach (Vault vault in vaultList.Vaults)
{
if (vault.Name.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase))
{
ARSVault rsVault = new ARSVault(vault);
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.ResourceGroupName, this.Name);
rsVault.Properties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
rsVault.Properties.BackupStorageDeduplication = getStorageResponse.Properties.DedupState;
this.WriteObject(rsVault);
break;
}
}
}
catch (Exception exception)
{
Expand Down

0 comments on commit f16d5cd

Please sign in to comment.