-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Support Reset connection for VNG and Vwan #14225
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
Yabo Hu (VeryEarly)
merged 11 commits into
Azure:network-november
from
akshatkale:ak-reset-connection-november
Feb 25, 2021
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
905a81f
Support Reset connection for VNG and Vwan
akshatkale f4992d9
Updates and add recorded test for VNG
akshatkale a8e0f78
Remove unwanted files
akshatkale 621ed07
Remove new VSPrompt.lnk
akshatkale 38b4cad
Add local SDK
akshatkale b08f8c4
Add recorded test for Reset-AzVpnSiteLinkConnection
akshatkale 5583b43
Merge branch 'network-november' into ak-reset-connection-november
akshatkale d9788bf
Update local SDK version
akshatkale 0d47b19
Fix md file
akshatkale 70c9873
Fix md-2
akshatkale cd04b1c
CR Fix-1
akshatkale 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
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
25,089 changes: 2,682 additions & 22,407 deletions
25,089
...orkGatewayConnectionTests/TestVirtualNetworkGatewayConnectionWithActiveAcitveGateway.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
110 changes: 110 additions & 0 deletions
110
src/Network/Network/Cortex/VpnConnection/ResetAzVpnSiteLinkConnectionCommand.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,110 @@ | ||
| namespace Microsoft.Azure.Commands.Network.Cortex.VpnConnection | ||
| { | ||
| using System; | ||
| using System.Management.Automation; | ||
| using Microsoft.Azure.Commands.Network.Models; | ||
| using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
| using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
| using Microsoft.Azure.Management.Network; | ||
| using Microsoft.Azure.Management.Network.Models; | ||
|
|
||
| [Cmdlet( | ||
| VerbsCommon.Reset, | ||
| ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VpnSiteLinkConnection", | ||
| DefaultParameterSetName = "ByName"), | ||
| OutputType(typeof(void))] | ||
|
|
||
| public class ResetAzVpnSiteLinkConnectionCommand : VpnLinkConnectionBaseCmdlet | ||
| { | ||
| [Parameter( | ||
| ParameterSetName = "ByName", | ||
| Mandatory = true, | ||
| HelpMessage = "The resource group name.")] | ||
| [ResourceGroupCompleter] | ||
| [ValidateNotNullOrEmpty] | ||
| public string ResourceGroupName { get; set; } | ||
|
|
||
| [Alias("GrandParentName")] | ||
| [Parameter( | ||
| ParameterSetName = "ByName", | ||
| Mandatory = true, | ||
| HelpMessage = "The Vpn gateway name.")] | ||
| [ResourceNameCompleter("Microsoft.Network/vpnGateways", "ResourceGroupName")] | ||
| [ValidateNotNullOrEmpty] | ||
| public string VpnGatewayName { get; set; } | ||
|
|
||
| [Alias("ParentName")] | ||
| [Parameter( | ||
| ParameterSetName = "ByName", | ||
| Mandatory = true, | ||
| HelpMessage = "The Vpn connection name.")] | ||
| [ResourceNameCompleter("Microsoft.Network/connections", "GrandParentResourceName")] | ||
| [ValidateNotNullOrEmpty] | ||
| public string VpnConnectionName { get; set; } | ||
|
|
||
| [Alias("ResourceName", "VpnSiteLinkConnectionName")] | ||
| [Parameter( | ||
| ParameterSetName = "ByName", | ||
| Mandatory = true, | ||
| HelpMessage = "The Vpn site link connection name.")] | ||
| [ResourceNameCompleter("Microsoft.Network/connections", "ParentResourceName")] | ||
| [ValidateNotNullOrEmpty] | ||
| public string Name { get; set; } | ||
|
|
||
| [Alias("VpnSiteLinkConnection")] | ||
| [Parameter( | ||
| ParameterSetName = "ByInputObject", | ||
| Mandatory = true, | ||
| ValueFromPipeline = true, | ||
| HelpMessage = "The Vpn site link connection object.")] | ||
| [ValidateNotNullOrEmpty] | ||
| public PSVpnSiteLinkConnection InputObject { get; set; } | ||
|
|
||
| [Parameter( | ||
| ParameterSetName = "ByResourceId", | ||
| Mandatory = true, | ||
| ValueFromPipelineByPropertyName = true, | ||
| HelpMessage = "The Azure resource ID of the Vpn site link connection for which IKE SAs needs to be fetched.")] | ||
| [ValidateNotNullOrEmpty] | ||
| public string ResourceId { get; set; } | ||
|
|
||
| [Parameter( | ||
| Mandatory = false, | ||
| HelpMessage = "Run cmdlet in the background.")] | ||
| public SwitchParameter AsJob { get; set; } | ||
|
|
||
| public override void Execute() | ||
| { | ||
| var parsedResourceId = new ResourceIdentifier(); | ||
|
|
||
| if (!ParameterSetName.Equals("ByName")) | ||
| { | ||
| if (ParameterSetName.Equals("ByResourceId")) | ||
| { | ||
| parsedResourceId = new ResourceIdentifier(this.ResourceId); | ||
| } | ||
| else if (ParameterSetName.Equals("ByInputObject")) | ||
| { | ||
| parsedResourceId = new ResourceIdentifier(this.InputObject.Id); | ||
| } | ||
|
|
||
| this.ResourceGroupName = parsedResourceId.ResourceGroupName; | ||
| var resources = parsedResourceId.ParentResource.Split(new[] { '/' }, 4, StringSplitOptions.RemoveEmptyEntries); | ||
| this.VpnGatewayName = resources[1]; | ||
| this.VpnConnectionName = resources[3]; | ||
| this.Name = parsedResourceId.ResourceName; | ||
| } | ||
|
|
||
| base.Execute(); | ||
|
|
||
| if (this.IsVpnConnectionPresent(this.ResourceGroupName, this.VpnGatewayName, this.VpnConnectionName)) | ||
| { | ||
| this.VpnLinkConnectionClient.ResetConnection(this.ResourceGroupName, this.VpnGatewayName, this.VpnConnectionName, this.Name); | ||
| } | ||
| else | ||
| { | ||
| throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name); | ||
| } | ||
| } | ||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
src/Network/Network/Cortex/VpnConnection/VpnLinkConnectionBaseCmdlet.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,19 @@ | ||
| using Microsoft.Azure.Management.Network; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Net; | ||
| using System.Text; | ||
|
|
||
| namespace Microsoft.Azure.Commands.Network.Cortex.VpnConnection | ||
| { | ||
| public class VpnLinkConnectionBaseCmdlet : VpnConnectionBaseCmdlet | ||
| { | ||
| public IVpnLinkConnectionsOperations VpnLinkConnectionClient | ||
| { | ||
| get | ||
| { | ||
| return NetworkClient.NetworkManagementClient.VpnLinkConnections; | ||
| } | ||
| } | ||
| } | ||
| } |
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
93 changes: 93 additions & 0 deletions
93
...twork/VirtualNetworkGatewayConnection/ResetAzureVirtualNetworkGatewayConnectionCommand.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,93 @@ | ||||||
| // 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. | ||||||
| // ---------------------------------------------------------------------------------- | ||||||
|
|
||||||
| namespace Microsoft.Azure.Commands.Network | ||||||
| { | ||||||
| using System.Collections.Generic; | ||||||
| using System.Management.Automation; | ||||||
| using Microsoft.Azure.Commands.Network.Models; | ||||||
| using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||||||
| using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||||||
| using Microsoft.Azure.Management.Network; | ||||||
| using Microsoft.Azure.Management.Network.Models; | ||||||
| using Newtonsoft.Json; | ||||||
|
|
||||||
| [Cmdlet("Reset", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGatewayConnection", DefaultParameterSetName = "ByName"), OutputType(typeof(void))] | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| public class ResetAzVirtualNetworkGatewayConnectionCommand : VirtualNetworkGatewayConnectionBaseCmdlet | ||||||
| { | ||||||
| [Alias("ResourceName", "ConnectionName")] | ||||||
| [Parameter( | ||||||
| ParameterSetName = "ByName", | ||||||
| Mandatory = true, | ||||||
| HelpMessage = "The virtual network gateway connection name which needs to be reset.")] | ||||||
| [ResourceNameCompleter("Microsoft.Network/connections", "ResourceGroupName")] | ||||||
| [ValidateNotNullOrEmpty] | ||||||
| public virtual string Name { get; set; } | ||||||
|
|
||||||
| [Parameter( | ||||||
| ParameterSetName = "ByName", | ||||||
| Mandatory = true, | ||||||
| HelpMessage = "The resource group name.")] | ||||||
| [ResourceGroupCompleter] | ||||||
| [ValidateNotNullOrEmpty] | ||||||
| public virtual string ResourceGroupName { get; set; } | ||||||
|
|
||||||
| [Parameter( | ||||||
| ParameterSetName = "ByInputObject", | ||||||
| Mandatory = true, | ||||||
| ValueFromPipelineByPropertyName = true, | ||||||
| HelpMessage = "The virtual network gateway connection object which needs to be reset.")] | ||||||
| [ValidateNotNullOrEmpty] | ||||||
| public PSVirtualNetworkGatewayConnection InputObject { get; set; } | ||||||
|
|
||||||
| [Parameter( | ||||||
| ParameterSetName = "ByResourceId", | ||||||
| Mandatory = true, | ||||||
| ValueFromPipelineByPropertyName = true, | ||||||
| HelpMessage = "The Azure resource ID of the Virtual Network Gateway Connection which needs to be reset.")] | ||||||
| [ValidateNotNullOrEmpty] | ||||||
| public string ResourceId { get; set; } | ||||||
|
|
||||||
| [Parameter( | ||||||
| Mandatory = false, | ||||||
| HelpMessage = "Run cmdlet in the background.")] | ||||||
| public SwitchParameter AsJob { get; set; } | ||||||
|
|
||||||
| public override void Execute() | ||||||
| { | ||||||
| if (ParameterSetName.Equals("ByInputObject")) | ||||||
| { | ||||||
| this.ResourceGroupName = this.InputObject.ResourceGroupName; | ||||||
| this.Name = this.InputObject.Name; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| if (ParameterSetName.Equals("ByResourceId")) | ||||||
| { | ||||||
| var parsedResourceId = new ResourceIdentifier(ResourceId); | ||||||
| Name = parsedResourceId.ResourceName; | ||||||
| ResourceGroupName = parsedResourceId.ResourceGroupName; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| base.Execute(); | ||||||
|
|
||||||
| if (this.IsVirtualNetworkGatewayConnectionPresent(this.ResourceGroupName, this.Name)) | ||||||
| { | ||||||
| this.VirtualNetworkGatewayConnectionClient.ResetConnection(this.ResourceGroupName, this.Name); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| throw new PSArgumentException(Properties.Resources.ResourceNotFound, this.Name); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated