Public/lldp-neighbor.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-ArubaCXLLDPNeighbor {

    <#
      .SYNOPSIS
      Get list of LLDP Neighbor

      .DESCRIPTION
      Get list of LLDP Neighbor (Chassis name, IP Address, description...)

      .EXAMPLE
      Get-ArubaCXLLDPNeighbor

      Get LLDP Neighbor information of ALL Ports

      .EXAMPLE
      Get-ArubaCXLLDPNeighbor 1/1/1

      Get LLDP Neighbor information of port 1/1/1

    #>

    Param(
        [Parameter(Mandatory = $false, position = 1)]
        [String]$neighbor = "*",
        [Parameter(Mandatory = $false)]
        [ValidateRange(1, 4)]
        [Int]$depth,
        [Parameter(Mandatory = $false)]
        [ValidateSet("configuration", "status", "statistics", "writable")]
        [String]$selector,
        [Parameter(Mandatory = $false)]
        [String[]]$attributes,
        [Parameter(Mandatory = $false)]
        [switch]$vsx_peer,
        [Parameter (Mandatory = $False)]
        [ValidateNotNullOrEmpty()]
        [PSObject]$connection = $DefaultArubaCXConnection
    )

    Begin {
    }

    Process {

        $invokeParams = @{ }
        if ( $PsBoundParameters.ContainsKey('depth') ) {
            $invokeParams.add( 'depth', $depth )
        }
        if ( $PsBoundParameters.ContainsKey('selector') ) {
            $invokeParams.add( 'selector', $selector )
        }
        if ( $PsBoundParameters.ContainsKey('attributes') ) {
            $invokeParams.add( 'attributes', $attributes )
        }
        if ( $PsBoundParameters.ContainsKey('vsx_peer') ) {
            $invokeParams.add( 'vsx_peer', $true )
        }

        $neighbor = $neighbor -replace '/', '%2F'
        $uri = "system/interfaces/$neighbor/lldp_neighbors"

        $response = Invoke-ArubaCXRestMethod -uri $uri -method 'GET' -connection $connection  @invokeParams
        $response
    }

    End {
    }
}