Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtboren committed Jan 3, 2018
2 parents 5052235 + 7fcba9c commit 68179ca
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 27 deletions.
5 changes: 3 additions & 2 deletions ToDoAndNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


### Need to make:
- Examples/docs
- Tests
- Tests (partial, currently, written for interactive test, not fully automated)

### Maybe eventually add/update:
- `Copy-VNVDTrafficRule -Rule -Ruleset <rulesettowhichtocopy>`
Expand All @@ -13,6 +12,7 @@
- `Set-VNVDTrafficRuleSet -Precedence -Rule`
- to allow for the overwriting of the rules in the ruleset with just the new Rule(s) specified, and to allow setting of Precedence (though, may only ever be one TrafficRuleSet per vDPortgroup)
- add `-RunAsync` to `New-VNVDTrafficRule`, `Remove-VNVDTrafficRule`, and any other cmdlet where it makes sense
- add tidbit to `makeExamplesMD.ps1` that wraps long lines at ~105 characters or so, so that web presentation of the .md does not require reader to scroll long examples

### Done (to at least some extent -- some may have further features to implement):
- `Get-VNVDTrafficFilterPolicyConfig`
Expand All @@ -34,6 +34,7 @@
- `Get-VNVDTrafficRuleAction`
- `Set-VNVDTrafficRuleSet -Enabled -TrafficRuleset`
- define cmdlet `ConfirmImpact` to High
- Examples/docs

