Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

PHP library used for interacting with Aruba switch (ArubaOS) API.

License

NotificationsYou must be signed in to change notification settings

benclerc/Aruba-SwitchAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aruba SwitchAPI is a PHP library for requesting Aruba switches (ArubaOS). This library can retrieve, create, update and delete configuration on the switch. It wan be used to :

  • Configure switch from a PHP designed web interface.
  • Backup switch configuration with a PHP script.
  • So much more, it is up to you !

Warning : This library is incomplete and mainly oriented towards POE, VLAN, port and LED locator. Contributions are welcome !

You can find all supported methods onAruba's website, choose your equipment and download the API documentation.

Table of contents

Getting started

  1. GetComposer.
  2. Install the library using composercomposer require benclerc/aruba-switchapi.
  3. Add the following to your application's main PHP filerequire 'vendor/autoload.php';.
  4. Instanciate the Config class with the switch's hostname, username and password$configSwitch = new \Aruba\Config('123.123.123.123', 'admin', 'password');.
  5. Use the Config object previously created to instanciate the SwitchAPI object$switch = new \Aruba\SwitchAPI($configSwitch);.
  6. Start using the library$runningConf = $switch->getRunningConfig();.

Documentation

You can find a full documentationhere.

Config class

This Config class is used to prepare the mandatory configuration information to instanciate and use the SwitchAPI class. In the constructor you must pass :

  1. The switch's hostname (FQDN) or IP address
  2. A valid user's username
  3. The valid user's password

Optional parameters :

  • Timeout : 5000ms. UsesetTimeout() to change.
  • SSL verify peer option : TRUE. UsesetSSLVerifyPeer() to change.
  • SSL verify host option : 2. UsesetSSLVerifyHost() to change.
  • API version : 'v7'. UsesetAPIVersion() to change (only >= v7 are supported).

Example :

// Basic configuration$configSwitch =new \Aruba\Config('123.123.123.123','admin','password');// Configuration for very slow switchs/long requests$configSwitch =new \Aruba\Config('123.123.123.123','admin','password');$configSwitch->setTimeout(20000);// Unsecure configuration$configSwitch =new \Aruba\Config('123.123.123.123','admin','password');$configSwitch->setSSLVerifyPeer(FALSE)->setSSLVerifyHost(FALSE);// Special API version$configSwitch =new \Aruba\Config('123.123.123.123','admin','password');$configSwitch->setAPIVersion('v8');// The class logins to the switch when being instanciated hence the try/catch statement.try {$switch =new \Aruba\SwitchAPI($configSwitch);}catch (Exception$e) {echo('Handle error :'.$e->getMessage());}

SwitchAPI class

Usage

This class uses Exception to handle errors, for nominal execution you should instanciate and request methods inside try/catch statements.

Examples :

// Blink for 1 min LED locatortry {$res =$switch->blinkLedLocator(2,1);if ($res) {echo('Blink succeeded');}else {echo('Blink failed');}}catch (Exception$e) {echo('Handle error :'.$e->getMessage());}// Create a VLANtry {$res =$switch->createVlan(666,'HELL');if ($res) {echo('The VLAN has been created.');}else {echo('Error : the VLAN was not created.');}}catch (Exception$e) {echo('Handle error :'.$e->getMessage());}// Get status of all portstry {$res =$switch->getPortsStatus();if ($res !=FALSE) {foreach ($resas$key =>$value) {$status = ($value->is_port_enabled) ?'up' :'down';echo('Port'.$value->id.' is'.$status.'<br>');}}else {echo('Error : status could not be retrieved.');}}catch (Exception$e) {echo('Handle error :'.$e->getMessage());}// Set untagged VLAN 666 on port 42try {$res =$switch->setUVlanPort(666,'42');if ($res) {echo('The VLAN 666 has been affected to the port 42.');}else {echo('Error : the VLAN was not affected.');}}catch (Exception$e) {echo('Handle error :'.$e->getMessage());}

Available methods

You can browse all available methodshere.


[8]ページ先頭

©2009-2025 Movatter.jp