Skip to content

Commit

Permalink
System: Add Contact/Description/Location (and Tests)
Browse files Browse the repository at this point in the history
Fix #55
  • Loading branch information
alagoutte committed Sep 5, 2023
1 parent 1c79dad commit 52a90c3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
30 changes: 30 additions & 0 deletions PowerArubaCX/Public/System.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ function Set-ArubaCXSystem {
#add Check of timezone ? very long list..
[string]$timezone,
[Parameter (Mandatory = $false)]
[string]$contact,
[Parameter (Mandatory = $false)]
[string]$description,
[Parameter (Mandatory = $false)]
[string]$location,
[Parameter (Mandatory = $false)]
[switch]$use_pipeline,
[Parameter (Mandatory = $False)]
[ValidateNotNullOrEmpty()]
Expand Down Expand Up @@ -138,6 +144,30 @@ function Set-ArubaCXSystem {
if ( $PsBoundParameters.ContainsKey('timezone') ) {
$_system.timezone = $timezone
}
if ( $PsBoundParameters.ContainsKey('contact') ) {
if ($_system.other_config.system_contact) {
$_system.other_config.system_contact = $contact
}
else {
$_system.other_config | Add-member -name "system_contact" -membertype NoteProperty -Value $contact
}
}
if ( $PsBoundParameters.ContainsKey('description') ) {
if ($_system.other_config.system_description) {
$_system.other_config.system_description = $description
}
else {
$_system.other_config | Add-member -name "system_description" -membertype NoteProperty -Value $description
}
}
if ( $PsBoundParameters.ContainsKey('location') ) {
if ($_system.other_config.system_location) {
$_system.other_config.system_location = $location
}
else {
$_system.other_config | Add-member -name "system_location" -membertype NoteProperty -Value $location
}
}

if ($PSCmdlet.ShouldProcess($_system.hostname, 'Configure System Settings')) {
Invoke-ArubaCXRestMethod -method "PUT" -body $_system -uri $uri -connection $connection
Expand Down
35 changes: 35 additions & 0 deletions Tests/integration/System.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,41 @@ Describe "Configure System" {
$sys.other_config.banner | Should -Be "PowerArubaCX-Banner"
}

It "Change System contact (Add if needed)" {
Set-ArubaCXSystem -Contact "PowerArubaCX-Contact"
$sys = Get-ArubaCXSystem
$sys.other_config.system_contact | Should -Be "PowerArubaCX-Contact"
}

It "Change System contact" {
Set-ArubaCXSystem -Contact "PowerArubaCX-Contact2"
$sys = Get-ArubaCXSystem
$sys.other_config.system_contact | Should -Be "PowerArubaCX-Contact2"
}

It "Change System description (Add if needed)" {
Set-ArubaCXSystem -Description "PowerArubaCX-Description"
$sys = Get-ArubaCXSystem
$sys.other_config.system_description | Should -Be "PowerArubaCX-Description"
}

It "Change System description" {
Set-ArubaCXSystem -description "PowerArubaCX-Description2"
$sys = Get-ArubaCXSystem
$sys.other_config.system_description | Should -Be "PowerArubaCX-Description2"
}

It "Change System location (Add if needed)" {
Set-ArubaCXSystem -location "PowerArubaCX-Location"
$sys = Get-ArubaCXSystem
$sys.other_config.system_location | Should -Be "PowerArubaCX-Location"
}

It "Change System location" {
Set-ArubaCXSystem -location "PowerArubaCX-Location2"
$sys = Get-ArubaCXSystem
$sys.other_config.system_location | Should -Be "PowerArubaCX-Location2"
}
AfterAll {
$default_sys | Set-ArubaCXSystem -use_pipeline
#Reverse CheckPoint ?
Expand Down

0 comments on commit 52a90c3

Please sign in to comment.