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

Add Copy configuration function #44

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
89 changes: 89 additions & 0 deletions PowerArubaCX/Public/Configuration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
function Get-ArubaCXConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add copyright


<#
.SYNOPSIS
Get Aruba CX running or startup-configuration

.DESCRIPTION
Get the startup-config or running-config and copy it to a remote location

.EXAMPLE
Get-ArubaCXConfiguration -local running -remote sftp://192.0.2.1/backups_switchs/arubacx/ -type cli -vrf mgmt

Get the running-config and copy it to the remote location 192.0.2.1/backups_switchs/arubacx using sftp, in cli format via thr mgmt vrf
#>

Param(
[Parameter(Mandatory = $true)]
[ValidateSet("running", "startup")]
[string]$local,
[Parameter(Mandatory = $false)]
[string]$remote,
[Parameter(Mandatory = $false)]
[ValidateSet("cli", "json")]
[string]$type,
[Parameter(Mandatory = $false)]
[string]$vrf,
[Parameter (Mandatory = $False)]
[ValidateNotNullOrEmpty()]
[PSObject]$connection = $DefaultArubaCXConnection
)

Begin {
}

Process {

$remote = $remote.Replace(":", "%3A")
$remote = $remote.Replace("/", "%2F")
$remote = $remote.Replace("@", "%40")

$uri = "fullconfigs/${local}-config/?to=${remote}&type=${type}&vrf=${vrf}"

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

End {
}
}

function Get-ArubaCXConfigurationName {

<#
.SYNOPSIS
Get Aruba CX running or startup-configuration by the name

.DESCRIPTION
Get the startup-config or running-config

.EXAMPLE
Get-ArubaCXConfigurationName -name running

Get the running-config
#>

Param(
[Parameter(Mandatory = $true)]
[ValidateSet("running", "startup", IgnoreCase = $true)]
[string]$name,
[Parameter (Mandatory = $False)]
[ValidateNotNullOrEmpty()]
[PSObject]$connection = $DefaultArubaCXConnection
)

Begin {
}

Process {

$name = $name.ToLower()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need if you use IgnoreCase = $true

$uri = "fullconfigs/${name}-config"

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

End {
}
}