vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 90 forks source link

Get-NsxLogicalRouterInterfaceAddress missing!? #163

Open heitmanr opened 7 years ago

heitmanr commented 7 years ago

PowerCLI C:> Get-NsxLogicalRouter | Get-NsxLogicalRouterInterface -name "T_DLR"

label           : 138800000002/vNic_2
name            : T_DLR
addressGroups   : addressGroups
mtu             : 1500
type            : uplink
isConnected     : true
isSharedNetwork : false
index           : 2
connectedToId   : virtualwire-4
connectedToName : T_DLR
logicalRouterId : edge-47
---

=> "addressGroups" listed, but no address    
=> the API_Call provides the information!?

https://192.168.47.200/api/4.0/edges/edge-47/interfaces

<?xml version="1.0" encoding="UTF-8"?>
<interfaces>
    <interface>
        <label>138800000002/vNic_2</label>
        <name>T_DLR</name>
        <addressGroups>
            <addressGroup>
                <primaryAddress>172.22.0.1</primaryAddress>
                <subnetMask>255.255.255.0</subnetMask>
                <subnetPrefixLength>24</subnetPrefixLength>
            </addressGroup>
        </addressGroups>
        <mtu>1500</mtu>
        <type>uplink</type>
        <isConnected>true</isConnected>
        <isSharedNetwork>false</isSharedNetwork>
        <index>2</index>
        <connectedToId>virtualwire-4</connectedToId>
        <connectedToName>T_DLR</connectedToName>
    </interface>
    ...

or...

is it similar to

Function Get-NsxEdgeInterface PowerNSX Function Get-NsxEdgeInterfaceAddress PowerNSX

that Function Get-NsxLogicalRouterInterface PowerNSX exists but ... the Function "Get-NsxLogicalRouterInterfaceAddress" isn't there!?


vScripter commented 7 years ago

@ron4all The markdown examples seem to have gotten minced but I think I understand what you are asking.

The addressGroups is actually more than just a value; it's the XML parent node which contains the interface address details.

Here are a few examples of how you can further extract:

In the example below, I am testing against a DLR named t-dlr-prod and inspecting the DLR interface named transit:

Grab the DLR

$dlr = Get-NsxLogicalRouter -Name 't-dlr-prod'

This will produce output similar to what you listed

$dlr|Get-NsxLogicalRouterInterface -Name 'transit'

Unroll addressGroups to list the address group details (preferred method)

($dlr|Get-NsxLogicalRouterInterface -Name 'transit').addressGroups.addressGroup

primaryAddress     : 192.168.8.1
subnetMask         : 255.255.255.248
subnetPrefixLength : 29
you can also achieve it, this way
($dlr|Get-NsxLogicalRouterInterface -Name 'transit' | select -ExpandProperty addressGroups | select -ExpandProperty addressGroup)
nmbradford commented 7 years ago

Thanks for jumping in on this @vScripter - perfect answer - although Ill leave this open to create the missing Get-NsxLogicalRouterIInterfaceAddress cmdlet.

nmbradford commented 7 years ago

pushing to 2.2 as non critical