Skip to content

Commit f7548b2

Browse files
committed
Merge branch 'dev' into neha-dev
2 parents ecea8a1 + e7da461 commit f7548b2

17 files changed

+263
-57
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/Commands.RecoveryServices.Test.csproj

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\..\packages\xunit.core.2.0.0-beta4-build2738\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props" Condition="Exists('..\..\..\packages\xunit.core.2.0.0-beta4-build2738\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" />
3+
<Import Project="..\..\..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props" Condition="Exists('..\..\..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" />
4+
<Import Project="..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props')" />
45
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
56
<PropertyGroup>
67
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -67,6 +68,10 @@
6768
<Reference Include="Microsoft.WindowsAzure.Common.NetFramework">
6869
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Common.1.4.0\lib\net45\Microsoft.WindowsAzure.Common.NetFramework.dll</HintPath>
6970
</Reference>
71+
<Reference Include="Microsoft.WindowsAzure.Management.SiteRecovery, Version=0.9.0.0, Culture=neutral, PublicKeyToken=c66ce9294aae1300, processorArchitecture=MSIL">
72+
<SpecificVersion>False</SpecificVersion>
73+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.0.2.2-preview\lib\net40\Microsoft.WindowsAzure.Management.SiteRecovery.dll</HintPath>
74+
</Reference>
7075
<Reference Include="Microsoft.WindowsAzure.Testing, Version=1.0.5417.13285, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7176
<SpecificVersion>False</SpecificVersion>
7277
<HintPath>..\..\..\packages\Hydra.SpecTestSupport.1.0.5417.13285-prerelease\lib\net45\Microsoft.WindowsAzure.Testing.dll</HintPath>
@@ -97,14 +102,14 @@
97102
<Reference Include="Microsoft.CSharp" />
98103
<Reference Include="System.Data" />
99104
<Reference Include="System.Xml" />
100-
<Reference Include="xunit.abstractions">
101-
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0-beta4-build2738\lib\net35\xunit.abstractions.dll</HintPath>
105+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
106+
<HintPath>..\..\..\packages\xunit.abstractions.2.0.0-beta5-build2785\lib\net35\xunit.abstractions.dll</HintPath>
102107
</Reference>
103108
<Reference Include="xunit.assert">
104-
<HintPath>..\..\..\packages\xunit.assert.2.0.0-beta4-build2738\lib\portable-net45+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
109+
<HintPath>..\..\..\packages\xunit.assert.2.0.0-beta5-build2785\lib\portable-net45+aspnetcore50+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
105110
</Reference>
106111
<Reference Include="xunit.core">
107-
<HintPath>..\..\..\packages\xunit.core.2.0.0-beta4-build2738\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
112+
<HintPath>..\..\..\packages\xunit.core.2.0.0-beta5-build2785\lib\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
108113
</Reference>
109114
</ItemGroup>
110115
<ItemGroup>
@@ -151,7 +156,8 @@
151156
<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>
152157
</PropertyGroup>
153158
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
154-
<Error Condition="!Exists('..\..\..\packages\xunit.core.2.0.0-beta4-build2738\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.core.2.0.0-beta4-build2738\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props'))" />
159+
<Error Condition="!Exists('..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props'))" />
160+
<Error Condition="!Exists('..\..\..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props'))" />
155161
</Target>
156162
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
157163
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ public void RecoveryServicesNetworkMappingTest()
5454
this.RunPowerShellTest("Test-NetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
5555
}
5656

57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void RecoveryServicesNetworkUnMappingTest()
60+
{
61+
this.RunPowerShellTest("Test-NetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
62+
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void RecoveryServicesAzureNetworkMappingTest()
67+
{
68+
this.RunPowerShellTest("Test-AzureNetworkMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
69+
}
70+
71+
[Fact]
72+
[Trait(Category.AcceptanceType, Category.CheckIn)]
73+
public void RecoveryServicesAzureNetworkUnMappingTest()
74+
{
75+
this.RunPowerShellTest("Test-AzureNetworkUnMapping -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
76+
}
77+
5778
[Fact]
5879
[Trait(Category.AcceptanceType, Category.CheckIn)]
5980
public void RecoveryServicesFailbackTest()

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

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,70 @@ function Test-NetworkMapping
253253
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
254254
}
255255

256+
<#
257+
.SYNOPSIS
258+
Recovery Services Azure Network mapping tests and validation
259+
#>
260+
function Test-AzureNetworkMapping
261+
{
262+
param([string] $vaultSettingsFilePath)
263+
264+
# Import Azure Site Recovery Vault Settings
265+
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
266+
267+
# Enumerate Servers
268+
$servers = Get-AzureSiteRecoveryServer
269+
Assert-True { $servers.Count -gt 0 }
270+
Assert-NotNull($servers)
271+
foreach($server in $servers)
272+
{
273+
Assert-NotNull($server.Name)
274+
Assert-NotNull($server.ID)
275+
}
276+
277+
# Enumerate Networks
278+
$networks = Get-AzureSiteRecoveryNetwork -Server $servers[0]
279+
Assert-NotNull($networks)
280+
Assert-True { $networks.Count -gt 0 }
281+
foreach($network in $networks)
282+
{
283+
Assert-NotNull($network.Name)
284+
Assert-NotNull($network.ID)
285+
}
286+
287+
<#
288+
# Enumerate Azure VM Networks
289+
$azureVmNetworks = Get-AzureVNetSite
290+
Assert-NotNull($azureVmNetworks)
291+
Assert-True { $azureVmNetworks.Count -gt 0 }
292+
#>
293+
294+
# Enumerate AzureNetworkMappings
295+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
296+
Assert-True { $networkMappings.Count -eq 0 }
297+
298+
# Create AzureNetworkMapping
299+
# $subscription = Get-AzureSubscription -Current
300+
301+
# TODO (sriramvu): There are few dependency issues on using Get-AzureVNetSite to get list of Azure VM Networks, will update the test.
302+
# Should setup NetworkManagementClient along with our two mgmt clients in RecoveryServicesTestsBase.cs
303+
# $job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId $subscription.SubscriptionId -AzureVMNetworkId $azureVmNetworks[0].Id
304+
# $job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId 62633f66-ce59-4114-b65d-a50beb5bd8d8 -AzureVMNetworkId "1d0ecfad-ac09-4222-b46f-2ab74839fe7e" # OneBox details
305+
$job = New-AzureSiteRecoveryNetworkMapping -PrimaryNetwork $networks[0] -AzureSubscriptionId a5aa5997-33e5-46cc-8ab8-8bd89b76b7ba -AzureVMNetworkId ecb3a462-664f-4f57-873e-d09b5925e1a1 # POD details
306+
WaitForJobCompletion -JobId $job.ID
307+
308+
# Enumerate NetworkMappings
309+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
310+
Assert-NotNull($networkMappings)
311+
Assert-True { $networkMappings.Count -eq 1 }
312+
Assert-NotNull($networkMappings[0].PrimaryServerId)
313+
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
314+
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
315+
Assert-NotNull($networkMappings[0].RecoveryServerId)
316+
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
317+
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
318+
}
319+
256320
<#
257321
.SYNOPSIS
258322
Recovery Services Network unmapping tests and validation
@@ -285,7 +349,7 @@ function Test-NetworkUnMapping
285349
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
286350
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
287351

288-
# Remove StorageMapping
352+
# Remove NetworkMapping
289353
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
290354
WaitForJobCompletion -JobId $job.ID
291355

@@ -294,6 +358,47 @@ function Test-NetworkUnMapping
294358
Assert-True { $networkMappings.Count -eq 0 }
295359
}
296360

361+
<#
362+
.SYNOPSIS
363+
Recovery Services Azure Network unmapping tests and validation
364+
#>
365+
function Test-AzureNetworkUnMapping
366+
{
367+
param([string] $vaultSettingsFilePath)
368+
369+
# Import Azure Site Recovery Vault Settings
370+
Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
371+
372+
# Enumerate Servers
373+
$servers = Get-AzureSiteRecoveryServer
374+
Assert-True { $servers.Count -gt 0 }
375+
Assert-NotNull($servers)
376+
foreach($server in $servers)
377+
{
378+
Assert-NotNull($server.Name)
379+
Assert-NotNull($server.ID)
380+
}
381+
382+
# Enumerate Azure NetworkMappings
383+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
384+
Assert-NotNull($networkMappings)
385+
Assert-True { $networkMappings.Count -eq 1 }
386+
Assert-NotNull($networkMappings[0].PrimaryServerId)
387+
Assert-NotNull($networkMappings[0].PrimaryNetworkId)
388+
Assert-NotNull($networkMappings[0].PrimaryNetworkName)
389+
Assert-NotNull($networkMappings[0].RecoveryServerId)
390+
Assert-NotNull($networkMappings[0].RecoveryNetworkId)
391+
Assert-NotNull($networkMappings[0].RecoveryNetworkName)
392+
393+
# Remove Azure NetworkMapping
394+
$job = Remove-AzureSiteRecoveryNetworkMapping -NetworkMapping $networkMappings[0]
395+
WaitForJobCompletion -JobId $job.ID
396+
397+
# Enumerate Azure NetworkMappings
398+
$networkMappings = Get-AzureSiteRecoveryNetworkMapping -PrimaryServer $servers[0] -Azure
399+
Assert-True { $networkMappings.Count -eq 0 }
400+
}
401+
297402
<#
298403
.SYNOPSIS
299404
Recovery Services Failback Tests

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices.Test/packages.config

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<packages>
33
<package id="Hydra.HttpRecorder" version="1.0.5417.13285-prerelease" targetFramework="net45" />
44
<package id="Hydra.SpecTestSupport" version="1.0.5417.13285-prerelease" targetFramework="net45" />
5-
<package id="Microsoft.Azure.Management.RecoveryServices" version="0.1.0-preview" targetFramework="net45" />
5+
<package id="Microsoft.Azure.Management.RecoveryServices" version="0.2.2-preview" targetFramework="net45" />
66
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
77
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
88
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
@@ -11,8 +11,9 @@
1111
<package id="Microsoft.WindowsAzure.Common" version="1.4.0" targetFramework="net45" />
1212
<package id="Microsoft.WindowsAzure.Common.Dependencies" version="1.1.0" targetFramework="net45" />
1313
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
14-
<package id="xunit" version="2.0.0-beta4-build2738" targetFramework="net45" />
15-
<package id="xunit.abstractions" version="2.0.0-beta4-build2738" targetFramework="net45" />
16-
<package id="xunit.assert" version="2.0.0-beta4-build2738" targetFramework="net45" />
17-
<package id="xunit.core" version="2.0.0-beta4-build2738" targetFramework="net45" />
14+
<package id="xunit" version="2.0.0-beta5-build2785" targetFramework="net45" />
15+
<package id="xunit.abstractions" version="2.0.0-beta5-build2785" targetFramework="net45" />
16+
<package id="xunit.assert" version="2.0.0-beta5-build2785" targetFramework="net45" />
17+
<package id="xunit.core" version="2.0.0-beta5-build2785" targetFramework="net45" />
18+
<package id="xunit.runner.visualstudio" version="0.99.9-build1021" targetFramework="net45" />
1819
</packages>

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<Compile Include="Service\GetAzureSiteRecoveryNetwork.cs" />
160160
<Compile Include="Service\CreateAzureSiteRecoveryRecoveryPlan.cs" />
161161
<Compile Include="Service\GetAzureSiteRecoveryRecoveryPlanFile.cs" />
162-
<Compile Include="Service\GetAzureSiteRecoveryVaultCredential.cs" />
162+
<Compile Include="Service\GetAzureSiteRecoveryVaultSettingsFile.cs" />
163163
<Compile Include="Service\RemoveAzureSiteRecoveryRecoveryPlan.cs" />
164164
<Compile Include="Service\GetAzureSiteRecoveryProtectionEntity.cs" />
165165
<Compile Include="Service\RestartAzureSiteRecoveryJob.cs" />

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesNetworkMappingClient.cs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ namespace Microsoft.Azure.Commands.RecoveryServices
3232
public enum NetworkTargetType
3333
{
3434
/// <summary>
35-
/// Target type of the network is Server.
35+
/// SCVMM VM Network.
3636
/// </summary>
37-
Server = 0,
37+
SCVMM = 0,
3838

3939
/// <summary>
40-
/// Target type of the network is Azure.
40+
/// Azure VM Network.
4141
/// </summary>
4242
Azure,
4343
}
@@ -200,13 +200,13 @@ public class CreateAzureNetworkMappingInput
200200
/// Gets or sets Azure VM Network Id.
201201
/// </summary>
202202
[DataMember(Order = 3)]
203-
public string AzureVMNetworkId { get; set; }
203+
public string RecoveryNetworkId { get; set; }
204204

205205
/// <summary>
206206
/// Gets or sets Azure VM Network name.
207207
/// </summary>
208208
[DataMember(Order = 4)]
209-
public string AzureVMNetworkName { get; set; }
209+
public string RecoveryNetworkName { get; set; }
210210
}
211211

212212
/// <summary>
@@ -255,7 +255,7 @@ public JobResponse NewAzureSiteRecoveryNetworkMapping(
255255
createNetworkMappingInput.RecoveryNetworkId = recoveryNetworkId;
256256

257257
NetworkMappingInput networkMappingInput = new NetworkMappingInput();
258-
networkMappingInput.NetworkTargetType = NetworkTargetType.Server.ToString();
258+
networkMappingInput.NetworkTargetType = NetworkTargetType.SCVMM.ToString();
259259
networkMappingInput.CreateNetworkMappingInput =
260260
DataContractUtils.Serialize<CreateNetworkMappingInput>(createNetworkMappingInput);
261261
return this.GetSiteRecoveryClient()
@@ -281,8 +281,8 @@ public JobResponse NewAzureSiteRecoveryAzureNetworkMapping(
281281
new CreateAzureNetworkMappingInput();
282282
createAzureNetworkMappingInput.PrimaryServerId = primaryServerId;
283283
createAzureNetworkMappingInput.PrimaryNetworkId = primaryNetworkId;
284-
createAzureNetworkMappingInput.AzureVMNetworkName = recoveryNetworkName;
285-
createAzureNetworkMappingInput.AzureVMNetworkId = recoveryNetworkId;
284+
createAzureNetworkMappingInput.RecoveryNetworkName = recoveryNetworkName;
285+
createAzureNetworkMappingInput.RecoveryNetworkId = recoveryNetworkId;
286286

287287
NetworkMappingInput networkMappingInput = new NetworkMappingInput();
288288
networkMappingInput.NetworkTargetType = NetworkTargetType.Azure.ToString();
@@ -296,16 +296,38 @@ public JobResponse NewAzureSiteRecoveryAzureNetworkMapping(
296296
/// <summary>
297297
/// Validates whether the Azure VM Network is associated with the subscription or not.
298298
/// </summary>
299-
/// <param name="subscriptionId">Subscription Id</param>
300-
/// <param name="azureNetworkId">Azure Network Id</param>
301-
public void ValidateVMNetworkSubscriptionAssociation(string subscriptionId, string azureNetworkId)
299+
/// <param name="azureSubscriptionId">Subscription Id</param>
300+
/// <param name="azureVMNetworkId">Azure VM Network Id</param>
301+
/// <param name="azureVMNetworkName">Azure VM Network name</param>
302+
public void ValidateVMNetworkSubscriptionAssociation(
303+
string azureSubscriptionId,
304+
string azureVMNetworkId,
305+
out string azureVMNetworkName)
302306
{
303-
/*
304-
NetworkManagementClient networkClient =
305-
AzureSession.ClientFactory.CreateClient<NetworkManagementClient>(AzureSession.CurrentContext.Subscription, AzureEnvironment.Endpoint.ServiceManagement);
306-
var response = this.networkClient.Networks.List();
307-
var sites = response.VirtualNetworkSites;
308-
*/
307+
bool associatedVMNetwork = false;
308+
azureVMNetworkName = string.Empty;
309+
310+
AzureNetworkListResponse azureNetworkListResponse =
311+
this.GetSiteRecoveryClient().Networks.ListAzureNetworks(azureSubscriptionId);
312+
313+
foreach (AzureNetworkListResponse.VirtualNetworkSite site in azureNetworkListResponse.VirtualNetworkSites)
314+
{
315+
if (azureVMNetworkId.Equals(site.Id))
316+
{
317+
associatedVMNetwork = true;
318+
azureVMNetworkName = site.Name;
319+
break;
320+
}
321+
}
322+
323+
if (!associatedVMNetwork)
324+
{
325+
throw new InvalidOperationException(
326+
string.Format(
327+
Properties.Resources.AzureVMNetworkIsNotAssociatedWithTheSubscription,
328+
azureVMNetworkId,
329+
azureSubscriptionId));
330+
}
309331
}
310332

311333
/// <summary>

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesVaultExtendedInfoClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private async Task<string> GetChannelIntegrityKey()
157157
{
158158
// In case this condition is true that means the credential was first generated in portal
159159
// and hence can not be fetched here.
160-
throw new CloudException(Resources.VaultCredentialGenerationUnSupported);
160+
throw new CloudException(Resources.VaultSettingsGenerationUnSupported);
161161
}
162162
}
163163

0 commit comments

Comments
 (0)