Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Feature: add set-nsxfirewallrule appliedTo support #614

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion module/PowerNSX.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28524,6 +28524,16 @@ function Set-NsxFirewallRule {
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -comment "My Comment"

Set/update the comment of the RuleId 1007

.EXAMPLE
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -ApplyToDfw

SetRuleId AppliedTo for RuleID 1007 to the Distributed Firewall

.EXAMPLE
Get-NsxFirewallRule -Ruleid 1007 | Set-NsxFirewallRule -appliedTo (Get-NsxSecurityGroup myGroup)

SetRuleId AppliedTo for RuleID 1007 to myGroup
#>

param (
Expand All @@ -28545,6 +28555,14 @@ function Set-NsxFirewallRule {
[Parameter (Mandatory=$false)]
[ValidateNotNullOrEmpty()]
[string]$comment,
[Parameter (Mandatory=$false)]
[object[]]$appliedTo,
[Parameter (Mandatory=$false)]
# Enable application of the rule to 'DISTRIBUTED_FIREWALL' (ie, to all VNICs present on NSX prepared hypervisors. This does NOT include NSX Edges)
[switch]$ApplyToDfw=$false,
[Parameter (Mandatory=$false)]
# Enable application of the rule to all NSX edges
[switch]$ApplyToAllEdges=$false,
[Parameter (Mandatory=$false)]
#PowerNSX Connection object.
[ValidateNotNullOrEmpty()]
Expand Down Expand Up @@ -28578,6 +28596,14 @@ function Set-NsxFirewallRule {
$_FirewallRule.action = $action
}

if ( $PsBoundParameters.ContainsKey('ApplyToDfw') -or $PsBoundParameters.ContainsKey('ApplyToAllEdges') -or $PsBoundParameters.ContainsKey('appliedTo')){
$appliedToList = New-NsxAppliedToListNode -itemList $appliedTo -xmlDoc $_FirewallRule.SchemaInfo.OwnerDocument -ApplyToDFW:$ApplyToDFW -ApplyToAllEdges:$ApplyToAllEdges
if ( $appliedToList ) {
$_FirewallRule.removeChild($_FirewallRule.appliedToList)
$_FirewallRule.AppendChild($appliedToList)
}

}

if ( $PsBoundParameters.ContainsKey('comment') ) {
if ( (Invoke-XPathQuery -QueryMethod SelectSingleNode -Node $_FirewallRule -Query 'descendant::notes')) {
Expand Down Expand Up @@ -34731,7 +34757,7 @@ function Set-NsxLoadBalancerPool {

if ( $PsBoundParameters.ContainsKey('name') ) {
$_LoadBalancerPool.name = $name
$poolname = $name
$poolname = $name
}

if ( $PsBoundParameters.ContainsKey('Description') ) {
Expand Down