Skip to content

Commit b35042b

Browse files
Merge pull request #4 from RecoveryServicesOneSDK/vishak-lrs
These changes looks fine from ARS perspective. Merging.
2 parents ca483e5 + e8b4c44 commit b35042b

File tree

11 files changed

+644
-4493
lines changed

11 files changed

+644
-4493
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/Commands.RecoveryServices.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
4949
</Reference>
5050
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
52-
<Private>True</Private>
51+
<SpecificVersion>False</SpecificVersion>
52+
<HintPath>..\RecoveryServicesDLL\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5555
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Recovery Services Vault CRUD Tests
2121
function Test-RecoveryServicesVaultCRUDTests
2222
{
2323
# Create vault
24-
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName S91-1 -Location westus
24+
$vaultCreationResponse = New-AzureRmRecoveryServicesVault -Name rsv1 -ResourceGroupName vishakintdrg -Location westus
2525
Assert-NotNull($vaultCreationResponse.Name)
2626
Assert-NotNull($vaultCreationResponse.ID)
2727
Assert-NotNull($vaultCreationResponse.Type)
@@ -37,14 +37,19 @@ function Test-RecoveryServicesVaultCRUDTests
3737
Assert-NotNull($vault.Type)
3838
}
3939

40+
$vaultBackupProperties = Get-AzureRmRecoveryServicesBackupProperties -Vault $vaultCreationResponse
41+
Assert-NotNull($vaultBackupProperties.BackupStorageRedundancy)
42+
43+
Set-AzureRmRecoveryServicesBackupProperties -Vault $vaultCreationResponse -BackupStorageRedundancy "LocallyRedundant"
44+
4045
# Get the created vault
41-
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
46+
$vaultToBeRemoved = Get-AzureRmRecoveryServicesVault -ResourceGroupName vishakintdrg -Name rsv1
4247
Assert-NotNull($vaultToBeRemoved.Name)
4348
Assert-NotNull($vaultToBeRemoved.ID)
4449
Assert-NotNull($vaultToBeRemoved.Type)
4550

4651
# Remove Vault
4752
Remove-AzureRmRecoveryServicesVault -Vault $vaultToBeRemoved
48-
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName S91-1 -Name rsv1
53+
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName vishakintdrg -Name rsv1
4954
Assert-True { $vaults.Count -eq 0 }
5055
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTestsBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ public static T GetServiceClient<T>() where T : class
8484
if (testEnvironment.UsesCustomUri())
8585
{
8686
client = new RecoveryServicesManagementClient(
87-
"Microsoft.RecoveryServicesBVTD2",
87+
"Microsoft.RecoveryServicesBVTD",
8888
testEnvironment.Credentials as SubscriptionCloudCredentials,
8989
testEnvironment.BaseUri);
9090
}
9191
else
9292
{
9393
client = new RecoveryServicesManagementClient(
94-
"Microsoft.RecoveryServicesBVTD2",
94+
"Microsoft.RecoveryServicesBVTD",
9595
testEnvironment.Credentials as SubscriptionCloudCredentials);
9696
}
9797
return GetServiceClient<T>(factory, client);

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Test.ScenarioTests.RecoveryServicesTests/VaultCRUDTests.json

Lines changed: 460 additions & 4479 deletions
Large diffs are not rendered by default.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
55-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.1.0.2-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
56-
<Private>True</Private>
55+
<SpecificVersion>False</SpecificVersion>
56+
<HintPath>..\RecoveryServicesDLL\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5757
</Reference>
5858
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5959
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
@@ -129,10 +129,12 @@
129129
</Compile>
130130
<Compile Include="Utilities\CertUtils.cs" />
131131
<Compile Include="Utilities\Utilities.cs" />
132+
<Compile Include="Vault\GetAzureRmRecoveryServicesBackupProperties.cs" />
132133
<Compile Include="Vault\GetAzureRmRecoveryServicesVaults.cs" />
133134
<Compile Include="Vault\GetAzureRmRecoveryServicesVaultSettingsFile.cs" />
134135
<Compile Include="Vault\NewAzureRmRecoveryServicesVault.cs" />
135136
<Compile Include="Vault\RemoveAzureRmRecoveryServicesVault.cs" />
137+
<Compile Include="Vault\SetAzureRmRecoveryServicesBackupProperties.cs" />
136138
</ItemGroup>
137139
<ItemGroup>
138140
<EmbeddedResource Include="Properties\Resources.resx">

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/PSRecoveryServicesVaultClient.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,31 @@ public ResourceGroupListResponse GetResouceGroups()
6363
{
6464
return this.GetRecoveryServicesClient.ResourceGroup.List();
6565
}
66+
67+
68+
/// <summary>
69+
/// Method to Update Azure Recovery Services Vault Backup Properties
70+
/// </summary>
71+
/// <param name="resouceGroupName">Name of the resouce group</param>
72+
/// <param name="vaultName">Name of the vault</param>
73+
/// <param name="vaultStorageUpdateRequest">Backup Properties Update</param>
74+
/// <returns>Azure Operation response object.</returns>
75+
public AzureOperationResponse UpdateVaultStorageType(string resouceGroupName, string vaultName, UpdateVaultStorageTypeRequest vaultStorageUpdateRequest)
76+
{
77+
return this.recoveryServicesClient.Vaults.UpdateStorageType(resouceGroupName, vaultName,
78+
vaultStorageUpdateRequest, this.GetRequestHeaders());
79+
}
80+
81+
/// <summary>
82+
/// Method to Get Azure Recovery Services Vault Backup Properties
83+
/// </summary>
84+
/// <param name="resouceGroupName">Name of the resouce group</param>
85+
/// <param name="vaultName">Name of the vault</param>
86+
/// <returns>Azure Resource Storage response object.</returns>
87+
public GetResourceStorageConfigResponse GetVaultStorageType(string resouceGroupName, string vaultName)
88+
{
89+
return this.recoveryServicesClient.Vaults.GetResourceStorageConfig(resouceGroupName, vaultName, this.GetRequestHeaders());
90+
}
91+
6692
}
6793
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Models/PSContracts.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public class ARMExceptionDetails
175175
DefaultValueHandling = DefaultValueHandling.Ignore)]
176176
public string ClientRequestId { get; private set; }
177177

178-
/// <summary>
178+
/// <summary>
179179
/// Gets the activity Id for the session.
180180
/// </summary>
181181
[JsonProperty(PropertyName = "activityId")]
@@ -520,9 +520,10 @@ public class AcsNamespace
520520
/// <param name="acsDetails">authenticating service Details name</param>
521521
public AcsNamespace(UploadCertificateResponse acsDetails)
522522
{
523-
this.HostName = acsDetails.Properties.GlobalAcsHostName;
524-
this.Namespace = acsDetails.Properties.GlobalAcsNamespace;
525-
this.ResourceProviderRealm = acsDetails.Properties.GlobalAcsRPRealm;
523+
this.HostName = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsHostName;
524+
this.Namespace = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsNamespace;
525+
this.ResourceProviderRealm = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsRPRealm;
526+
526527
}
527528

528529
/// <summary>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Models/PSObjects.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public ARSVault(VaultCreateResponse vault)
135135
public class ASRVaultProperties
136136
{
137137
#region Properties
138-
138+
139139
/// <summary>
140140
/// Gets or sets Provisioning State.
141141
/// </summary>
@@ -144,6 +144,18 @@ public class ASRVaultProperties
144144
#endregion
145145
}
146146

147+
public class ASRVaultBackupProperties
148+
{
149+
#region Properties
150+
151+
/// <summary>
152+
/// Gets or sets BackupStorageRedundancy type.
153+
/// </summary>
154+
public string BackupStorageRedundancy { get; set; }
155+
156+
#endregion
157+
}
158+
147159
/// <summary>
148160
/// Class to define the output of the vault settings file generation.
149161
/// </summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Management.RecoveryServices.Models;
20+
21+
namespace Microsoft.Azure.Commands.RecoveryServices
22+
{
23+
/// <summary>
24+
/// Retrieves Azure Recovery Services Vault.
25+
/// </summary>
26+
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesBackupProperties")]
27+
[OutputType(typeof(ASRVaultBackupProperties))]
28+
public class GetAzureRmRecoveryServicesBackupProperties : RecoveryServicesCmdletBase
29+
{
30+
#region Parameters
31+
32+
/// <summary>
33+
/// Gets or sets vault Object.
34+
/// </summary>
35+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
36+
[ValidateNotNullOrEmpty]
37+
public ARSVault Vault { get; set; }
38+
39+
#endregion
40+
41+
/// <summary>
42+
/// ProcessRecord of the command.
43+
/// </summary>
44+
public override void ExecuteCmdlet()
45+
{
46+
try
47+
{
48+
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name);
49+
ASRVaultBackupProperties vaultBackupProperties = new ASRVaultBackupProperties();
50+
vaultBackupProperties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
51+
this.WriteObject(vaultBackupProperties);
52+
}
53+
catch (Exception exception)
54+
{
55+
this.HandleException(exception);
56+
}
57+
}
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Management.RecoveryServices.Models;
20+
21+
namespace Microsoft.Azure.Commands.RecoveryServices
22+
{
23+
/// <summary>
24+
/// Retrieves Azure Recovery Services Vault.
25+
/// </summary>
26+
[Cmdlet(VerbsCommon.Set, "AzureRmRecoveryServicesBackupProperties")]
27+
public class SetAzureRmRecoveryServicesBackupProperties : RecoveryServicesCmdletBase
28+
{
29+
#region Parameters
30+
/// <summary>
31+
/// Gets or sets vault Object.
32+
/// </summary>
33+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
34+
[ValidateNotNullOrEmpty]
35+
public ARSVault Vault { get; set; }
36+
/// <summary>
37+
/// Gets or sets BackupStorageRedundancy type.
38+
/// </summary>
39+
[Parameter(Mandatory = false)]
40+
public string BackupStorageRedundancy { get; set; }
41+
42+
#endregion Parameters
43+
44+
/// <summary>
45+
/// ProcessRecord of the command.
46+
/// </summary>
47+
public override void ExecuteCmdlet()
48+
{
49+
try
50+
{
51+
if (!string.IsNullOrEmpty(this.BackupStorageRedundancy))
52+
{
53+
UpdateVaultStorageTypeRequest vaultStorageRequest = new UpdateVaultStorageTypeRequest();
54+
vaultStorageRequest.Properties = new StorageTypeProperties();
55+
vaultStorageRequest.Properties.StorageModelType = BackupStorageRedundancy;
56+
AzureOperationResponse storageResponse = RecoveryServicesClient.UpdateVaultStorageType(this.Vault.ResouceGroupName, this.Vault.Name, vaultStorageRequest);
57+
}
58+
}
59+
catch (Exception exception)
60+
{
61+
this.HandleException(exception);
62+
}
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)