Updates to Set-NSXTraceFlow

Updates to Set-NSXTraceFlow. Added more comment and aligned variable names with api
This commit is contained in:
AndyG
2018-09-12 13:45:38 -04:00
parent a753d8251b
commit 75a2562d97

View File

@@ -378,21 +378,21 @@ Function Set-NSXTTraceFlow {
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateSet("UNICAST")] [ValidateSet("UNICAST")]
[string] [string]
$TrafficType = "UNICAST", $transport_type = "UNICAST",
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
#[ValidateScript({Get-NSXTLogicalPort -Id $_}] #[ValidateScript({Get-NSXTLogicalPort -Id $_}]
[string] [string]
$LPORTID, $lport_id,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[ValidateScript({$_ -match [IPAddress]$_})] [ValidateScript({$_ -match [IPAddress]$_})]
[string] [string]
$SIPAddr, $src_ip,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
@@ -403,14 +403,14 @@ Function Set-NSXTTraceFlow {
} }
})] })]
[string] [string]
$SMAC, $src_mac,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[ValidateScript({$_ -match [IPAddress]$_ })] [ValidateScript({$_ -match [IPAddress]$_ })]
[string] [string]
$DIPAddr, $dst_ip,
[parameter(Mandatory=$true, [parameter(Mandatory=$true,
ValueFromPipeline=$true, ValueFromPipeline=$true,
ParameterSetName='Parameter Set VM Type')] ParameterSetName='Parameter Set VM Type')]
@@ -421,7 +421,7 @@ Function Set-NSXTTraceFlow {
} }
})] })]
[string] [string]
$DMAC) $dst_mac)
Begin Begin
{ {
@@ -477,26 +477,22 @@ Function Set-NSXTTraceFlow {
$this.timeout = '15000' $this.timeout = '15000'
} }
} }
[traceflow_request]$traceflow_request = [traceflow_request]::new()
$traceflow_request.lport_id = '8afcd58a-4bdc-483c-97a5-c5f08df7f772'
$traceflow_request.timeout = '15000'
$traceflow_request.packet.routed = 'true'
$traceflow_request.packet.transport_type = 'UNICAST'
$traceflow_request.packet.resource_type = 'FieldsPacketData'
$traceflow_request.packet.frame_size = '128'
$traceflow_request.packet.eth_header.src_mac = '00:50:56:b3:90:e3'
$traceflow_request.packet.eth_header.dst_mac = '00:50:56:b3:0e:91'
$traceflow_request.packet.ip_header.src_ip = '15.128.160.20'
$traceflow_request.packet.ip_header.dst_ip = '15.128.160.24'
} }
Process Process
{ {
[traceflow_request]$traceflow_request = [traceflow_request]::new()
$traceflow_request.lport_id = $lport_id
$traceflow_request.packet.transport_type = $transport_type
$traceflow_request.packet.eth_header.src_mac = $src_mac
$traceflow_request.packet.eth_header.dst_mac = $dst_mac
$traceflow_request.packet.ip_header.src_ip = $src_ip
$traceflow_request.packet.ip_header.dst_ip = $dst_ip
try try
{ {
# This does not work, ignores eth_header,ip_header etc.. Not clear why!? # This does not work, bug report submitted to PowerCLI team
$NSXTraceFlow = $NSXTraceFlowService.create($traceflow_request) $NSXTraceFlow = $NSXTraceFlowService.create($traceflow_request)
} }
@@ -509,6 +505,7 @@ Function Set-NSXTTraceFlow {
End End
{ {
# Likely don't need this and will replace with write-output $NSXTraceFlow but I can't test right now due to bug
if ($NSXTraceFlow) if ($NSXTraceFlow)
{ {
Get-NSXttraceflow Get-NSXttraceflow
@@ -642,10 +639,9 @@ Function Get-NSXTRoutingTable {
{ {
$NSXTRoutingTable = [NSXTRoutingTable]::new() $NSXTRoutingTable = [NSXTRoutingTable]::new()
# this does not work, bug report submitted to PowerCLI team
$NSXTRoutingTable = $NSXTRoutingTableService.list($Logical_router_id, $transport_node_id) $NSXTRoutingTable = $NSXTRoutingTableService.list($Logical_router_id, $transport_node_id)
#$NSXTRoutingTable = $NSXTRoutingTableService.list("ca02cb69-0210-4f34-8164-42943a1cc974","309fda89-3439-40ff-996e-b7eb2ec69ace")
write-output $NSXTRoutingTable write-output $NSXTRoutingTable
} }
} }