承接 benclerc/aruba-switchapi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

benclerc/aruba-switchapi

Composer 安装命令:

composer require benclerc/aruba-switchapi

包简介

Library used for interacting with Aruba SwitchAPI (ArubaOS).

README 文档

README

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 on Aruba's website, choose your equipment and download the API documentation.

Table of contents

Getting started

  1. Get Composer.
  2. Install the library using composer composer require benclerc/aruba-switchapi.
  3. Add the following to your application's main PHP file require '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 documentation here.

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. Use setTimeout() to change.
  • SSL verify peer option : TRUE. Use setSSLVerifyPeer() to change.
  • SSL verify host option : 2. Use setSSLVerifyHost() to change.
  • API version : 'v7'. Use setAPIVersion() 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 locator
try {
	$res = $switch->blinkLedLocator(2, 1);
	if ($res) {
		echo('Blink succeeded');
	} else {
		echo('Blink failed');
	}
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}

// Create a VLAN
try {
	$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 ports
try {
	$res = $switch->getPortsStatus();
	if ($res != FALSE) {
		foreach ($res as $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 42
try {
	$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 methods here.

benclerc/aruba-switchapi 适用场景与选型建议

benclerc/aruba-switchapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.34k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 benclerc/aruba-switchapi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 benclerc/aruba-switchapi 我们能提供哪些服务?
定制开发 / 二次开发

基于 benclerc/aruba-switchapi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-08