Documentation

SwitchAPI

Switch ArubaOS API

Tags
link

Aruba ressource downloader, you can find API documentation in the product page.

Table of Contents

$cache  : array<string|int, mixed>
$config  : Config
$token  : string
$cache  : mixed
$config  : Config
$token  : mixed
__construct()  : mixed
Constructor takes care of checking and registering switch's data and login to the API
__destruct()  : mixed
Destructor takes care of logout
blinkLedLocator()  : Return
Turn on or off the locator LED. If no duration is set, default to 30 minutes.
cli()  : mixed
Execute a CLI command.
createVlan()  : bool
Create a VLAN on the switch.
deleteVlan()  : bool
Delete a VLAN on the switch.
disablePoePort()  : bool
Disable POE on a port.
disablePort()  : bool
Disable a port.
enablePoePort()  : bool
Enable POE on a port.
enablePort()  : bool
Enable a port.
getArpEntryFromIP()  : array<string|int, mixed>
Retrieve an ARP table entry from an IP.
getArpEntryFromMAC()  : array<string|int, mixed>
Retrieve an ARP table entry from a MAC address.
getArpEntryFromVLAN()  : array<string|int, mixed>
Retrieve an ARP table entry from a VLAN.
getArpTable()  : array<string|int, mixed>
Retrieve ARP table (capped to 1K entries right now).
getBanner()  : array<string|int, mixed>
Get switch's banners.
getMacAddressInfo()  : mixed
Get infos about a MAC address.
getMacTable()  : Return
Get MAC table of the switch.
getMacTablePort()  : Return
Get MAC table of a port.
getManagementUser()  : array<string|int, mixed>
Get one device management user.
getManagementUsers()  : array<string|int, mixed>
Get all device management users.
getPortsPOEStatus()  : array<string|int, mixed>
Get all ports POE status.
getPortsStatus()  : array<string|int, mixed>
Get all ports status.
getRunningConfig()  : mixed
Get runnning configuration.
getStackGlobalSystemStatus()  : array<string|int, mixed>
Get switch's system status (firmware version, base address MAC, ...). Works only for stacked switchs.
getStackMemberSystemStatus()  : array<string|int, mixed>
Get switch's system status (model, SN, ...). Works only for stacked switchs.
getSystemStatus()  : array<string|int, mixed>
Get switch's system status (model, SN, firmware version, ...). Works only for standalone switchs.
getTVlanPort()  : mixed
Get the tagged vlan for one port.
getUVlanPort()  : mixed
Get the untagged vlan for one port.
getVlanPorts()  : mixed
Get list of ports for one vlan.
getVlans()  : mixed
Get all VLANs on the switch.
getVlansPort()  : mixed
Get list of vlans affected to one port.
getVlansPorts()  : mixed
Get list of vlans/ports association.
isPortEnabled()  : bool
Check if a port is enabled.
isPortUp()  : bool
Check if a port is up.
isStack()  : bool
Is the switch a stacked switches ?
ping()  : mixed
Ping an IP or a hostname.
portPoeStatus()  : Return
Check if a port is POE enabled.
restartPoePort()  : bool
Restart POE on a port.
restartPort()  : bool
Disable a port 5sec and re-enable it. Be careful when disabling links between switchs or firewalls .
setBanner()  : array<string|int, mixed>
Set switch's banners.
setTVlanPort()  : bool
Set tagged VLAN(s) on port.
setUVlanPort()  : bool
Set untagged VLAN on port.
updateManagementUserPassword()  : array<string|int, mixed>
Change the password of a management user.
updateVlan()  : bool
Update a VLAN on the switch.
curlRequest()  : mixed
Method to request the switch's API
login()  : bool
Login in the switch.
logout()  : mixed
Logout

Properties

$cache

public array<string|int, mixed> $cache

Variable use to cache information.

$token

public string $token

Authentication token kept in cache.

Methods

__construct()

Constructor takes care of checking and registering switch's data and login to the API

public __construct(Config $config) : mixed
Parameters
$config : Config

Object containing all necessary configuration.

Return values
mixed

__destruct()

Destructor takes care of logout

public __destruct() : mixed
Return values
mixed

blinkLedLocator()

Turn on or off the locator LED. If no duration is set, default to 30 minutes.

public blinkLedLocator(int $mode[, int $duration = 30 ]) : Return
Parameters
$mode : int

0 : off, 1 : on, 2 : blink.

$duration : int = 30

Duration of the mode wanted in minutes.

Return values
Return

the configuration if successful, FALSE if it failed.

cli()

Execute a CLI command.

public cli(string $command) : mixed
Parameters
$command : string

A Aruba OS valid CLI command.

Return values
mixed

Return decoded response if success or FALSE on fail.

createVlan()

Create a VLAN on the switch.

