Skip to content

Commit 1cab39a

Browse files
gmainarEvgenyAgafonchikov
authored andcommitted
Commands and tests with updated API version. Not able to run new unit tests.
1 parent 3442d01 commit 1cab39a

19 files changed

+648
-0
lines changed

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/LoadBalancerTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,33 @@ public void TestSetLoadBalancerObjectAssignment()
144144
{
145145
NetworkResourcesController.NewInstance.RunPsTest("Test-SetLoadBalancerObjectAssignment");
146146
}
147+
148+
[Fact]
149+
[Trait(Category.AcceptanceType, Category.CheckIn)]
150+
public void TestSetLoadBalancerCRUDPublicBasicSku()
151+
{
152+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerCRUD-PublicBasicSku");
153+
}
154+
155+
[Fact]
156+
[Trait(Category.AcceptanceType, Category.CheckIn)]
157+
public void TestSetLoadBalancerCRUDInternalBasicSku()
158+
{
159+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerCRUD-InternalBasicSku");
160+
}
161+
162+
[Fact]
163+
[Trait(Category.AcceptanceType, Category.CheckIn)]
164+
public void TestSetLoadBalancerCRUDPublicStandardSku()
165+
{
166+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerCRUD-PublicStandardSku");
167+
}
168+
169+
[Fact]
170+
[Trait(Category.AcceptanceType, Category.CheckIn)]
171+
public void TestSetLoadBalancerCRUDInternalStandardSku()
172+
{
173+
NetworkResourcesController.NewInstance.RunPsTest("Test-LoadBalancerCRUD-InternalStandardSku");
174+
}
147175
}
148176
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/LoadBalancerTests.ps1

