Skip to content

Commit 7243c44

Browse files
committed
Merge pull request #5 from DeepakRajendranMsft/NrpCrpCmdlet
fix test build and lb bugs
2 parents a295e72 + 03c4fcb commit 7243c44

13 files changed

+155
-77
lines changed

AzurePowershell.Test.targets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<CommonTestDebug>.\src\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll</CommonTestDebug>
1010
<SqlTestDebug>.\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll</SqlTestDebug>
1111
<ComputeTestDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll</ComputeTestDebug>
12-
<NetworkResourceProviderTestDebug>.\src\ResourceManager\Network\Commands.NetworkResourceProvider.Test\bin\Debug\Microsoft.Azure.Commands.NetworkResourceProvider.Test.dll</NetworkResourceProviderTestDebug>
12+
<NetworkTestDebug>.\src\ResourceManager\Network\Commands.Network.Test\bin\Debug\Microsoft.Azure.Commands.Network.Test.dll</NetworkTestDebug>
1313
<AzureRTTestSettings>.\src\AzureRT.testsettings</AzureRTTestSettings>
1414
<AzureRTTestContainer>.\src\ServiceManagement\Compute\Commands.ServiceManagement.Test\bin\Debug\Microsoft.WindowsAzure.Commands.ServiceManagement.Test.dll</AzureRTTestContainer>
1515
<StorageScenarioTestDebug>src\ServiceManagement\Storage\Commands.Storage.ScenarioTest\bin\Debug\CLITest.dll</StorageScenarioTestDebug>
@@ -44,7 +44,7 @@
4444
<XUnitTests Include=".\src\ServiceManagement\StorSimple\Commands.StorSimple.Test\bin\Debug\Microsoft.WindowsAzure.Commands.StorSimple.Test.dll"/>
4545
<XUnitTests Include=".\src\ResourceManager\Resources\Commands.Resources.Test\bin\Debug\Microsoft.Azure.Commands.Resources.Test.dll"/>
4646
<XUnitTests Include=".\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll"/>
47-
<XUnitTests Include=".\src\ResourceManager\Network\Commands.NetworkResourceProvider.Test\bin\Debug\Microsoft.Azure.Commands.NetworkResourceProvider.Test.dll"/>
47+
<XUnitTests Include=".\src\ResourceManager\Network\Commands.Network.Test\bin\Debug\Microsoft.Azure.Commands.Network.Test.dll"/>
4848
<XUnitTests Include=".\src\ResourceManager\DataFactories\Commands.DataFactories.Test\bin\Debug\Microsoft.Azure.Commands.DataFactories.Test.dll"/>
4949
<XUnitTests Include=".\src\ResourceManager\StreamAnalytics\Commands.StreamAnalytics.Test\bin\Debug\Microsoft.Azure.Commands.StreamAnalytics.Test.dll"/>
5050
<XUnitTests Include=".\src\ResourceManager\Batch\Commands.Batch.Test\bin\Debug\Microsoft.Azure.Commands.Batch.Test.dll"/>
@@ -114,8 +114,8 @@
114114
IncludeTraits="$(XUnitIncludedTrait)" MaxParallelThreads="0" ParallelizeAssemblies="false" ParallelizeTestCollections="false" />
115115
</Target>
116116

117-
<Target Name="NetworkResourceProviderTestDebug">
118-
<Xunit.Runner.MSBuild.xunit Assemblies="$(NetworkResourceProviderTestDebug)" Html="$(TestOutputDirectory)\NetworkResourceProviderTestDebug.xunit.dll.html" Verbose="false"
117+
<Target Name="NetworkTestDebug">
118+
<Xunit.Runner.MSBuild.xunit Assemblies="$(NetworkTestDebug)" Html="$(TestOutputDirectory)\NetworkTestDebug.xunit.dll.html" Verbose="false"
119119
IncludeTraits="$(XUnitIncludedTrait)" MaxParallelThreads="0" ParallelizeAssemblies="false" ParallelizeTestCollections="false" />
120120
</Target>
121121

