Skip to content

Commit bc8e25d

Browse files
committed
Merge pull request #1 from AsrArmOneSdk/avneeshb1
dynamic provider namespace
2 parents 50b95fc + ff351ba commit bc8e25d

File tree

8 files changed

+79
-14
lines changed

8 files changed

+79
-14
lines changed

src/ResourceManager/SiteRecovery/Commands.SiteRecovery.Test/Commands.SiteRecovery.Test.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.27-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
3838
</Reference>
3939
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.0.1.0-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
41-
<Private>True</Private>
40+
<SpecificVersion>False</SpecificVersion>
41+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.0.1.5-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
4242
</Reference>
4343
<Reference Include="Microsoft.Azure.ResourceManager">
4444
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -161,6 +161,9 @@
161161
<Name>Commands.SiteRecovery</Name>
162162
</ProjectReference>
163163
</ItemGroup>
164+
<ItemGroup>
165+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
166+
</ItemGroup>
164167
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
165168
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
166169
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

src/ResourceManager/SiteRecovery/Commands.SiteRecovery.Test/ScenarioTests/SiteRecoveryTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ private SiteRecoveryManagementClient GetSiteRecoveryManagementClient()
122122
}
123123

124124
return new SiteRecoveryManagementClient(
125-
asrVaultCreds.ResourceGroupName,
126125
asrVaultCreds.ResourceName,
127126
asrVaultCreds.ResourceGroupName,
127+
"Microsof.SiteRecovery",
128128
RecoveryServicesMgmtClient.Credentials,
129129
RecoveryServicesMgmtClient.BaseUri).WithHandler(HttpMockServer.CreateInstance());
130130
}

src/ResourceManager/SiteRecovery/Commands.SiteRecovery.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.27-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Resources" version="2.18.1-preview" targetFramework="net45" />
8-
<package id="Microsoft.Azure.Management.SiteRecovery" version="0.1.0-preview" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Management.SiteRecovery" version="0.1.5-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1111
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Commands.SiteRecovery.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
<SpecificVersion>False</SpecificVersion>
4949
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
5050
</Reference>
51-
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
52-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.0.1.0-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
53-
<Private>True</Private>
51+
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
52+
<SpecificVersion>False</SpecificVersion>
53+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.0.1.5-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
5454
</Reference>
5555
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
5656
<SpecificVersion>False</SpecificVersion>
@@ -64,6 +64,9 @@
6464
<SpecificVersion>False</SpecificVersion>
6565
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
6666
</Reference>
67+
<Reference Include="Microsoft.WindowsAzure.Management.Scheduler">
68+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.6.2.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll</HintPath>
69+
</Reference>
6770
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
6871
<SpecificVersion>False</SpecificVersion>
6972
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -72,6 +75,7 @@
7275
<HintPath>Utilities\Security.Cryptography.dll</HintPath>
7376
</Reference>
7477
<Reference Include="System" />
78+
<Reference Include="System.Configuration" />
7579
<Reference Include="System.Core" />
7680
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7781
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Common/PSRecoveryServicesClient.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
using Microsoft.WindowsAzure.Commands.Common;
3434
using Microsoft.WindowsAzure.Commands.Utilities.Common;
3535
using Properties = Microsoft.Azure.Commands.SiteRecovery.Properties;
36+
using Microsoft.WindowsAzure.Management.Scheduler;
37+
using System.Configuration;
38+
using System.Collections.Specialized;
3639

3740
namespace Microsoft.Azure.Commands.SiteRecovery
3841
{
@@ -82,6 +85,11 @@ public RecoveryServicesManagementClient GetRecoveryServicesClient
8285
/// </summary>
8386
private RecoveryServicesManagementClient recoveryServicesClient;
8487

88+
/// <summary>
89+
/// Recovery Services client.
90+
/// </summary>
91+
private CloudServiceManagementClient cloudServicesClient;
92+
8593
/// <summary>
8694
/// Initializes a new instance of the <see cref="PSRecoveryServicesClient" /> class with
8795
/// required current subscription.
@@ -90,8 +98,30 @@ public RecoveryServicesManagementClient GetRecoveryServicesClient
9098
public PSRecoveryServicesClient(AzureProfile azureProfile, AzureSubscription azureSubscription)
9199
{
92100
this.Profile = azureProfile;
101+
102+
this.cloudServicesClient = AzureSession.ClientFactory.CreateClient<CloudServiceManagementClient>(azureProfile, azureSubscription, AzureEnvironment.Endpoint.ResourceManager);
103+
104+
System.Configuration.Configuration siteRecoveryConfig = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location);
105+
106+
System.Configuration.AppSettingsSection appSettings = (System.Configuration.AppSettingsSection)siteRecoveryConfig.GetSection("appSettings");
107+
108+
string resourceNamespace = "";
109+
if(appSettings.Settings.Count == 0)
110+
{
111+
resourceNamespace = "Microsoft.SiteRecovery"; // ProviderNameSpace for Production is taken as default
112+
}
113+
else
114+
{
115+
resourceNamespace = appSettings.Settings["ProviderNamespace"].Value;
116+
}
117+
118+
Utilities.UpdateVaultSettingsProviderNamespace(resourceNamespace);
119+
93120
this.recoveryServicesClient =
94-
AzureSession.ClientFactory.CreateClient<RecoveryServicesManagementClient>(azureProfile, azureSubscription, AzureEnvironment.Endpoint.ResourceManager);
121+
AzureSession.ClientFactory.CreateCustomClient<RecoveryServicesManagementClient>(
122+
asrVaultCreds.ResourceNamespace,
123+
cloudServicesClient.Credentials,
124+
Profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager));
95125
}
96126