Lines changed: 377 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/PublicIpAddressTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,19 @@ public void TestPublicIpAddressVmss()
7474
{
7575
NetworkResourcesController.NewInstance.RunPsTest("Test-PublicIpAddressVmss");
7676
}
77+
78+
[Fact]
79+
[Trait(Category.AcceptanceType, Category.CheckIn)]
80+
public void TestPublicIpBasicSku()
81+
{
82+
NetworkResourcesController.NewInstance.RunPsTest("Test-PublicIpAddressCRUD-BasicSku");
83+
}
84+
85+
[Fact]
86+
[Trait(Category.AcceptanceType, Category.CheckIn)]
87+
public void TestPublicIpStandardSku()
88+
{
89+
NetworkResourcesController.NewInstance.RunPsTest("Test-PublicIpAddressCRUD-StandardSku");
90+
}
7791
}
7892
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/PublicIpAddressTests.ps1

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,115 @@ function Test-PublicIpAddressVmss
414414
# Cleanup
415415
Clean-ResourceGroup $rgname
416416
}
417+
418+
<#
419+
.SYNOPSIS
420+
Tests creating new simple publicIpAddress.
421+
#>
422+
function Test-PublicIpAddressCRUD-BasicSku
423+
{
424+
# Setup
425+
$rgname = Get-ResourceGroupName
426+
$rname = Get-ResourceName
427+
$domainNameLabel = Get-ResourceName
428+
$rglocation = Get-ProviderLocation ResourceManagement
429+
$resourceTypeParent = "Microsoft.Network/publicIpAddresses"
430+
$location = Get-ProviderLocation $resourceTypeParent
431+
432+
try
433+
{
434+
# Create the resource group
435+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
436+
437+
# Create publicIpAddres
438+
$actual = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $rname -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel -Sku Basic
439+
$expected = Get-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $rname
440+
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
441+
Assert-AreEqual $expected.Name $actual.Name
442+
Assert-AreEqual $expected.Location $actual.Location
443+
Assert-AreEqual $expected.Sku $actual.Sku
444+
Assert-AreEqual "Dynamic" $expected.PublicIpAllocationMethod
445+
Assert-NotNull $expected.ResourceGuid
446+
Assert-AreEqual "Succeeded" $expected.ProvisioningState
447+
Assert-AreEqual $domainNameLabel $expected.DnsSettings.DomainNameLabel
448+
449+
# list
450+
$list = Get-AzureRmPublicIpAddress -ResourceGroupName $rgname
451+
Assert-AreEqual 1 @($list).Count
452+
Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName
453+
Assert-AreEqual $list[0].Name $actual.Name
454+
Assert-AreEqual $list[0].Location $actual.Location
455+
Assert-AreEqual $list[0].Sku $actual.Sku
456+
Assert-AreEqual "Dynamic" $list[0].PublicIpAllocationMethod
457+
Assert-AreEqual "Succeeded" $list[0].ProvisioningState
458+
Assert-AreEqual $domainNameLabel $list[0].DnsSettings.DomainNameLabel
459+
460+
# delete
461+
$delete = Remove-AzureRmPublicIpAddress -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force
462+
Assert-AreEqual true $delete
463+
464+
$list = Get-AzureRmPublicIpAddress -ResourceGroupName $actual.ResourceGroupName
465+
Assert-AreEqual 0 @($list).Count
466+
}
467+
finally
468+
{
469+
# Cleanup
470+
Clean-ResourceGroup $rgname
471+
}
472+
}
473+
474+
<#
475+
.SYNOPSIS
476+
Tests creating new simple publicIpAddress with Static allocation.
477+
#>
478+
function Test-PublicIpAddressCRUD-StandardSku
479+
{
480+
# Setup
481+
$rgname = Get-ResourceGroupName
482+
$rname = Get-ResourceName
483+
$domainNameLabel = Get-ResourceName
484+
$rglocation = Get-ProviderLocation ResourceManagement
485+
$resourceTypeParent = "Microsoft.Network/publicIpAddresses"
486+
$location = Get-ProviderLocation $resourceTypeParent
487+
488+
try
489+
{
490+
# Create the resource group
491+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
492+
493+
# Create publicIpAddres
494+
$actual = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $rname -location $location -AllocationMethod Static -Sku Standard
495+
$expected = Get-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $rname
496+
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
497+
Assert-AreEqual $expected.Name $actual.Name
498+
Assert-AreEqual $expected.Location $actual.Location
499+
Assert-AreEqual $expected.Sku $actual.Sku
500+
Assert-AreEqual "Static" $expected.PublicIpAllocationMethod
501+
Assert-NotNull $expected.IpAddress
502+
Assert-AreEqual "Succeeded" $expected.ProvisioningState
503+
504+
# list
505+
$list = Get-AzureRmPublicIpAddress -ResourceGroupName $rgname
506+
Assert-AreEqual 1 @($list).Count
507+
Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName
508+
Assert-AreEqual $list[0].Name $actual.Name
509+
Assert-AreEqual $list[0].Location $actual.Location
510+
Assert-AreEqual $list[0].Sku $actual.Sku
511+
Assert-AreEqual "Static" $list[0].PublicIpAllocationMethod
512+
Assert-NotNull $list[0].IpAddress
513+
Assert-AreEqual "Succeeded" $list[0].ProvisioningState
514+
515+
# delete
516+
$delete = Remove-AzureRmPublicIpAddress -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force
517+
Assert-AreEqual true $delete
518+
519+
$list = Get-AzureRmPublicIpAddress -ResourceGroupName $actual.ResourceGroupName
520+
Assert-AreEqual 0 @($list).Count
521+
}
522+
finally
523+
{
524+
# Cleanup
525+
Clean-ResourceGroup $rgname
526+
}
527+
}
417528
}

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@
215215
<Compile Include="Models\PSApplicationGatewayAvailableSslOptions.cs" />
216216
<Compile Include="Models\PSEndpointServiceResult.cs" />
217217
<Compile Include="Models\PSServiceEndpoint.cs" />
218+
<Compile Include="Models\PSLoadBalancerSku.cs" />
219+
<Compile Include="Models\PSPublicIpAddressSku.cs" />
218220
<Compile Include="Models\PSVirtualNetworkUsage.cs" />
219221
<Compile Include="Models\PSApplicationGatewayBackendHealth.cs" />
220222
<Compile Include="Models\PSApplicationGatewayBackendHealthHttpSettings.cs" />

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ public static void Initialize()
9898
// PublicIpAddress
9999
// CNM to MNM
100100
cfg.CreateMap<CNM.PSPublicIpAddress, MNM.PublicIPAddress>();
101+
cfg.CreateMap<CNM.PSPublicIpAddressSku, MNM.PublicIPAddressSku>();
101102
cfg.CreateMap<CNM.PSPublicIpAddressDnsSettings, MNM.PublicIPAddressDnsSettings>();
102103

103104
// MNM to CNM
104105
cfg.CreateMap<MNM.PublicIPAddress, CNM.PSPublicIpAddress>();
106+
cfg.CreateMap<MNM.PublicIPAddressSku, CNM.PSPublicIpAddressSku>();
105107
cfg.CreateMap<MNM.PublicIPAddressDnsSettings, CNM.PSPublicIpAddressDnsSettings>();
106108

107109
// NetworkInterface
@@ -215,9 +217,11 @@ public static void Initialize()
215217
// LoadBalancer
216218
// CNM to MNM
217219
cfg.CreateMap<CNM.PSLoadBalancer, MNM.LoadBalancer>();
220+
cfg.CreateMap<CNM.PSLoadBalancerSku, MNM.LoadBalancerSku>();
218221

219222
// MNM to CNM
220223
cfg.CreateMap<MNM.LoadBalancer, CNM.PSLoadBalancer>();
224+
cfg.CreateMap<MNM.LoadBalancerSku, CNM.PSLoadBalancerSku>();
221225

222226
// FrontendIpConfiguration
223227
// CNM to MNM

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public override void Execute()
6262
}
6363

6464
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
65+
loadBalancingRule.DisableOutboundSNAT = this.DisableOutboundSNAT.IsPresent;
6566

6667
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))
6768
{

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public class AzureLoadBalancerRuleConfigBase : NetworkBaseCmdlet
9696
HelpMessage = "EnableFloatingIP")]
9797
public SwitchParameter EnableFloatingIP { get; set; }
9898

99+
[Parameter(
100+
Mandatory = false,
101+
HelpMessage = "DisableOutboundSNAT")]
102+
public SwitchParameter DisableOutboundSNAT { get; set; }
103+
99104
public override void Execute()
100105
{
101106

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public override void Execute()
4646
}
4747

4848
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
49+
loadBalancingRule.DisableOutboundSNAT = this.DisableOutboundSNAT.IsPresent;
4950

5051
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))
5152
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public override void Execute()
5757
loadBalancingRule.LoadDistribution = string.IsNullOrEmpty(this.LoadDistribution) ? "Default" : this.LoadDistribution;
5858

5959
loadBalancingRule.EnableFloatingIP = this.EnableFloatingIP.IsPresent;
60+
loadBalancingRule.DisableOutboundSNAT = this.DisableOutboundSNAT.IsPresent;
6061

6162
loadBalancingRule.BackendAddressPool = null;
6263
if (!string.IsNullOrEmpty(this.BackendAddressPoolId))

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public class NewAzureLoadBalancerCommand : LoadBalancerBaseCmdlet
4949
[ValidateNotNullOrEmpty]
5050
public virtual string Location { get; set; }
5151

