-
Notifications
You must be signed in to change notification settings - Fork 4k
Add CRUD for VirtualRouter top level resource and VirtualRouterPeer #10273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wyunchi-ms
merged 1 commit into
Azure:network-october
from
naveenchekuri:network-october
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/Network/Network.Test/ScenarioTests/VirtualRouterTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.Network.Test.ScenarioTests; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
|
||
namespace Commands.Network.Test.ScenarioTests | ||
{ | ||
public class VirtualRouterTests : NetworkTestRunner | ||
{ | ||
public VirtualRouterTests(Xunit.Abstractions.ITestOutputHelper output) | ||
: base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
[Trait(Category.Owner, NrpTeamAlias.pgtm)] | ||
public void TestVirtualRouterCRUDMinimalParameters() | ||
{ | ||
TestRunner.RunTestScript(string.Format("Test-VirtualRouterCRUD")); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/Network/Network.Test/ScenarioTests/VirtualRouterTests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# Copyright Microsoft Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
function Check-CmdletReturnType | ||
{ | ||
param($cmdletName, $cmdletReturn) | ||
|
||
$cmdletData = Get-Command $cmdletName | ||
Assert-NotNull $cmdletData | ||
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") } | ||
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") } | ||
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.","" | ||
return $cmdletReturnTypes -contains $realReturnType | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test creating new VirtualRouter | ||
#> | ||
function Test-VirtualRouterCRUD | ||
{ | ||
# Setup | ||
$rgname = Get-ResourceGroupName | ||
$rname = Get-ResourceName | ||
$domainNameLabel = Get-ResourceName | ||
$vnetName = Get-ResourceName | ||
$publicIpName = Get-ResourceName | ||
$vnetGatewayConfigName = Get-ResourceName | ||
$rglocation = Get-ProviderLocation ResourceManagement "southcentralus" | ||
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways" | ||
$location = Get-ProviderLocation $resourceTypeParent "southcentralus" | ||
$virtualRouterName = Get-ResourceName | ||
|
||
try | ||
{ | ||
# Create the resource group | ||
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" } | ||
|
||
|
||
# Create the Virtual Network | ||
$subnet = New-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24 | ||
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet | ||
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
$subnet = Get-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet | ||
|
||
# Create the publicip | ||
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel | ||
|
||
# Create & Get virtualnetworkgateway | ||
$vnetIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet | ||
|
||
$actual = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType ExpressRoute -GatewaySku HighPerformance -VpnType RouteBased -VpnGatewayGeneration None -Force | ||
$expected = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname | ||
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName | ||
Assert-AreEqual $expected.Name $actual.Name | ||
Assert-AreEqual "ExpressRoute" $expected.GatewayType | ||
Assert-AreEqual "None" $expected.VpnGatewayGeneration | ||
|
||
# Create Virtual Router | ||
$actualvr = New-AzVirtualRouter -ResourceGroupName $rgname -location $location -Name $virtualRouterName -HostedGateway $expected | ||
$expectedvr = Get-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName | ||
Assert-AreEqual $expectedvr.ResourceGroupName $actualvr.ResourceGroupName | ||
Assert-AreEqual $expectedvr.Name $actualvr.Name | ||
|
||
# List Virtual Routers | ||
$list = Get-AzVirtualRouter -ResourceGroupName $rgname | ||
Assert-AreEqual 1 @($list).Count | ||
Assert-AreEqual $list[0].ResourceGroupName $actualvr.ResourceGroupName | ||
Assert-AreEqual $list[0].Name $actualvr.Name | ||
Assert-AreEqual $list[0].Location $actualvr.Location | ||
|
||
# Delete VR | ||
$deletevR = Remove-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName -PassThru -Force | ||
Assert-AreEqual true $deletevR | ||
|
||
# Delete virtualNetworkGateway | ||
$delete = Remove-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force | ||
Assert-AreEqual true $delete | ||
|
||
$list = Get-AzVirtualRouter -ResourceGroupName $rgname | ||
Assert-AreEqual 0 @($list).Count | ||
} | ||
finally | ||
{ | ||
# Cleanup | ||
Clean-ResourceGroup $rgname | ||
} | ||
} | ||
|
7,632 changes: 7,632 additions & 0 deletions
7,632
...Network.Test.ScenarioTests.VirtualRouterTests/TestVirtualRouterCRUDMinimalParameters.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft and contributors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.WindowsAzure.Commands.Common.Attributes; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Azure.Commands.Network.Models | ||
{ | ||
public partial class PSVirtualRouter : PSTopLevelResource | ||
{ | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public PSResourceId HostedGateway { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public uint VirtualRouterAsn { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public List<string> VirtualRouterIps { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public string ProvisioningState { get; set; } | ||
public List<PSVirtualRouterPeer> Peerings { get; set; } | ||
|
||
[JsonIgnore] | ||
public string PeeringsText | ||
{ | ||
get { return JsonConvert.SerializeObject(Peerings, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } | ||
} | ||
|
||
[JsonIgnore] | ||
public string HostedGatewayText | ||
{ | ||
get { return JsonConvert.SerializeObject(HostedGateway, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Network/Network/Generated/Models/PSVirtualRouterPeer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft and contributors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.WindowsAzure.Commands.Common.Attributes; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Azure.Commands.Network.Models | ||
{ | ||
public partial class PSVirtualRouterPeer : PSChildResource | ||
{ | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public uint PeerAsn { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public string PeerIp { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public string ProvisioningState { get; set; } | ||
[Ps1Xml(Target = ViewControl.Table)] | ||
public string Type { get; set; } | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.