public createVlan(int $vlan, string $name) : bool
Parameters
$vlan : int

VLAN id.

$name : string

VLAN name.

Return values
bool

Return TRUE if successful, FALSE if it failed.

deleteVlan()

Delete a VLAN on the switch.

public deleteVlan(int $vlan) : bool
Parameters
$vlan : int

VLAN id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

disablePoePort()

Disable POE on a port.

public disablePoePort(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

disablePort()

Disable a port.

public disablePort(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

enablePoePort()

Enable POE on a port.

public enablePoePort(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

enablePort()

Enable a port.

public enablePort(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

getArpEntryFromIP()

Retrieve an ARP table entry from an IP.

public getArpEntryFromIP(string $ip) : array<string|int, mixed>
Parameters
$ip : string

IPv4 address.

Return values
array<string|int, mixed>

Return an Arp Table Entry as an object on success or FALSE on failure.

getArpEntryFromMAC()

Retrieve an ARP table entry from a MAC address.

public getArpEntryFromMAC(string $mac) : array<string|int, mixed>
Parameters
$mac : string

MAC address format 123456-789abc.

Return values
array<string|int, mixed>

Return an Arp Table Entry as an object on success or FALSE on failure.

getArpEntryFromVLAN()

Retrieve an ARP table entry from a VLAN.

public getArpEntryFromVLAN(string $vlan) : array<string|int, mixed>
Parameters
$vlan : string

VLAN ID.

Return values
array<string|int, mixed>

Return an array of Arp Table Entries as objects.

getArpTable()

Retrieve ARP table (capped to 1K entries right now).

public getArpTable() : array<string|int, mixed>
Return values
array<string|int, mixed>

Return an array of Arp Table Entries as objects.

getBanner()

Get switch's banners.

public getBanner() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns a Banner object containing motd banner, exec banner and last login enable parameter.

getMacAddressInfo()

Get infos about a MAC address.

public getMacAddressInfo(string $mac) : mixed
Parameters
$mac : string

MAC address format 123456-789abc.

Return values
mixed

Return the object if successful, FALSE if it failed.

getMacTable()

Get MAC table of the switch.

public getMacTable() : Return
Return values
Return

an array of objects if successful, FALSE if it failed.

getMacTablePort()

Get MAC table of a port.

public getMacTablePort(string $port) : Return
Parameters
$port : string

Port id.

Return values
Return

an array of objects if successful, FALSE if it failed.

getManagementUser()

Get one device management user.

public getManagementUser(string $name) : array<string|int, mixed>
Parameters
$name : string

user's name.

Return values
array<string|int, mixed>

Returns DeviceManagementUser object containing username, group, password type, password, aging period and minimum password length on success or FALSE on failure.

getManagementUsers()

Get all device management users.

public getManagementUsers() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns an array of DeviceManagementUser objects containing username, group, password type, password, aging period and minimum password length on success or FALSE on failure.

getPortsPOEStatus()

Get all ports POE status.

public getPortsPOEStatus() : array<string|int, mixed>

Values of port_poe_stats can be :

  • If POE is disable : PPDS_DISABLE.
  • If POE is enable but not delivering : PPDS_SEARCHING.
  • If POE is enable and delivering : PPDS_DELIVERING.
  • If POE has problem or is failing : PPDS_FAULT, PPDS_TEST, PPDS_OTHER_FAULT.
Return values
array<string|int, mixed>

Return an array of objects.

getPortsStatus()

Get all ports status.

public getPortsStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>

Return an array of objects.

getRunningConfig()

Get runnning configuration.

public getRunningConfig() : mixed
Return values
mixed

Return the configuration if successful, FALSE if it failed.

getStackGlobalSystemStatus()

Get switch's system status (firmware version, base address MAC, ...). Works only for stacked switchs.

public getStackGlobalSystemStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns the global system information for stacked switches as StackSystemInfoStatsGlobal object.

getStackMemberSystemStatus()

Get switch's system status (model, SN, ...). Works only for stacked switchs.

public getStackMemberSystemStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns the list of member specific system information as SystemInfoStats objects for stacked switches or FALSE on failure.

getSystemStatus()

Get switch's system status (model, SN, firmware version, ...). Works only for standalone switchs.

public getSystemStatus() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns the status of the host system for standalone switches as SystemInfoStats object.

getTVlanPort()

Get the tagged vlan for one port.

public getTVlanPort(string $port) : mixed
Parameters
$port : string

Port id.

Return values
mixed

Return the port association object info list if successful, FALSE if it failed.

getUVlanPort()

Get the untagged vlan for one port.

public getUVlanPort(string $port) : mixed
Parameters
$port : string

Port id.

Return values
mixed

Return the port association object info if successful, FALSE if it failed.

getVlanPorts()

Get list of ports for one vlan.

public getVlanPorts(int $vlan) : mixed
Parameters
$vlan : int

VLAN id.

Return values
mixed

Return the list as an array of objects if successful, FALSE if it failed.

getVlans()

Get all VLANs on the switch.

public getVlans() : mixed
Return values
mixed

Return the list as an array of objects if successful, FALSE if it failed.

getVlansPort()

Get list of vlans affected to one port.

public getVlansPort(string $port) : mixed
Parameters
$port : string

Port id.

Return values
mixed

Return the list as an array of objects if successful, FALSE if it failed.

getVlansPorts()

Get list of vlans/ports association.

public getVlansPorts() : mixed
Return values
mixed

Return the list as an array of objects if successful, FALSE if it failed.

isPortEnabled()

Check if a port is enabled.

public isPortEnabled(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if the port is enabled, FALSE if not.

isPortUp()

Check if a port is up.

public isPortUp(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if the port is up, FALSE if not.

isStack()

Is the switch a stacked switches ?

public isStack() : bool
Return values
bool

Returns TRUE if switch is stacked switches, else FALSE.

ping()

Ping an IP or a hostname.

public ping(string $target[, int $timeout = NULL ]) : mixed
Parameters
$target : string

IPv4, IPv6 or hostname.

$timeout : int = NULL

ICMP timeout.

Return values
mixed

Return an object with "result" (enum 0 -> 10) and "rtt_in_milliseconds" (integer) if successful, FALSE if it failed.

portPoeStatus()

Check if a port is POE enabled.

public portPoeStatus(string $port) : Return

Values of port_poe_stats can be :

  • If POE is disable : PPDS_DISABLE.
  • If POE is enable but not delivering : PPDS_SEARCHING.
  • If POE is enable and delivering : PPDS_DELIVERING.
  • If POE has problem or is failing : PPDS_FAULT, PPDS_TEST, PPDS_OTHER_FAULT.
Parameters
$port : string

Port id.

Return values
Return

the object.

restartPoePort()

Restart POE on a port.

public restartPoePort(string $port) : bool
Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

restartPort()

Disable a port 5sec and re-enable it. Be careful when disabling links between switchs or firewalls .

public restartPort(string $port) : bool

..

Parameters
$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

setBanner()

Set switch's banners.

public setBanner([string $motd = NULL ][, string $exec = NULL ][, bool $lastLogin = TRUE ]) : array<string|int, mixed>
Parameters
$motd : string = NULL

The new wanted motd banner. NULL to leave it the same, empty string to remove it.

$exec : string = NULL

The new wanted exec banner. NULL to leave it the same, empty string to remove it.

$lastLogin : bool = TRUE

Display last login information ?

Return values
array<string|int, mixed>

Returns a Banner object containing the newly set motd banner, exec banner and last login enable parameter.

setTVlanPort()

Set tagged VLAN(s) on port.

public setTVlanPort(array<string|int, mixed> $vlans, string $port) : bool

Working but be careful ongoing forum post about not being able to remove tagged vlan if it's the default vlan (1). More info on this forum post.

Parameters
$vlans : array<string|int, mixed>

[VLAN ids].

$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

setUVlanPort()

Set untagged VLAN on port.

public setUVlanPort(int $vlan, string $port) : bool
Parameters
$vlan : int

VLAN id.

$port : string

Port id.

Return values
bool

Return TRUE if successful, FALSE if it failed.

updateManagementUserPassword()

Change the password of a management user.

public updateManagementUserPassword(string $name, string $password) : array<string|int, mixed>
Parameters
$name : string

User's name.

$password : string

user's password.

Return values
array<string|int, mixed>

Returns TRUE on success or FALSE on failure.

updateVlan()

Update a VLAN on the switch.

public updateVlan(int $vlan, string $name) : bool
Parameters
$vlan : int

VLAN id.

$name : string

VLAN name.

Return values
bool

Return TRUE if successful, FALSE if it failed.

curlRequest()

Method to request the switch's API

private curlRequest(string $method, string $endpoint[, string $data = NULL ][, int $timeout = NULL ]) : mixed
Parameters
$method : string

HTTP method (e.g. 'GET', 'POST', 'PUT', 'DELETE' ...).

$endpoint : string

API endpoint without the 2 first element ('rest' and API version '/rest/vX'), e.g. /login-sessions.

$data : string = NULL

Data to be passed in the request body as a JSON document (e.g. '{"userName":"api","password":"api"}').

$timeout : int = NULL
Return values
mixed

Return switch's response as a PHP array if any or TRUE on success without response.

login()

Login in the switch.

private login() : bool
Return values
bool

Return TRUE if successful or throw Exception if fails.

logout()

Logout

private logout() : mixed
Return values
mixed

Search results