Skip to content

Commit 86108ab

Browse files
author
Khushboo Baheti
committed
VNGCommands
1 parent debf8f5 commit 86108ab

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/Network/Network/Models/PSVirtualNetworkGateway.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class PSVirtualNetworkGateway : PSTopLevelResource
5454

5555
public List<PSVirtualNetworkGatewayNatRule> NatRules { get; set; }
5656

57+
[Ps1Xml(Target = ViewControl.Table)]
58+
public bool EnableBgpRouteTranslationForNat { get; set; }
59+
5760
[JsonIgnore]
5861
public string IpConfigurationsText
5962
{

src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
199199
[ValidateNotNullOrEmpty]
200200
public PSIpConfigurationBgpPeeringAddress[] IpConfigurationBgpPeeringAddresses { get; set; }
201201

202+
[Parameter(
203+
Mandatory = false,
204+
ValueFromPipelineByPropertyName = true,
205+
HelpMessage = "The NatRules for Virtual network gateway.")]
206+
public PSVirtualNetworkGatewayNatRule[] NatRule { get; set; }
207+
208+
[Parameter(
209+
Mandatory = false,
210+
HelpMessage = "Flag to enable BgpRouteTranslationForNat on this VirtualNetworkGateway.")]
211+
public SwitchParameter EnableBgpRouteTranslationForNatFlag { get; set; }
212+
202213
[Parameter(
203214
Mandatory = false,
204215
ValueFromPipelineByPropertyName = true,
@@ -512,6 +523,18 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
512523
vnetGateway.VpnGatewayGeneration = this.VpnGatewayGeneration;
513524
}
514525

526+
if (this.NatRule != null && this.NatRule.Any())
527+
{
528+
vnetGateway.NatRules = this.NatRule?.ToList();
529+
}
530+
else
531+
{
532+
vnetGateway.NatRules = null;
533+
}
534+
535+
// Set the EnableBgpRouteTranslationForNat, if it is specified by customer.
536+
vnetGateway.EnableBgpRouteTranslationForNat = EnableBgpRouteTranslationForNatFlag.IsPresent;
537+
515538
// Map to the sdk object
516539
var vnetGatewayModel = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualNetworkGateway>(vnetGateway);
517540
vnetGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,22 @@ public class SetAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
201201
HelpMessage = "Custom routes AddressPool specified by customer")]
202202
public string[] CustomRoute { get; set; }
203203

204+
[Parameter(
205+
Mandatory = false,
206+
ValueFromPipelineByPropertyName = true,
207+
HelpMessage = "The NatRules for Virtual network gateway.")]
208+
public PSVirtualNetworkGatewayNatRule[] NatRule { get; set; }
209+
210+
[Parameter(
211+
Mandatory = false,
212+
HelpMessage = "Flag to enable BgpRouteTranslationForNat on this VirtualNetworkGateway.")]
213+
public SwitchParameter EnableBgpRouteTranslationForNatFlag { get; set; }
214+
215+
[Parameter(
216+
Mandatory = false,
217+
HelpMessage = "Flag to disable BgpRouteTranslationForNat on this VirtualNetworkGateway.")]
218+
public SwitchParameter DisableBgpRouteTranslationForNatFlag { get; set; }
219+
204220
[Parameter(
205221
Mandatory = true,
206222
ParameterSetName = VirtualNetworkGatewayParameterSets.UpdateResourceWithTags,
@@ -442,6 +458,22 @@ public override void Execute()
442458
this.VirtualNetworkGateway.CustomRoutes = null;
443459
}
444460

461+
if (this.NatRule != null)
462+
{
463+
this.VirtualNetworkGateway.NatRules = this.NatRule?.ToList();
464+
}
465+
466+
if (this.EnableBgpRouteTranslationForNatFlag.IsPresent)
467+
{
468+
this.VirtualNetworkGateway.EnableBgpRouteTranslationForNat = true;
469+
}
470+
471+
if (this.DisableBgpRouteTranslationForNatFlag.IsPresent)
472+
{
473+
this.VirtualNetworkGateway.EnableBgpRouteTranslationForNat = false;
474+
}
475+
476+
445477
// Map to the sdk object
446478
MNM.VirtualNetworkGateway sdkVirtualNetworkGateway = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualNetworkGateway>(this.VirtualNetworkGateway);
447479
sdkVirtualNetworkGateway.Tags =

0 commit comments

Comments
 (0)