Quick examples:
## Get
Expand Down
2 changes: 1 addition & 1 deletion Update-ThisModuleManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ begin {
$hshModManifestParams = @{
# Confirm = $true
Path = $strFilespecForPsd1
ModuleVersion = "0.5.0"
ModuleVersion = "1.0.0"
CompanyName = 'vNugglets for the VMware PowerCLI community'
Copyright = "MIT License"
Description = "Module with functions for managing VMware vSphere Virtual Distributed Networking components like traffic filtering and marking"
Expand Down
5 changes: 5 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: vNugglets.VDNetworking
description: A PowerShell module for VMware vSphere Virtual Distributed Networking Management
google_analytics:
show_downloads: true
theme: jekyll-theme-cayman
102 changes: 102 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
### Examples for vNugglets.VDNetworking PowerShell module for VMware vSphere Virtual Distributed Networking management

#### `Get-VNVDTrafficFilterPolicyConfig`: Get the VDTrafficFilterPolicy configuration for the given VDPortgroup(s) from VDSwitch(es)

```PowerShell
## Get the TrafficFilter policy config for the given VDPortgroup
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig
```

#### `Get-VNVDTrafficRule`: Get the VDTrafficRule for the TrafficRuleset from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)

```PowerShell
## Get the traffic rules from the TrafficeRuleset, which was gotten from the vDPG's TrafficFilterPolicyConfig
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule
## Get traffic rules whose name is like "myTestRule*"
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule myTestRule*
```

#### `Get-VNVDTrafficRuleAction`: Get the VDTrafficRule Action for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)

```PowerShell
## Get the traffic rules action from the traffic rules from the TrafficeRuleset property of the TrafficFilterPolicyConfig
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRule | Get-VNVDTrafficRuleAction
```

#### `Get-VNVDTrafficRuleQualifier`: Get the VDTrafficRule Qualifier for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)

```PowerShell
## Get the traffic rules qualifiers from the traffic rules from the TrafficeRuleset property of the TrafficFilterPolicyConfig
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRule | Get-VNVDTrafficRuleQualifier
```

#### `Get-VNVDTrafficRuleSet`: Get the DvsTrafficRuleset for the given VDTrafficFilterPolicy configuration from VDPortgroup(s), or from VDPortgroup(s) directly

```PowerShell
## Get the traffic ruleset from the TrafficFilterPolicyConfig object of a given vDPG. Can also get the ruleset from just the vDPG, but this "from TrafficFilterPolicyConfig" method is to help show the relationship between the vDPG, the TrafficFilterPolicyConfig, and the TrafficRuleset
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet
## Get the traffic ruleset directly from the given vDPG
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficRuleSet
```

#### `New-VNVDTrafficRule`: Make new Traffic Rule and add it to the given Traffic Ruleset of a vDPortgroup traffic filter policy

```PowerShell
## Create a new Traffic Rule that has two Qualifiers and add it to the given TrafficRuleset from the given vDPortgroup. The new Traffic Rule allows vMotion traffic from given source network
Get-VDPortGroup myVDPG0 | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "Allow vMotion from source network" -Action (New-VNVDTrafficRuleAction -Allow) -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType vMotion), (New-VNVDTrafficRuleQualifier -SourceIpAddress 10.0.0.0/8)
## Create a new Traffic Rule that has two Qualifiers and add it to the given TrafficRuleset from the given vDPortgroup. The new Traffic Rule adds a DSCP tag with value 8 to VM traffic from given source IP
Get-VDPortGroup myVDPG0 | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "Apply DSCP tag to VM traffic from given address" -Action (New-VNVDTrafficRuleAction -DscpTag 8) -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType virtualMachine), (New-VNVDTrafficRuleQualifier -SourceIpAddress 172.16.1.2) -Direction outgoingPackets
```

#### `New-VNVDTrafficRuleAction`: Make new VMware.Vim.DvsNetworkRuleAction, for use in creating vDPortgroup traffic filter policy rule. Currently supports creating Rule Actions of types DvsAcceptNetworkRuleAction ("Allow"), DvsDropNetworkRuleAction, and DvsUpdateTagNetworkRuleAction

```PowerShell
## Create a new DvsAcceptNetworkRuleAction object that will specify an action of "Allow packet"
New-VNVDTrafficRuleAction -Allow
## Create a new DvsDropNetworkRuleAction object that will specify an action of "Drop packet"
New-VNVDTrafficRuleAction -Drop
## Create a new DvsUpdateTagNetworkRuleAction object that will specify an action of "tag with DSCP value of 8, and clear the QoS tag of packet"
New-VNVDTrafficRuleAction -DscpTag 8 -QosTag 0
```

#### `New-VNVDTrafficRuleQualifier`: Make new VMware.Vim.DvsNetworkRuleQualifier, for use in creating vDPortgroup traffic filter policy rule

```PowerShell
## Create a new DvsSystemTrafficNetworkRuleQualifier for traffic that is vMotion
New-VNVDTrafficRuleQualifier -SystemTrafficType vMotion
## Create a new DvsSystemTrafficNetworkRuleQualifier for traffic that is _not_ Management traffic
New-VNVDTrafficRuleQualifier -SystemTrafficType Management -Negate
## Create a new DvsIpNetworkRuleQualifier for traffice from the given source IP that is _not_ to the given destination network, using TCP (6) protocol, and that is from source ports of 443 or 444
New-VNVDTrafficRuleQualifier -SourceIpAddress 172.16.1.2 -DestinationIpAddress 10.0.0.0/8 -NegateDestinationIpAddress -Protocol 6 -SourceIpPort 443-444
## Create a new DvsMacNetworkRuleQualifier for traffic from the source MAC address, that is _not_ to the destination MAC, that is using EtherType 0x8922, and that is not on VLAN 10
New-VNVDTrafficRuleQualifier -SourceMacAddress 00:00:56:01:23:45 -DestinationMacAddress 00:00:56:78:90:12 -NegateDestinationMacAddress -EtherTypeProtocol 0x8922 -VlanId 10 -NegateVlanId
## Create a new DvsMacNetworkRuleQualifier for traffic from the any source MAC address in the given MAC range and that is on VLAN 22
New-VNVDTrafficRuleQualifier -SourceMacAddress 00:A0:C9:14:C8:29/FF:FF:00:FF:00:FF -VlanId 22
```

#### `Remove-VNVDTrafficRule`: Remove a Traffic Rule from the given Traffic Ruleset of a vDPortgroup traffic filter policy

```PowerShell
## Get the TrafficRules named like "test*" from the TrafficRuleSet for the given vDPortGroup and delete them
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule -Name test* | Remove-VNVDTrafficRule
```

#### `Set-VNVDTrafficRuleSet`: Set attributes on the DvsTrafficRuleset (like Enable/Disable it) for the given TrafficRuleSet

```PowerShell
## Get the traffic ruleset from the TrafficFilterPolicyConfig object of a given vDPG and Enable it
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet | Set-VNVDTrafficRuleSet -Enabled
## Get the traffic ruleset from the given vDPG and Disable it
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficRuleSet | Set-VNVDTrafficRuleSet -Enabled:$false
```

3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### vNugglets.VDNetworking PowerShell module for VMware vSphere Virtual Distributed Networking management

Examples for the cmdlets (or, see each cmdlet's help for the examples): [examples.md](examples.md)
16 changes: 16 additions & 0 deletions makeExamplesMd.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## some code to put the cmdlets' examples into MD format for, say, examples.md in the docs

"### Examples for vNugglets.VDNetworking PowerShell module for VMware vSphere Virtual Distributed Networking management`n"
Get-Command -Module vNugglets.VDNetworking -PipelineVariable oThisCommand | Foreach-Object {
## get the full help for this cmdlet
$oHelp_ThisCommand = Get-Help -Full -Name $oThisCommand.Name
## make a string with the example description(s) and example code(s) for this cmdlet
$strExampleCodeBlock = ($oHelp_ThisCommand.examples.example | Foreach-Object {
"`n## {0}`n{1}" -f ($($_.remarks.Text | Where-Object {-not [System.String]::IsNullOrEmpty($_)}) -join "`n"), $_.code
}) -join "`n"
## make a string that has the cmdlet name and description followed by a code block with example(s)
"#### ``{0}``: {1}`n`n``````PowerShell{2}`n```````n" -f `
$oThisCommand.Name,
$oHelp_ThisCommand.Description.Text,
$strExampleCodeBlock
} ## end Foreach-Object
10 changes: 9 additions & 1 deletion testing/vNugglets.VDNetworking.Tests_Get.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,28 @@ $strGuidForThisTest = (New-Guid).Guid
$oTestVDSwitch = New-VDSwitch -Name "vNuggsTestVDS_toDelete_${strGuidForThisTest}" -Location $oDatacenterToUse -Verbose

## create a new vDPortgroup
$oTestVDPG = $oTestVDSwitch | New-VDPortgroup -Name "vNuggsTestVDPG_toDelete_${strGuidForThisTest}" -Notes "testing vDPG" -Verbose
$oTestVDPG = New-VDPortgroup -VDSwitch $oTestVDSwitch -Name "vNuggsTestVDPG_toDelete_${strGuidForThisTest}" -Notes "testing vDPG" -Verbose

<# tests
- get Traffic Fileter Policy config
$oTestVDPG | Get-VNVDTrafficFilterPolicyConfig
- get TrafficRuleSet (should be disabled)
$oTestVDPG | Get-VNVDTrafficRuleSet
- get TrafficRule (should be 0)
- create three TrafficRules
$oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule0_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -Allow) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType faultTolerance -NegateSystemTrafficType), (New-VNVDTrafficRuleQualifier -SourceIpAddress 172.16.10.0/24 -DestinationIpAddress 10.0.0.0/8 -SourceIpPort 443-444)
$oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule1_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -QosTag 5 -DscpTag 23) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType vsan)
$oTestVDPG | Get-VNVDTrafficRuleSet | New-VNVDTrafficRule -Name "testRule2_toDelete_${strGuidForThisTest}" -Action (New-VNVDTrafficRuleAction -QosTag 7 -DscpTag 30) -Direction both -Qualifier (New-VNVDTrafficRuleQualifier -SystemTrafficType vdp), (New-VNVDTrafficRuleQualifier -DestinationIpAddress 172.16.100.0/24)
- get TrafficRuleSet (should have three TrafficRules)
$oTestVDPG | Get-VNVDTrafficRuleSet
- get TrafficRules (should be three)
$oTestVDPG | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule | Measure-Object
- remove two TrafficRules
$oTestVDPG | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule | Select-Object -Last 2 | Remove-VNVDTrafficRule
- get TrafficRuleSet (should have one TrafficRule)
$oTestVDPG | Get-VNVDTrafficRuleSet
- get TrafficRules (should be one)
$oTestVDPG | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule | Measure-Object
#>

## remove the VDSwitch when done
Expand Down
15 changes: 8 additions & 7 deletions vNugglets.VDNetworking/GetItems.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function Get-VNVDTrafficFilterPolicyConfig {
<# .Description
Function to get the VDTrafficFilterPolicy configuration for the given VDPortgroup(s) from VDSwitch(es). The VDTrafficFilterPolicy is the item that can be enabled/disabled at the vDPG level.
Get the VDTrafficFilterPolicy configuration for the given VDPortgroup(s) from VDSwitch(es)
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig
Get the TrafficFilter policy config for the given VDPortgroup
.Outputs
VNVDTrafficFilterPolicyConfig with properties with at least VMware.Vim.DvsTrafficFilterConfig and VMware.Vim.DistributedVirtualPortgroup for the TrafficFilter policy confi
VNVDTrafficFilterPolicyConfig with properties with at least VMware.Vim.DvsTrafficFilterConfig and VMware.Vim.DistributedVirtualPortgroup for the TrafficFilter policy config
#>
[CmdletBinding()]
[OutputType([VNVDTrafficFilterPolicyConfig])]
Expand All @@ -30,7 +31,7 @@ function Get-VNVDTrafficFilterPolicyConfig {

function Get-VNVDTrafficRuleSet {
<# .Description
Function to get the DvsTrafficRuleset for the given VDTrafficFilterPolicy configuration from VDPortgroup(s), or from VDPortgroup(s) directly.
Get the DvsTrafficRuleset for the given VDTrafficFilterPolicy configuration from VDPortgroup(s), or from VDPortgroup(s) directly
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet
Expand Down Expand Up @@ -93,15 +94,15 @@ function Get-VNVDTrafficRuleSet {

function Get-VNVDTrafficRule {
<# .Description
Function to get the VDTrafficRule for the TrafficRuleset from the given VDTrafficFilterPolicy configuration from VDPortgroup(s).
Get the VDTrafficRule for the TrafficRuleset from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule
Get the traffic rules from the TrafficeRuleset, which was gotten from the vDPG's TrafficFilterPolicyConfig
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRuleSet | Get-VNVDTrafficRule myTestRule*
Get traffic rules whose name is like "myTestRule*".
Get traffic rules whose name is like "myTestRule*"
.Outputs
VNVDTrafficRule with at least properties for VMware.Vim.DvsTrafficRule and VMware.Vim.DistributedVirtualPortgroup for the Traffic rule set rule
Expand Down Expand Up @@ -144,7 +145,7 @@ function Get-VNVDTrafficRule {

function Get-VNVDTrafficRuleQualifier {
<# .Description
Function to get the VDTrafficRule Qualifier for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s).
Get the VDTrafficRule Qualifier for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRule | Get-VNVDTrafficRuleQualifier
Expand Down Expand Up @@ -179,7 +180,7 @@ function Get-VNVDTrafficRuleQualifier {

function Get-VNVDTrafficRuleAction {
<# .Description
Function to get the VDTrafficRule Action for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s).
Get the VDTrafficRule Action for the TrafficRule from the given VDTrafficFilterPolicy configuration from VDPortgroup(s)
.Example
Get-VDSwitch -Name myVDSw0 | Get-VDPortGroup -Name myVDPG0 | Get-VNVDTrafficFilterPolicyConfig | Get-VNVDTrafficRule | Get-VNVDTrafficRuleAction
Expand Down
Loading

0 comments on commit 68179ca

Please sign in to comment.