52+
[Parameter(
53+
Mandatory = false,
54+
ValueFromPipelineByPropertyName = true,
55+
HelpMessage = "The load balancer Sku name.")]
56+
[ValidateNotNullOrEmpty]
57+
[ValidateSet(
58+
MNM.LoadBalancerSkuName.Basic,
59+
MNM.LoadBalancerSkuName.Standard,
60+
IgnoreCase = true)]
61+
public string Sku { get; set; }
62+
5263
[Parameter(
5364
Mandatory = false,
5465
ValueFromPipelineByPropertyName = true,
@@ -122,6 +133,12 @@ private PSLoadBalancer CreateLoadBalancer()
122133
loadBalancer.ResourceGroupName = this.ResourceGroupName;
123134
loadBalancer.Location = this.Location;
124135

136+
if (!string.IsNullOrEmpty(this.Sku))
137+
{
138+
loadBalancer.Sku = new PSLoadBalancerSku();
139+
loadBalancer.Sku.Name = this.Sku;
140+
}
141+
125142
if (this.FrontendIpConfiguration != null)
126143
{
127144
loadBalancer.FrontendIpConfigurations = this.FrontendIpConfiguration;

src/ResourceManager/Network/Commands.Network/Models/PSLoadBalancer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace Microsoft.Azure.Commands.Network.Models
2020

2121
public class PSLoadBalancer : PSTopLevelResource
2222
{
23+
public PSLoadBalancerSku Sku { get; set; }
24+
2325
public List<PSFrontendIPConfiguration> FrontendIpConfigurations { get; set; }
2426

2527
public List<PSBackendAddressPool> BackendAddressPools { get; set; }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Microsoft.Azure.Commands.Network.Models
16+
{
17+
public class PSLoadBalancerSku
18+
{
19+
public string Name { get; set; }
20+
}
21+
}

src/ResourceManager/Network/Commands.Network/Models/PSLoadBalancingRule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public class PSLoadBalancingRule : PSInboundRule
3737
[JsonProperty(Order = 1)]
3838
public bool? EnableFloatingIP { get; set; }
3939

40+
[JsonProperty(Order = 1)]
41+
public bool? DisableOutboundSNAT { get; set; }
42+
4043
[JsonIgnore]
4144
public string BackendAddressPoolText
4245
{

src/ResourceManager/Network/Commands.Network/Models/PSPublicIpAddress.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class PSPublicIpAddress : PSTopLevelResource
2020
{
2121
public string PublicIpAllocationMethod { get; set; }
2222

23+
public PSPublicIpAddressSku Sku { get; set; }
24+
2325
public PSIPConfiguration IpConfiguration { get; set; }
2426

2527
public PSPublicIpAddressDnsSettings DnsSettings { get; set; }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Microsoft.Azure.Commands.Network.Models
16+
{
17+
public class PSPublicIpAddressSku
18+
{
19+
public string Name { get; set; }
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Microsoft.Azure.Commands.Network.Models
16+
{
17+
public class PSResourceId
18+
{
19+
public string Id { get; set; }
20+
}
21+
}

src/ResourceManager/Network/Commands.Network/PublicIpAddress/NewAzurePublicIpAddressCommand.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ public class NewAzurePublicIpAddressCommand : PublicIpAddressBaseCmdlet
5050
[ValidateNotNullOrEmpty]
5151
public string Location { get; set; }
5252

53+
[Parameter(
54+
Mandatory = false,
55+
ValueFromPipelineByPropertyName = true,
56+
HelpMessage = "The public IP Sku name.")]
57+
[ValidateNotNullOrEmpty]
58+
[ValidateSet(
59+
MNM.PublicIPAddressSkuName.Basic,
60+
MNM.PublicIPAddressSkuName.Standard,
61+
IgnoreCase = true)]
62+
public string Sku { get; set; }
63+
5364
[Parameter(
5465
Mandatory = true,
5566
ValueFromPipelineByPropertyName = true,
@@ -127,6 +138,12 @@ private PSPublicIpAddress CreatePublicIpAddress()
127138
publicIp.PublicIpAllocationMethod = this.AllocationMethod;
128139
publicIp.PublicIpAddressVersion = this.IpAddressVersion;
129140

141+
if (!string.IsNullOrEmpty(this.Sku))
142+
{
143+
publicIp.Sku = new PSPublicIpAddressSku();
144+
publicIp.Sku.Name = this.Sku;
145+
}
146+
130147
if (this.IdleTimeoutInMinutes > 0)
131148
{
132149
publicIp.IdleTimeoutInMinutes = this.IdleTimeoutInMinutes;
Binary file not shown.

0 commit comments

Comments
 (0)