-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Added validation for circuit bandwidth in New/Update collector policy cmdlet for ATC #24571
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
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d6b14ba
Modified custom cmdlet
kukulkarni1 3ced294
minor fix
kukulkarni1 bd92f9e
Added custom new cmdlet
kukulkarni1 251fcb2
Added shouldprocess
kukulkarni1 e44d4c3
Add UT
kukulkarni1 aef8141
fix
kukulkarni1 b273d54
Update
kukulkarni1 6aba7e0
revert
kukulkarni1 22ca026
revert
kukulkarni1 2f9ed9d
Add UT
kukulkarni1 7362f76
Add UT
kukulkarni1 03a4fdf
Address comment
kukulkarni1 fab420f
Added UT
kukulkarni1 5baf240
test
kukulkarni1 745946a
Testing
kukulkarni1 2f6aec9
Testing
kukulkarni1 b4d49c9
Tests
kukulkarni1 55d2feb
Tests
kukulkarni1 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
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 |
|---|---|---|
|
|
@@ -63,4 +63,8 @@ directive: | |
| - where: | ||
| verb: Set | ||
| hide: true | ||
| - where: | ||
| verb: New | ||
| subject: ^CollectorPolicy(.*) | ||
| hide: true | ||
| ``` | ||
189 changes: 189 additions & 0 deletions
189
src/NetworkFunction/NetworkFunction.Autorest/custom/New-AzNetworkFunctionCollectorPolicy.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,189 @@ | ||
|
|
||
| # ---------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. 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. | ||
| # Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code | ||
| # is regenerated. | ||
| # ---------------------------------------------------------------------------------- | ||
|
|
||
| <# | ||
| .Synopsis | ||
| Creates or updates a Collector Policy resource | ||
| .Description | ||
| Creates or updates a Collector Policy resource | ||
| .Example | ||
| New-AzNetworkFunctionCollectorPolicy -collectorpolicyname cp1 -azuretrafficcollectorname atc -resourcegroupname rg1 -location eastus | Format-List | ||
|
|
||
| .Outputs | ||
| Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Models.Api20221101.ICollectorPolicy | ||
| .Notes | ||
| COMPLEX PARAMETER PROPERTIES | ||
|
|
||
| To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. | ||
|
|
||
| EMISSIONPOLICY <IEmissionPoliciesPropertiesFormat[]>: Emission policies. | ||
| [EmissionDestination <IEmissionPolicyDestination[]>]: Emission policy destinations. | ||
| [DestinationType <DestinationType?>]: Emission destination type. | ||
| [EmissionType <EmissionType?>]: Emission format type. | ||
|
|
||
| INGESTIONPOLICYINGESTIONSOURCE <IIngestionSourcesPropertiesFormat[]>: Ingestion Sources. | ||
| [ResourceId <String>]: Resource ID. | ||
| [SourceType <SourceType?>]: Ingestion source type. | ||
| .Link | ||
| https://learn.microsoft.com/powershell/module/az.networkfunction/new-aznetworkfunctioncollectorpolicy | ||
| #> | ||
| function New-AzNetworkFunctionCollectorPolicy { | ||
| [OutputType([Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Models.Api20221101.ICollectorPolicy])] | ||
| [CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)] | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Path')] | ||
| [System.String] | ||
| # Azure Traffic Collector name | ||
| ${AzureTrafficCollectorName}, | ||
|
|
||
| [Parameter(Mandatory)] | ||
| [Alias('CollectorPolicyName')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Path')] | ||
| [System.String] | ||
| # Collector Policy Name | ||
| ${Name}, | ||
|
|
||
| [Parameter(Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Path')] | ||
| [System.String] | ||
| # The name of the resource group. | ||
| ${ResourceGroupName}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Path')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
| [System.String] | ||
| # Azure Subscription ID. | ||
| ${SubscriptionId}, | ||
|
|
||
| [Parameter(Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Body')] | ||
| [System.String] | ||
| # Resource location. | ||
| ${Location}, | ||
|
|
||
| [Parameter()] | ||
| [AllowEmptyCollection()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Body')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Models.Api20221101.IEmissionPoliciesPropertiesFormat[]] | ||
| # Emission policies. | ||
| # To construct, see NOTES section for EMISSIONPOLICY properties and create a hash table. | ||
| ${EmissionPolicy}, | ||
|
|
||
| [Parameter()] | ||
| [AllowEmptyCollection()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Body')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Models.Api20221101.IIngestionSourcesPropertiesFormat[]] | ||
| # Ingestion Sources. | ||
| # To construct, see NOTES section for INGESTIONPOLICYINGESTIONSOURCE properties and create a hash table. | ||
| ${IngestionPolicyIngestionSource}, | ||
|
|
||
| [Parameter()] | ||
| [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Support.IngestionType])] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Body')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Support.IngestionType] | ||
| # The ingestion type. | ||
| ${IngestionPolicyIngestionType}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Body')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Models.Api20221101.ITrackedResourceTags]))] | ||
| [System.Collections.Hashtable] | ||
| # Resource tags. | ||
| ${Tag}, | ||
|
|
||
| [Parameter()] | ||
| [Alias('AzureRMContext', 'AzureCredential')] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Azure')] | ||
| [System.Management.Automation.PSObject] | ||
| # The credentials, account, tenant, and subscription used for communication with Azure. | ||
| ${DefaultProfile}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command as a job | ||
| ${AsJob}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Wait for .NET debugger to attach | ||
| ${Break}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
| ${HttpPipelineAppend}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
| ${HttpPipelinePrepend}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command asynchronously | ||
| ${NoWait}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Uri] | ||
| # The URI for the proxy server to use | ||
| ${Proxy}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Management.Automation.PSCredential] | ||
| # Credentials for a proxy server to use for the remote call | ||
| ${ProxyCredential}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.NetworkFunction.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Use the default credentials for the proxy | ||
| ${ProxyUseDefaultCredentials} | ||
| ) | ||
|
|
||
| process { | ||
| $rg = $PSBoundParameters.ResourceGroupName | ||
|
|
||
| # Ensure exr circuit bandwidth 1G or more | ||
| $cktname = $IngestionPolicyIngestionSource.ResourceId | Where {$IngestionPolicyIngestionSource.ResourceId -match "/*subscriptions/(?<subid>.*)/resourceGroups/(?<rgname>.*)/providers/Microsoft.Network/expressRouteCircuits/(?<circuitname>.*)"} | Foreach {$Matches['circuitname']} | ||
| Import-Module Az.Network -Force | ||
| $exrCircuit = Get-AzExpressRouteCircuit -Name $cktname -ResourceGroupName $rg | ||
| $bandwidthInGbps = $exrCircuit.BandwidthInGbps | ||
| $bandwidthInMbps = $exrCircuit.ServiceProviderProperties.BandwidthInMbps | ||
|
|
||
| if ($bandwidthInGbps -and ($bandwidthInGbps -lt 1)) { | ||
| throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported." | ||
| } | ||
|
|
||
| if ($bandwidthInMbps -and ($bandwidthInMbps -lt 1000)) { | ||
| throw "CollectorPolicy can not be updated because circuit has bandwidth less than 1G. Circuit size with a bandwidth of 1G or more is supported." | ||
| } | ||
|
|
||
| Az.NetworkFunction.internal\New-AzNetworkFunctionCollectorPolicy @PSBoundParameters | ||
| } | ||
| } |
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
10 changes: 10 additions & 0 deletions
10
src/NetworkFunction/NetworkFunction.Autorest/test/env.json
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,10 @@ | ||
| { | ||
| "collectorPolicyName": "cp1", | ||
| "azureTrafficCollectorName": "UTPSatc", | ||
| "resourceGroup": "DO_NOT_DELETE_ATC_PS_Tests", | ||
| "location": "eastus", | ||
| "SubscriptionId": "05f401ac-885f-4ba4-b2d6-7c5444596230", | ||
| "ResourceId1G": "/subscriptions/05f401ac-885f-4ba4-b2d6-7c5444596230/resourceGroups/DO_NOT_DELETE_ATC_PS_Tests/providers/Microsoft.Network/expressRouteCircuits/DO_NOT_DELETE_ATC_PS_Test_Ckt", | ||
| "ResourceIdLessThan1G": "/subscriptions/05f401ac-885f-4ba4-b2d6-7c5444596230/resourceGroups/DO_NOT_DELETE_ATC_PS_Tests/providers/Microsoft.Network/expressRouteCircuits/DO_NOT_DELETE_ATC_PS_Test_Ckt_1", | ||
| "IngestionType": "IPFIX" | ||
| } |
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.