-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Adding subnet delegation cmdlets #7220
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
Changes from all commits
df32a96
f4affad
0c0c99e
3caff88
a4fdbd8
e04ef74
4ddeaa6
912fded
c4ab084
c70aad4
284ef53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // 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.ServiceManagemenet.Common.Models; | ||
| using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Commands.Network.Test.ScenarioTests | ||
| { | ||
| public class AvailableDelegationsTests : Microsoft.WindowsAzure.Commands.Test.Utilities.Common.RMTestBase | ||
| { | ||
| public XunitTracingInterceptor _logger; | ||
|
|
||
| public AvailableDelegationsTests(Xunit.Abstractions.ITestOutputHelper output) | ||
| { | ||
| _logger = new XunitTracingInterceptor(output); | ||
| XunitTracingInterceptor.AddToContext(_logger); | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait(Category.AcceptanceType, Category.CheckIn)] | ||
| [Trait(Category.Owner, Category.sdnnrp)] | ||
| public void TestAvailableDelegationsList() | ||
| { | ||
| NetworkResourcesController.NewInstance.RunPsTest(_logger, "Test-GetAvailableDelegationsList"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # ---------------------------------------------------------------------------------- | ||
| # | ||
| # 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. | ||
| # ---------------------------------------------------------------------------------- | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Tests checking API to list available delegations. | ||
| #> | ||
| function Test-GetAvailableDelegationsList | ||
| { | ||
| $location = Get-ProviderLocation ResourceManagement | ||
| $location = $location -replace " ","" | ||
rupalivohra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try | ||
| { | ||
| $results = Get-AzureRmAvailableServiceDelegation -Location $location; | ||
| Assert-NotNull $results; | ||
rupalivohra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| finally | ||
| { | ||
| # Cleanup | ||
| Clean-ResourceGroup $rgname | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,6 +187,96 @@ function Test-subnetCRUD | |
| } | ||
| } | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Tests creating new virtualNetwork w/ delegated subnets. | ||
| .DESCRIPTION | ||
| SmokeTest | ||
| #> | ||
| function Test-subnetDelegationCRUD | ||
|
||
| { | ||
| # Setup | ||
| $rgname = Get-ResourceGroupName | ||
| $vnetName = Get-ResourceName | ||
| $subnetName = Get-ResourceName | ||
| $subnet2Name = Get-ResourceName | ||
| $domainNameLabel = Get-ResourceName | ||
| $rglocation = Get-ProviderLocation ResourceManagement | ||
| $resourceTypeParent = "Microsoft.Network/virtualNetworks" | ||
| $location = Get-ProviderLocation $resourceTypeParent | ||
|
|
||
| try | ||
| { | ||
| # Create the resource group | ||
| $resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" } | ||
|
|
||
| # Create a delegation | ||
| $delegation = New-AzureRmDelegation -Name "sqlDelegation" -ServiceName "Microsoft.Sql/servers" | ||
|
|
||
| # Create the Virtual Network | ||
| $subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24 -delegation $delegation | ||
| New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet | ||
| $vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
|
|
||
| # Add a subnet | ||
| $vnet | Add-AzureRmVirtualNetworkSubnetConfig -Name $subnet2Name -AddressPrefix 10.0.2.0/24 | ||
|
|
||
| # Set VirtualNetwork | ||
| $vnet | Set-AzureRmVirtualNetwork | ||
|
|
||
| # Get VirtualNetwork | ||
| $vnetExpected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
|
|
||
| Assert-AreEqual 2 @($vnetExpected.Subnets).Count | ||
| Assert-AreEqual 1 @($vnetExpected.Subnets[0].Delegations).Count | ||
| Assert-AreEqual 0 @($vnetExpected.Subnets[1].Delegations).Count | ||
|
|
||
| # Edit a subnet | ||
| $vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgname | Set-AzureRmVirtualNetworkSubnetConfig -Name $subnet2Name -AddressPrefix 10.0.2.0/24 | ||
|
|
||
| # Add a delegation to the subnet | ||
| Get-AzureRmVirtualNetworkSubnetConfig -Name $subnet2Name -VirtualNetwork $vnet | Add-AzureRmDelegation -Name "bareMetalDelegation" -ServiceName "Microsoft.Netapp/volumes" | ||
| Set-AzureRmVirtualNetwork -VirtualNetwork $vnet | ||
|
|
||
| $vnetExpected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
| Assert-AreEqual 2 @($vnetExpected.Subnets).Count | ||
| Assert-AreEqual 1 @($vnetExpected.Subnets[0].Delegations).Count | ||
| Assert-AreEqual "Microsoft.Sql/servers" $vnetExpected.Subnets[0].Delegations[0].ServiceName | ||
| Assert-AreEqual 1 @($vnetExpected.Subnets[1].Delegations).Count | ||
| Assert-AreEqual "Microsoft.Netapp/volumes" $vnetExpected.Subnets[1].Delegations[0].ServiceName | ||
|
|
||
| # Get subnet | ||
| $subnet2 = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | Get-AzureRmVirtualNetworkSubnetConfig -Name $subnet2Name | ||
| Assert-AreEqual 1 @($subnet2.Delegations).Count | ||
| $subnetAll = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | Get-AzureRmVirtualNetworkSubnetConfig | ||
|
|
||
| Assert-AreEqual 2 @($subnetAll).Count | ||
|
|
||
| # Get delegations from the subnets | ||
| Foreach ($sub in $subnetAll) | ||
| { | ||
| $del = Get-AzureRmDelegation -Subnet $sub | ||
| Assert-NotNull $del | ||
| } | ||
|
|
||
| # Remove a delegation | ||
| $vnetToEdit = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
| $subnetWithoutDelegation = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnet2Name -VirtualNetwork $vnet | Remove-AzureRmDelegation -Name "bareMetalDelegation" | ||
| $vnetToEdit.Subnets[1] = $subnetWithoutDelegation | ||
| $vnet = Set-AzureRmVirtualNetwork -VirtualNetwork $vnetToEdit | ||
|
|
||
| $vnetExpected = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname | ||
| Assert-AreEqual 2 @($vnetExpected.Subnets).Count | ||
| Assert-AreEqual 1 @($vnetExpected.Subnets[0].Delegations).Count | ||
| Assert-AreEqual 0 @($vnetExpected.Subnets[1].Delegations).Count | ||
| } | ||
| finally | ||
| { | ||
| # Cleanup | ||
| Clean-ResourceGroup $rgname | ||
| } | ||
| } | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Tests creating new simple virtualNetwork and subnets. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| { | ||
| "Entries": [ | ||
| { | ||
| "RequestUri": "/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/locations/westcentralus/availableDelegations?api-version=2018-08-01", | ||
| "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZTA1ZGJiY2UtNzljMi00NWEyLWE3ZWYtZjEwNTg4NTZmZWIzL3Byb3ZpZGVycy9NaWNyb3NvZnQuTmV0d29yay9sb2NhdGlvbnMvd2VzdGNlbnRyYWx1cy9hdmFpbGFibGVEZWxlZ2F0aW9ucz9hcGktdmVyc2lvbj0yMDE4LTA4LTAx", | ||
| "RequestMethod": "GET", | ||
| "RequestBody": "", | ||
| "RequestHeaders": { | ||
| "x-ms-client-request-id": [ | ||
| "c10de067-a942-4b31-af27-c70299eee8de" | ||
| ], | ||
| "accept-language": [ | ||
| "en-US" | ||
| ], | ||
| "User-Agent": [ | ||
| "FxVersion/4.7.3163.0", | ||
| "OSName/Windows10Enterprise", | ||
| "OSVersion/6.3.17134", | ||
| "Microsoft.Azure.Management.Network.NetworkManagementClient/19.4.0.0" | ||
| ] | ||
| }, | ||
| "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"name\": \"Microsoft.Web.serverFarms\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.Web.serverFarms\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.Web/serverFarms\",\r\n \"actions\": [\r\n \"Microsoft.Network/virtualNetworks/subnets/action\"\r\n ]\r\n },\r\n {\r\n \"name\": \"Microsoft.Sql.servers\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.Sql.servers\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.Sql/servers\",\r\n \"actions\": []\r\n },\r\n {\r\n \"name\": \"Microsoft.ContainerInstance.containerGroups\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.ContainerInstance.containerGroups\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"actions\": [\r\n \"Microsoft.Network/virtualNetworks/subnets/action\"\r\n ]\r\n },\r\n {\r\n \"name\": \"Microsoft.Netapp.volumes\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.Netapp.volumes\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.Netapp/volumes\",\r\n \"actions\": [\r\n \"Microsoft.Network/networkinterfaces/*\",\r\n \"Microsoft.Network/virtualNetworks/subnets/join/action\"\r\n ]\r\n },\r\n {\r\n \"name\": \"Microsoft.HardwareSecurityModules.dedicatedHSMs\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.HardwareSecurityModules.dedicatedHSMs\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.HardwareSecurityModules/dedicatedHSMs\",\r\n \"actions\": [\r\n \"Microsoft.Network/networkinterfaces/*\",\r\n \"Microsoft.Network/virtualNetworks/subnets/join/action\"\r\n ]\r\n },\r\n {\r\n \"name\": \"Microsoft.ServiceFabricMesh.networks\",\r\n \"id\": \"/subscriptions/e05dbbce-79c2-45a2-a7ef-f1058856feb3/providers/Microsoft.Network/availableDelegations/Microsoft.ServiceFabricMesh.networks\",\r\n \"type\": \"Microsoft.Network/availableDelegations\",\r\n \"serviceName\": \"Microsoft.ServiceFabricMesh/networks\",\r\n \"actions\": [\r\n \"Microsoft.Network/virtualNetworks/subnets/action\"\r\n ]\r\n }\r\n ]\r\n}", | ||
| "ResponseHeaders": { | ||
| "Content-Length": [ | ||
| "2596" | ||
| ], | ||
| "Content-Type": [ | ||
| "application/json; charset=utf-8" | ||
| ], | ||
| "Expires": [ | ||
| "-1" | ||
| ], | ||
| "Pragma": [ | ||
| "no-cache" | ||
| ], | ||
| "x-ms-request-id": [ | ||
| "584c08d1-9b2e-44c6-968c-322bdb48e783" | ||
| ], | ||
| "x-ms-correlation-request-id": [ | ||
| "3ca1d79c-8ba7-469e-82a8-89b5d8d0e840" | ||
| ], | ||
| "Strict-Transport-Security": [ | ||
| "max-age=31536000; includeSubDomains" | ||
| ], | ||
| "x-ms-ratelimit-remaining-subscription-reads": [ | ||
| "11999" | ||
| ], | ||
| "Cache-Control": [ | ||
| "no-cache" | ||
| ], | ||
| "Server": [ | ||
| "Microsoft-HTTPAPI/2.0", | ||
| "Microsoft-HTTPAPI/2.0" | ||
| ], | ||
| "x-ms-routing-request-id": [ | ||
| "WESTUS2:20180913T191723Z:3ca1d79c-8ba7-469e-82a8-89b5d8d0e840" | ||
| ], | ||
| "X-Content-Type-Options": [ | ||
| "nosniff" | ||
| ], | ||
| "Date": [ | ||
| "Thu, 13 Sep 2018 19:17:22 GMT" | ||
| ] | ||
| }, | ||
| "StatusCode": 200 | ||
| } | ||
| ], | ||
| "Names": {}, | ||
| "Variables": { | ||
| "SubscriptionId": "e05dbbce-79c2-45a2-a7ef-f1058856feb3" | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.