97127
/// <summary>
@@ -238,10 +268,10 @@ private SiteRecoveryManagementClient GetSiteRecoveryClient()
238268

239269
SiteRecoveryManagementClient siteRecoveryClient =
240270
AzureSession.ClientFactory.CreateCustomClient<SiteRecoveryManagementClient>(
241-
asrVaultCreds.ResourceGroupName,
242271
asrVaultCreds.ResourceName,
243272
asrVaultCreds.ResourceGroupName,
244-
recoveryServicesClient.Credentials,
273+
asrVaultCreds.ResourceNamespace,
274+
cloudServicesClient.Credentials,
245275
Profile.Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager));
246276

247277
if (null == siteRecoveryClient)

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,14 @@ public VaultCreds()
348348
/// <param name="resourceName">resource name</param>
349349
/// <param name="managementCert">management cert</param>
350350
/// <param name="acsNamespace">authenticating service namespace</param>
351-
public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace)
351+
public VaultCreds(string subscriptionId, string resourceName, string managementCert, AcsNamespace acsNamespace, string resourceNamespace)
352352
{
353353
this.SubscriptionId = subscriptionId;
354354
this.ResourceType = Constants.ASRVaultType;
355355
this.ResourceName = resourceName;
356356
this.ManagementCert = managementCert;
357357
this.AcsNamespace = acsNamespace;
358+
this.ResourceNamespace = resourceNamespace;
358359
}
359360

360361
#endregion
@@ -389,6 +390,13 @@ public VaultCreds(string subscriptionId, string resourceName, string managementC
389390
/// </summary>
390391
[DataMember(Order = 4)]
391392
public AcsNamespace AcsNamespace { get; set; }
393+
394+
/// <summary>
395+
/// Gets or sets the key name for HostName entry
396+
/// </summary>
397+
[DataMember(Order = 5)]
398+
public string ResourceNamespace { get; set; }
399+
392400
#endregion
393401
}
394402

@@ -427,8 +435,9 @@ public ASRVaultCreds(
427435
string managementCert,
428436
AcsNamespace acsNamespace,
429437
string channelIntegrityKey,
430-
string cloudServiceName)
431-
: base(subscriptionId, resourceName, managementCert, acsNamespace)
438+
string cloudServiceName,
439+
string resourceNamespace = "Microsoft.SiteRecovery")
440+
: base(subscriptionId, resourceName, managementCert, acsNamespace, resourceNamespace)
432441
{
433442
this.ChannelIntegrityKey = channelIntegrityKey;
434443
this.ResourceGroupName = cloudServiceName;

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Utilities/Utilities.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,24 @@ public static void UpdateVaultSettings(ASRVaultCreds asrVaultCreds)
113113
asrVaultCreds.ResourceGroupName;
114114
PSRecoveryServicesClient.asrVaultCreds.ChannelIntegrityKey =
115115
asrVaultCreds.ChannelIntegrityKey;
116+
if (asrVaultCreds.ResourceNamespace != null)
117+
{
118+
PSRecoveryServicesClient.asrVaultCreds.ResourceNamespace =
119+
asrVaultCreds.ResourceNamespace;
120+
}
121+
}
122+
}
123+
124+
/// <summary>
125+
/// Imports Azure Site Recovery Vault settings.
126+
/// </summary>
127+
/// <param name="resourceNamespace">Provider Namespace</param>
128+
public static void UpdateVaultSettingsProviderNamespace(string resourceNamespace)
129+
{
130+
object updateVaultSettingsOneAtATime = new object();
131+
lock (updateVaultSettingsOneAtATime)
132+
{
133+
PSRecoveryServicesClient.asrVaultCreds.ResourceNamespace = resourceNamespace;
116134
}
117135
}
118136

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.27-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Management.SiteRecovery" version="0.1.0-preview" targetFramework="net45" />
7+
<package id="Microsoft.Azure.Management.SiteRecovery" version="0.1.5-preview" targetFramework="net45" />
88
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
99
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1010
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
1111
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
12+
<package id="Microsoft.WindowsAzure.Management.Scheduler" version="6.2.0" targetFramework="net45" />
1213
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
1314
</packages>

0 commit comments

Comments
 (0)