src/ResourceManager/Network/Commands.Network/LoadBalancer/BackendAddressPool/AddAzureLoadBalancerBackendAddressPoolConfigCommand.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ public override void ExecuteCmdlet()
4848

4949
var backendAddressPool = new PSBackendAddressPool();
5050
backendAddressPool.Name = this.Name;
51-
backendAddressPool.BackendIpConfigurations = new List<PSResourceId>();
52-
53-
foreach (var backendIpConfigurationId in this.BackendIpConfigurationId)
51+
52+
if (this.BackendIpConfigurationId != null)
5453
{
55-
var resourceId = new PSResourceId();
56-
resourceId.Id = backendIpConfigurationId;
57-
backendAddressPool.BackendIpConfigurations.Add(resourceId);
54+
backendAddressPool.BackendIpConfigurations = new List<PSResourceId>();
55+
foreach (var backendIpConfigurationId in this.BackendIpConfigurationId)
56+
{
57+
var resourceId = new PSResourceId();
58+
resourceId.Id = backendIpConfigurationId;
59+
backendAddressPool.BackendIpConfigurations.Add(resourceId);
60+
}
5861
}
5962

6063
backendAddressPool.Id =

src/ResourceManager/Network/Commands.Network/LoadBalancer/BackendAddressPool/NewAzureLoadBalancerBackendAddressPoolConfigCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public override void ExecuteCmdlet()
3333

3434
var backendAddressPool = new PSBackendAddressPool();
3535
backendAddressPool.Name = this.Name;
36-
backendAddressPool.BackendIpConfigurations = new List<PSResourceId>();
37-
36+
3837
if (this.BackendIpConfigurationId != null)
3938
{
39+
backendAddressPool.BackendIpConfigurations = new List<PSResourceId>();
4040
foreach (var backendIpConfigurationId in this.BackendIpConfigurationId)
4141
{
4242
var resourceId = new PSResourceId();

src/ResourceManager/Network/Commands.Network/LoadBalancer/ChildResourceHelper.cs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,31 @@ public static void NormalizeChildResourcesId(PSLoadBalancer loadBalancer)
6262
{
6363
loadBalancingRule.Id = string.Empty;
6464

65-
foreach (var frontendIpConfiguration in loadBalancingRule.FrontendIPConfigurations)
65+
if (loadBalancingRule.FrontendIPConfigurations != null)
6666
{
67-
frontendIpConfiguration.Id = NormalizeLoadBalancerChildResourceIds(frontendIpConfiguration.Id,
68-
loadBalancer.ResourceGroupName, loadBalancer.Name);
67+
foreach (var frontendIpConfiguration in loadBalancingRule.FrontendIPConfigurations)
68+
{
69+
frontendIpConfiguration.Id = NormalizeLoadBalancerChildResourceIds(frontendIpConfiguration.Id,
70+
loadBalancer.ResourceGroupName, loadBalancer.Name);
71+
}
6972
}
7073

71-
loadBalancingRule.BackendAddressPool.Id =
72-
NormalizeLoadBalancerChildResourceIds(loadBalancingRule.BackendAddressPool.Id,
73-
loadBalancer.ResourceGroupName, loadBalancer.Name);
74+
if (loadBalancingRule.BackendAddressPool != null)
75+
{
76+
loadBalancingRule.BackendAddressPool.Id =
77+
NormalizeLoadBalancerChildResourceIds(
78+
loadBalancingRule.BackendAddressPool.Id,
79+
loadBalancer.ResourceGroupName,
80+
loadBalancer.Name);
81+
}
7482

75-
loadBalancingRule.Probe.Id =
76-
NormalizeLoadBalancerChildResourceIds(loadBalancingRule.Probe.Id,
77-
loadBalancer.ResourceGroupName, loadBalancer.Name);
83+
if (loadBalancingRule.Probe != null)
84+
{
85+
loadBalancingRule.Probe.Id = NormalizeLoadBalancerChildResourceIds(
86+
loadBalancingRule.Probe.Id,
87+
loadBalancer.ResourceGroupName,
88+
loadBalancer.Name);
89+
}
7890
}
7991
}
8092

@@ -85,10 +97,16 @@ public static void NormalizeChildResourcesId(PSLoadBalancer loadBalancer)
8597
{
8698
inboundNatRule.Id = string.Empty;
8799

88-
foreach (var frontendIpConfiguration in inboundNatRule.FrontendIPConfigurations)
100+
if (inboundNatRule.FrontendIPConfigurations != null)
89101
{
90-
frontendIpConfiguration.Id = NormalizeLoadBalancerChildResourceIds(frontendIpConfiguration.Id,
91-
loadBalancer.ResourceGroupName, loadBalancer.Name);
102+
foreach (var frontendIpConfiguration in inboundNatRule.FrontendIPConfigurations)
103+
{
104+
frontendIpConfiguration.Id =
105+
NormalizeLoadBalancerChildResourceIds(
106+
frontendIpConfiguration.Id,
107+
loadBalancer.ResourceGroupName,
108+
loadBalancer.Name);
109+
}
92110
}
93111
}
94112
}

