Aruba即时restapi的Python包装器
instantp的Python项目详细描述
Aruba即时Python API包装
这个模块为ArubaInstant8.6RESTAPI提供了一个Python3接口。在
请理解此项目是WIP。我也非常感谢你帮我测试一下。我的即时集群是我在家里生产的wifi。我无法彻底测试对API的某些调用(特别是在配置部分),因为在家中断wifi会导致家庭不幸福。
有关完整文档,请参见here。在
restapi分为三个部分。监视,Action,和配置。每一部分的细节如下。登录和注销由login()
和logout()
方法处理。登录有一个decorator方法,可以在需要时处理登录。您仍然需要处理注销。请参阅下面的示例。
监控
显然,API的监视端点用于监视。它用于从主、从或独立即时AP收集状态、统计信息和日志。这部分API的体系结构与“show”命令的cli输出非常相似。当前支持的命令是show clients
和show aps
。不久将添加更多内容。还有一个通用的show command
方法,它将接受任何CLI show命令并返回非结构化文本。在
如果结构化输出有帮助,请随意打开问题并请求对更多命令的支持。如果有帮助的话,我还可以添加对不同操作系统版本(至少回到8.5)的支持。在
NOTE: The response from the API is currently unstructred text and requires parsing with RegEx.
This lends itself to breaking easily between versions. My current testing has been against 8.6.
行动
操作终结点用于配置AP特定的设置。有关支持的端点,请参见下文。在
Endpoint | Method | Description |
---|---|---|
Hostname | hostname() | Set the hostname of a specific IAP. |
Swarm Mode | swarm() | Set an AP to be standalone or part of a swarm cluster. |
Static Channel and Power | channel() | Set the tx channel and power of the radios of a specific IAP. |
Zone | zone() | Set the zone of a specific IAP. |
Antenna Gain | antenna_gain() | Set the specific antenna gain when external antennas are used. |
Enable and Disable Radios | radio_state() | Enable or disable a radio in an AP. |
Generic Show Command | show_cmd() | Returns unstructured output text from any "show" command provided. |
配置
配置终结点用于配置即时虚拟控制器。有关支持的端点,请参阅下表。在
当初始化InstantVC()的实例时,“templates”目录默认为项目中的文件夹。建议您创建自己的模板目录并使用此目录作为参考。在
^{pr2}$ ^{tb2}$示例:
使用@autologin decorator登录-在这个场景中,decorator将在第一次调用API时为您登录。在
import instantpy
vc = instantpy.InstantVC('user', 'password', 'VC IP')
result = vc.clients()
...
vc.logout()
监控端点示例
列出已连接的客户端
import json
import instantpy
vc = instantpy.InstantVC('user', 'password', 'VC IP')
result = vc.clients()
print(json.dumps(result, indent=4))
vc.logout()
任意“show”命令
import json
import instantpy
vc = instantpy.InstantVC('user', 'password', 'VC IP')
result = vc.show_command(command="show swarm state")
print(result)
vc.logout()
操作终结点示例
设置特定AP的主机名
import json
import instantpy
vc = instantpy.InstantVC('user', 'password', 'VC IP')
result = vc.hostname(name="testname", iap_ip="1.2.3.4")
print(json.dumps(result, indent=4))
vc.logout()
配置端点示例
设置RADIUS身份验证服务器
import json
import instantpy
vc = instantpy.InstantVC('user', 'password', 'VC IP')
result = vc.auth_server(template='auth_server_template.json')
print(json.dumps(result, indent=4))
vc.logout()
如果这个项目有帮助,你可以buy me a coffee,但请不要觉得有义务。在
- 项目
标签: