Skip to content

Commit 399eee1

Browse files
committed
Merge pull request #269 from MabOneSdk/merge-dev1
Merge dev1
2 parents fc077fe + f18b148 commit 399eee1

File tree

16 files changed

+2439
-228
lines changed

16 files changed

+2439
-228
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
<Reference Include="Microsoft.Azure.Common.NetFramework">
4545
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
4646
</Reference>
47-
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.2.0.0-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
49-
<Private>True</Private>
47+
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<SpecificVersion>False</SpecificVersion>
49+
<HintPath>..\RecoveryServicesDLL\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5050
</Reference>
5151
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5252
<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 rg1 -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 rg1 -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 rg1 -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
@@ -93,14 +93,14 @@ public static T GetServiceClient<T>() where T : class
9393
if (testEnvironment.UsesCustomUri())
9494
{
9595
client = new RecoveryServicesManagementClient(
96-
"Microsoft.RecoveryServicesBVTD2",
96+
"Microsoft.RecoveryServicesBVTD",
9797
testEnvironment.Credentials as SubscriptionCloudCredentials,
9898
testEnvironment.BaseUri);
9999
}
100100
else
101101
{
102102
client = new RecoveryServicesManagementClient(
103-
"Microsoft.RecoveryServicesBVTD2",
103+
"Microsoft.RecoveryServicesBVTD",
104104
testEnvironment.Credentials as SubscriptionCloudCredentials);
105105
}
106106
return GetServiceClient<T>(factory, client);

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

Lines changed: 1898 additions & 207 deletions
Large diffs are not rendered by default.

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,30 @@ public ResourceGroupListResponse GetResouceGroups()
7474
{
7575
return this.GetRecoveryServicesClient.ResourceGroup.List();
7676
}
77+
78+
79+
/// <summary>
80+
/// Method to Update Azure Recovery Services Vault Backup Properties
81+
/// </summary>
82+
/// <param name="resouceGroupName">Name of the resouce group</param>
83+
/// <param name="vaultName">Name of the vault</param>
84+
/// <param name="vaultStorageUpdateRequest">Backup Properties Update</param>
85+
/// <returns>Azure Operation response object.</returns>
86+
public AzureOperationResponse UpdateVaultStorageType(string resouceGroupName, string vaultName, UpdateVaultStorageTypeRequest vaultStorageUpdateRequest)
87+
{
88+
return this.recoveryServicesClient.Vaults.UpdateStorageType(resouceGroupName, vaultName,
89+
vaultStorageUpdateRequest, this.GetRequestHeaders());
90+
}
91+
92+
/// <summary>
93+
/// Method to Get Azure Recovery Services Vault Backup Properties
94+
/// </summary>
95+
/// <param name="resouceGroupName">Name of the resouce group</param>
96+
/// <param name="vaultName">Name of the vault</param>
97+
/// <returns>Azure Resource Storage response object.</returns>
98+
public GetResourceStorageConfigResponse GetVaultStorageType(string resouceGroupName, string vaultName)
99+
{
100+
return this.recoveryServicesClient.Vaults.GetResourceStorageConfig(resouceGroupName, vaultName, this.GetRequestHeaders());
101+
}
77102
}
78103
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ public ASRVaultCreds GenerateVaultCredential(X509Certificate2 managementCert, AR
125125
return arsVaultCreds;
126126
}
127127

128+
/// <summary>
129+
/// Upload cert to idmgmt
130+
/// </summary>
131+
/// <param name="managementCert">certificate to be uploaded</param>
132+
/// <param name="vault">vault object</param>
133+
/// <returns>Upload Certificate Response</returns>
134+
public UploadCertificateResponse UploadCertificate(X509Certificate2 managementCert, ARSVault vault)
135+
{
136+
var certificateArgs = new CertificateArgs();
137+
certificateArgs.Properties = new Dictionary<string, string>();
138+
certificateArgs.Properties.Add("certificate", Convert.ToBase64String(managementCert.GetRawCertData()));
139+
140+
var response = this.recoveryServicesClient.VaultExtendedInfo.UploadCertificateAsync(
141+
vault.ResouceGroupName,
142+
vault.Name,
143+
certificateArgs, managementCert.FriendlyName,
144+
this.GetRequestHeaders());
145+
response.Wait();
146+
return response.Result;
147+
}
148+
128149
/// <summary>
129150
/// Changes the Vault context
130151
/// </summary>

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

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,11 @@ public VaultCreds()
310310
/// <param name="resourceName">resource name</param>
311311
/// <param name="managementCert">management cert</param>
312312
/// <param name="acsNamespace">authenticating service namespace</param>
313-
public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace)
313+
/// <param name="resourceType">resource type backup vault or ASR vault</param>
314+
public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string resourceType = null)
314315
{
315316
this.SubscriptionId = subscriptionId;
316-
this.ResourceType = Constants.VaultType;
317+
this.ResourceType = string.IsNullOrEmpty(resourceType) ? Constants.VaultType : resourceType;
317318
this.ResourceName = resourceName;
318319
this.ManagementCert = managementCert;
319320
this.AcsNamespace = acsNamespace;
@@ -456,6 +457,54 @@ public ASRVaultCreds(
456457
#endregion
457458
}
458459

460+
/// <summary>
461+
/// Class to define backup vault credentials
462+
/// </summary>
463+
[DataContract]
464+
public class BackupVaultCreds : VaultCreds
465+
{
466+
/// <summary>
467+
/// Gets or sets the agent links
468+
/// </summary>
469+
[DataMember(Order = 0)]
470+
public string AgentLinks { get; set; }
471+
472+
#region Constructors
473+
474+
/// <summary>
475+
/// Initializes a new instance of the BackupVaultCreds class
476+
/// </summary>
477+
public BackupVaultCreds() { }
478+
479+
/// <summary>
480+
/// Initializes a new instance of the BackupVaultCreds class
481+
/// </summary>
482+
/// <param name="subscriptionId">subscription Id</param>
483+
/// <param name="resourceType">resource type</param>
484+
/// <param name="resourceName">resource name</param>
485+
/// <param name="managementCert">management cert</param>
486+
/// <param name="acsNamespace">acs namespace</param>
487+
public BackupVaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace)
488+
: base(subscriptionId, resourceName, managementCert, acsNamespace, Constants.BackupVaultType) { }
489+
490+
/// <summary>
491+
/// Initializes a new instance of the BackupVaultCreds class
492+
/// </summary>
493+
/// <param name="subscriptionId">subscription Id</param>
494+
/// <param name="resourceType">resource type</param>
495+
/// <param name="resourceName">resource name</param>
496+
/// <param name="managementCert">management cert</param>
497+
/// <param name="acsNamespace">acs namespace</param>
498+
/// <param name="agentLinks">agent links</param>
499+
public BackupVaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string agentLinks)
500+
: this(subscriptionId, resourceName, managementCert, acsNamespace)
501+
{
502+
AgentLinks = agentLinks;
503+
}
504+
505+
#endregion
506+
}
507+
459508
/// <summary>
460509
/// Class to define ACS name space
461510
/// </summary>
@@ -472,9 +521,9 @@ public class AcsNamespace
472521
/// <param name="acsDetails">authenticating service Details name</param>
473522
public AcsNamespace(UploadCertificateResponse acsDetails)
474523
{
475-
this.HostName = acsDetails.Properties.GlobalAcsHostName;
476-
this.Namespace = acsDetails.Properties.GlobalAcsNamespace;
477-
this.ResourceProviderRealm = acsDetails.Properties.GlobalAcsRPRealm;
524+
this.HostName = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsHostName;
525+
this.Namespace = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsNamespace;
526+
this.ResourceProviderRealm = (acsDetails.Properties as ACSCertificateProperties).GlobalAcsRPRealm;
478527
}
479528

480529
/// <summary>

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public class Constants
2626
/// </summary>
2727
public const string VaultType = "HyperVRecoveryManagerVault";
2828

29+
/// <summary>
30+
/// Backup vault type
31+
/// </summary>
32+
public const string BackupVaultType = "Vaults";
33+
2934
/// <summary>
3035
/// Vault Credential version.
3136
/// </summary>
@@ -135,7 +140,7 @@ public ARSVault(VaultCreateResponse vault)
135140
public class ARSVaultProperties
136141
{
137142
#region Properties
138-
143+
139144
/// <summary>
140145
/// Gets or sets Provisioning State.
141146
/// </summary>
@@ -144,6 +149,18 @@ public class ARSVaultProperties
144149
#endregion
145150
}
146151

152+
public class ASRVaultBackupProperties
153+
{
154+
#region Properties
155+
156+
/// <summary>
157+
/// Gets or sets BackupStorageRedundancy type.
158+
/// </summary>
159+
public string BackupStorageRedundancy { get; set; }
160+
161+
#endregion
162+
}
163+
147164
/// <summary>
148165
/// Class to define the output of the vault settings file generation.
149166
/// </summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ internal static class ARSParameterSets
2020
/// When excution has to be done for site
2121
/// </summary>
2222
internal const string ForSite = "ForSite";
23+
24+
internal const string ForBackupVaultType = "ForBackupVaultType";
2325
}
2426
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Properties/Resources.Designer.cs

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Properties/Resources.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,24 @@ Please provide a storage account with the same location as that of the vault.</v
277277
<data name="SiteNotFound" xml:space="preserve">
278278
<value>Site {0} is not associated with the Vault {1}</value>
279279
</data>
280+
<data name="BackupVaultSerialized" xml:space="preserve">
281+
<value>RecoveryService - Backup Vault - Successfully serialized the file content</value>
282+
</data>
283+
<data name="ExecutingGetVaultCredCmdlet" xml:space="preserve">
284+
<value>Executing cmdlet with SubscriptionId = {0}, ResourceGroupName = {1}, ResourceName = {2}, TargetLocation = {3}</value>
285+
</data>
286+
<data name="SavingVaultCred" xml:space="preserve">
287+
<value>Saving Vault Credentials to file : {0}</value>
288+
</data>
289+
<data name="UploadedCertToIdmgmt" xml:space="preserve">
290+
<value>RecoveryService - Successfully uploaded the certificate</value>
291+
</data>
292+
<data name="UploadingCertToIdmgmt" xml:space="preserve">
293+
<value>RecoveryService - Going to upload the certificate</value>
294+
</data>
295+
<data name="VaultCredPathException" xml:space="preserve">
296+
<value>The target location provided is not a directory. Please provide a directory.</value>
297+
</data>
280298
<data name="ResourceGroupNameNullOrEmpty" xml:space="preserve">
281299
<value>Resource Group name mentioned is either null or empty</value>
282300
</data>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Utilities/CertUtils.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,16 @@ private static CngKey Create2048RsaKey()
221221

222222
return CngKey.Create(CngAlgorithm2.Rsa, null, keyCreationParameters);
223223
}
224+
225+
/// <summary>
226+
/// Returns serialized certificate - Base64 encoded based on the content type
227+
/// </summary>
228+
/// <param name="cert">The certificate provided</param>
229+
/// <param name="contentType">Cert content type</param>
230+
/// <returns>The serialized cert value in string</returns>
231+
public static string SerializeCert(X509Certificate2 cert, X509ContentType contentType)
232+
{
233+
return Convert.ToBase64String(cert.Export(contentType));
234+
}
224235
}
225236
}

0 commit comments

Comments
 (0)