src/ResourceManager/Network/Commands.Network/LoadBalancer/InboundNatRule/AddAzureLoadBalancerInboundNatRuleConfigCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ public override void ExecuteCmdlet()
5858
}
5959
inboundNatRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
6060
inboundNatRule.BackendIPConfiguration = new PSResourceId();
61-
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
62-
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
61+
62+
if (!string.IsNullOrEmpty(this.BackendIpConfigurationId))
63+
{
64+
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
65+
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
66+
}
6367

6468
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
6569
{

src/ResourceManager/Network/Commands.Network/LoadBalancer/InboundNatRule/AzureLoadBalancerInboundNatRuleConfigBase.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ public override void ExecuteCmdlet()
8383

8484
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource))
8585
{
86-
this.BackendIpConfigurationId = this.BackendIpConfiguration.Id;
87-
88-
this.FrontendIPConfigurationId = new List<string>();
86+
if (this.BackendIpConfiguration != null)
87+
{
88+
this.BackendIpConfigurationId = this.BackendIpConfiguration.Id;
89+
}
8990

90-
foreach (var frontendIpConfiguration in this.FrontendIpConfiguration)
91+
if (this.FrontendIpConfiguration != null)
9192
{
92-
this.FrontendIPConfigurationId.Add(frontendIpConfiguration.Id);
93+
this.FrontendIPConfigurationId = new List<string>();
94+
95+
foreach (var frontendIpConfiguration in this.FrontendIpConfiguration)
96+
{
97+
this.FrontendIPConfigurationId.Add(frontendIpConfiguration.Id);
98+
}
9399
}
94100
}
95101
}

src/ResourceManager/Network/Commands.Network/LoadBalancer/InboundNatRule/NewAzureLoadBalancerInboundNatRuleConfigCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ public override void ExecuteCmdlet()
4343
}
4444
inboundNatRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
4545
inboundNatRule.BackendIPConfiguration = new PSResourceId();
46-
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
47-
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
46+
47+
if (!string.IsNullOrEmpty(this.BackendIpConfigurationId))
48+
{
49+
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
50+
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
51+
}
4852

4953
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
5054
{

src/ResourceManager/Network/Commands.Network/LoadBalancer/InboundNatRule/SetAzureLoadBalancerInboundNatRuleConfigCommand.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ public override void ExecuteCmdlet()
5757
}
5858
inboundNatRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
5959
inboundNatRule.BackendIPConfiguration = new PSResourceId();
60-
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
61-
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
60+
61+
if (!string.IsNullOrEmpty(this.BackendIpConfigurationId))
62+
{
63+
inboundNatRule.BackendIPConfiguration.Id = this.BackendIpConfigurationId;
64+
inboundNatRule.FrontendIPConfigurations = new List<PSResourceId>();
65+
}
6266

