Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkDevice (NAD): Allow SNMP parameters #76

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Changes from 1 commit
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
38 changes: 38 additions & 0 deletions PowerArubaCP/Public/NetworkDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function Add-ArubaCPNetworkDevice {

Add Network Device SW2 with COA Capability on port 5000

.EXAMPLE
Add-ArubaCPNetworkDevice -name SW3 -ip_address 192.0.2.3 -radius_secret MySecurePassword -vendor Cisco -snmp_version V2C -community_string CommString

Add Network Device SW3 with a snmp-read community string from vendor Cisco

.EXAMPLE
Add-ArubaCPNetworkDevice -name SW3 -ip_address 192.0.2.3 -radius_secret MySecurePassword -vendor Cisco -tacacs_secret MySecurePassword

Expand Down Expand Up @@ -53,6 +58,10 @@ function Add-ArubaCPNetworkDevice {
[Parameter (Mandatory = $true)]
[string]$radius_secret,
[Parameter (Mandatory = $false)]
[string]$snmp_version,
[Parameter (Mandatory = $false)]
[string]$community_string,
[Parameter (Mandatory = $false)]
[string]$tacacs_secret,
[Parameter (Mandatory = $true)]
[string]$vendor_name,
Expand Down Expand Up @@ -124,6 +133,15 @@ function Add-ArubaCPNetworkDevice {
$_nad | add-member -name "attributes" -membertype NoteProperty -Value $attributes
}

if ($PsBoundParameters.ContainsKey('snmp_version')) {
$snmp_read = @{
snmp_version = $snmp_version
community_string = $community_string
zone_name = "default"
}
$_nad | add-member -name "snmp_read" -membertype NoteProperty -Value $snmp_read
}

$nad = invoke-ArubaCPRestMethod -method "POST" -body $_nad -uri $uri -connection $connection
$nad
}
Expand Down Expand Up @@ -273,6 +291,12 @@ function Set-ArubaCPNetworkDevice {

Set Vendor Name to Cisco and (re)configure TACACS Secret of NAD-PowerArubaCP

.EXAMPLE
$nad = Get-ArubaCPNetworkDevice -name NAD-PowerArubaCP
PS > $nad | Set-ArubaCPNetworkDevice -snmp_version V2C -community_string MyComm

Set SNMP version and community string of NAD-PowerArubaCP

.EXAMPLE
$nad = Get-ArubaCPNetworkDevice -name NAD-PowerArubaCP
PS > $nad | Set-ArubaCPNetworkDevice -coa_capable -coa_port 5000
Expand All @@ -297,6 +321,10 @@ function Set-ArubaCPNetworkDevice {
[Parameter (Mandatory = $false)]
[string]$radius_secret,
[Parameter (Mandatory = $false)]
[string]$snmp_version,
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
[Parameter (Mandatory = $false)]
[string]$community_string,
[Parameter (Mandatory = $false)]
[string]$tacacs_secret,
[Parameter (Mandatory = $false)]
[string]$vendor_name,
Expand Down Expand Up @@ -345,6 +373,16 @@ function Set-ArubaCPNetworkDevice {
$_nad | add-member -name "radius_secret" -membertype NoteProperty -Value $radius_secret
}

if ($PsBoundParameters.ContainsKey('snmp_version')) {
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
$snmp_read = @{
snmp_version = $snmp_version
alagoutte marked this conversation as resolved.
Show resolved Hide resolved
community_string = $community_string
zone_name = "default"
}
$_nad | add-member -name "snmp_read" -membertype NoteProperty -Value $snmp_read
}


if ( $PsBoundParameters.ContainsKey('tacacs_secret') ) {
$_nad | add-member -name "tacacs_secret" -membertype NoteProperty -Value $tacacs_secret
}
Expand Down