跳转到主要内容

提供厂商无关网络自动化的统一REST API

项目描述

Build Status Documentation Status PyPI version

Netman

Netman是一个提供厂商无关网络自动化的统一REST API。它抽象了特定于厂商的部分,并为你提供了一个干净且简化的API。

Python代码使用

switch_factory = SwitchFactory(MemoryStorage(), ThreadingLockFactory())
switch = switch_factory.get_anonymous_switch(
    model="cisco", 
    hostname="hostname_or_ip", 
    username="username", 
    password="password", 
)

switch.add_vlan(1000, name="myvlan")

REST API使用

首先,启动服务

tox
.tox/py27/bin/python netman/main.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

然后你可以通过http访问它

curl -X POST http://127.0.0.1:5000/switches/hostname_or_ip/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: username" 
    -H "Netman-password: password"

拆分模式

Netman支持拆分模式。这是一种特殊的操作模式,其中Netman将使用远程Netman服务器来访问网络设备。当你的网络设备无法连接到主Netman服务器时,这种模式特别有用。你可以在某个地方启动一个服务器,例如在192.168.1.1,按照上述方法运行Netman。并且使用如下代理直接使用代码

switch_factory = SwitchFactory(MemoryStorage(), ThreadingLockFactory())
switch = switch_factory.get_anonymous_switch(
    model="cisco", 
    hostname="hostname_or_ip", 
    username="username", 
    password="password", 
    netman_server="http://192.168.1.1")

switch.add_vlan(1000, name="myvlan")

或者当使用REST API调用时,你可以调用主服务器并提供要使用的代理Netman服务器。

curl -X POST http://127.0.0.1:5000/switches/hostname_or_ip/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: username" 
    -H "Netman-password: password"
    -H "Netman-Proxy-Server: http://192.168.1.1"

Docker使用

从你的计算机上,启动一个Netman容器和一个假交换机容器,以模拟Netman将要配置的交换机。

$ docker-compose up -d

创建Vlan

curl -X POST http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: root" 
    -H "Netman-password: root"

获取现有Vlan的信息

curl -X GET http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans/1000 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: root" 
    -H "Netman-password: root"

贡献

请随意提出问题并发送一些拉取请求,我们将很高兴查看它们!

项目详情


版本历史 发布通知 | RSS源

下载文件

下载适合您平台的应用程序。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

netman-1.5.1.tar.gz (184.3 kB 查看哈希值)

上传时间

构建分发

netman-1.5.1-py2-none-any.whl (121.4 kB 查看哈希值)

上传时间 Python 2

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面