6367
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
6468
{

src/ResourceManager/Network/Commands.Network/LoadBalancer/LoadBalancerRule/AddAzureLoadBalancerRuleConfigCommand.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,29 @@ public override void ExecuteCmdlet()
6464
}
6565

6666
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
67-
loadBalancingRule.BackendAddressPool = new PSResourceId();
68-
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
69-
70-
if (this.ProbeId == null)
67+
68+
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))
7169
{
72-
throw new ArgumentException("Probe missing, please associate a probe with a rule");
70+
loadBalancingRule.BackendAddressPool = new PSResourceId();
71+
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
7372
}
7473

75-
loadBalancingRule.Probe = new PSResourceId();
76-
loadBalancingRule.Probe.Id = this.ProbeId;
77-
78-
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
74+
if (!string.IsNullOrEmpty(this.ProbeId))
75+
{
76+
loadBalancingRule.Probe = new PSResourceId();
77+
loadBalancingRule.Probe.Id = this.ProbeId;
78+
}
7979

80-
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
80+
if (this.FrontendIPConfigurationId != null)
8181
{
82-
var resourceId = new PSResourceId();
83-
resourceId.Id = frontendIPConfigurationId;
84-
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
82+
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
83+
84+
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
85+
{
86+
var resourceId = new PSResourceId();
87+
resourceId.Id = frontendIPConfigurationId;
88+
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
89+
}
8590
}
8691

8792
loadBalancingRule.Id =

src/ResourceManager/Network/Commands.Network/LoadBalancer/LoadBalancerRule/AzureLoadBalancerRuleConfigBase.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,24 @@ public override void ExecuteCmdlet()
103103

104104
if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource))
105105
{
106-
this.BackendAddressPoolId = this.BackendAddressPool.Id;
107-
this.ProbeId = this.Probe.Id;
108-
this.FrontendIPConfigurationId = new List<string>();
106+
if (this.BackendAddressPool != null)
107+
{
108+
this.BackendAddressPoolId = this.BackendAddressPool.Id;
109+
}
110+
111+
if (this.Probe != null)
112+
{
113+
this.ProbeId = this.Probe.Id;
114+
}
109115

110-
foreach (var frontendIpConfiguration in this.FrontendIpConfiguration)
116+
if (this.FrontendIpConfiguration != null)
111117
{
112-
this.FrontendIPConfigurationId.Add(frontendIpConfiguration.Id);
118+
this.FrontendIPConfigurationId = new List<string>();
119+
120+
foreach (var frontendIpConfiguration in this.FrontendIpConfiguration)
121+
{
122+
this.FrontendIPConfigurationId.Add(frontendIpConfiguration.Id);
123+
}
113124
}
114125
}
115126
}

src/ResourceManager/Network/Commands.Network/LoadBalancer/LoadBalancerRule/NewAzureLoadBalancerRuleConfigCommand.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,36 @@ public override void ExecuteCmdlet()
4141
{
4242
loadBalancingRule.IdleTimeoutInMinutes = this.IdleTimeoutInMinutes;
4343
}
44+
4445
if (!string.IsNullOrEmpty(this.LoadDistribution))
4546
{
4647
loadBalancingRule.LoadDistribution = this.LoadDistribution;
4748
}
4849

4950
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
50-
loadBalancingRule.BackendAddressPool = new PSResourceId();
51-
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
52-
loadBalancingRule.Probe = new PSResourceId();
53-
loadBalancingRule.Probe.Id = this.ProbeId;
5451

55-
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
52+
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))
53+
{
54+
loadBalancingRule.BackendAddressPool = new PSResourceId();
55+
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
56+
}
5657

57-
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
58+
if (!string.IsNullOrEmpty(this.ProbeId))
5859
{
59-
var resourceId = new PSResourceId();
60-
resourceId.Id = frontendIPConfigurationId;
61-
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
60+
loadBalancingRule.Probe = new PSResourceId();
61+
loadBalancingRule.Probe.Id = this.ProbeId;
62+
}
63+
64+
if (this.FrontendIPConfigurationId != null)
65+
{
66+
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
67+
68+
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
69+
{
70+
var resourceId = new PSResourceId();
71+
resourceId.Id = frontendIPConfigurationId;
72+
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
73+
}
6274
}
6375

6476
loadBalancingRule.Id =

src/ResourceManager/Network/Commands.Network/LoadBalancer/LoadBalancerRule/SetAzureLoadBalancerRuleConfigCommand.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,29 @@ public override void ExecuteCmdlet()
5959
loadBalancingRule.LoadDistribution = string.IsNullOrEmpty(this.LoadDistribution) ? "Default" : this.LoadDistribution;
6060

6161
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
62-
loadBalancingRule.BackendAddressPool = new PSResourceId();
63-
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
6462

65-
if (this.ProbeId == null)
63+
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))
6664
{
67-
throw new ArgumentException("Probe missing, please associate a probe with a rule");
65+
loadBalancingRule.BackendAddressPool = new PSResourceId();
66+
loadBalancingRule.BackendAddressPool.Id = this.BackendAddressPoolId;
6867
}
6968

70-
loadBalancingRule.Probe = new PSResourceId();
71-
loadBalancingRule.Probe.Id = this.ProbeId;
72-
73-
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
69+
if (!string.IsNullOrEmpty(this.ProbeId))
70+
{
71+
loadBalancingRule.Probe = new PSResourceId();
72+
loadBalancingRule.Probe.Id = this.ProbeId;
73+
}
7474

75-
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
75+
if (this.FrontendIPConfigurationId != null)
7676
{
77-
var resourceId = new PSResourceId();
78-
resourceId.Id = frontendIPConfigurationId;
79-
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
77+
loadBalancingRule.FrontendIPConfigurations = new List<PSResourceId>();
78+
79+
foreach (var frontendIPConfigurationId in this.FrontendIPConfigurationId)
80+
{
81+
var resourceId = new PSResourceId();
82+
resourceId.Id = frontendIPConfigurationId;
83+
loadBalancingRule.FrontendIPConfigurations.Add(resourceId);
84+
}
8085
}
8186

8287
WriteObject(this.LoadBalancer);

src/ResourceManager/Network/Commands.Network/ProviderWideCmdlets/GetAzureCheckDnsAvailabilityCmdlet.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ namespace Microsoft.Azure.Commands.Network
2121
public class GetAzureCheckDnsAvailabilityCmdlet : NetworkBaseCmdlet
2222
{
2323
[Parameter(
24-
Mandatory = false,
25-
HelpMessage = "The Domain Qualified Name name.")]
24+
Mandatory = true,
25+
HelpMessage = "The Domain Qualified Name.")]
2626
[ValidateNotNullOrEmpty]
2727
public string DomainQualifiedName { get; set; }
2828

29+
[Parameter(
30+
Mandatory = true,
31+
HelpMessage = "Location.")]
32+
[ValidateNotNullOrEmpty]
33+
public string Location { get; set; }
34+
2935
public override void ExecuteCmdlet()
3036
{
31-
var result = this.NetworkClient.NetworkResourceProviderClient.CheckDnsNameAvailability("nrp8", DomainQualifiedName);
37+
var result = this.NetworkClient.NetworkResourceProviderClient.CheckDnsNameAvailability(this.Location, this.DomainQualifiedName);
3238
WriteObject(result);
3339
}
3440
}

0 commit comments

Comments
 (0)