前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python中文社区开源项目计划:forward

Python中文社区开源项目计划:forward

作者头像
Python中文社区
发布2018-07-26 17:11:50
9170
发布2018-07-26 17:11:50
举报
文章被收录于专栏:Python中文社区Python中文社区

Headkarl

IT设备自动化管理工具forward开源项目核心开发者。

GitHub ID:Headkarl

https://github.com/tecstack/forward

Authors

  • Forward由Headkarl创建,并且由cheung kei-chuen、Leann Mak、Shawn.T等多位用户参与贡献。
  • Forward was created by Wang Zhe(Headkarl) and contributed by many users, such as Zhang Qichuan(cheung kei-chuen), Mai Yi Fan(Leann Mak) and Dai Sheng(Shawn.T), and sincerely thanks each one.

Introduce 介绍

  • Forward是一个python模块,提供与目标设备之间的通道封装,基于指令行(Command Lines)的方式实现多数功能的封装,供开发者快速简便调用,屏蔽不同设备上指令差异。
  • 建议使用Forward用于多种(厂家、型号)网络设备的自动化管理场景,可以快速构建出运维场景脚本。
  • Forward is a python module, which provides channel encapsulation between target devices, and realizes most functions encapsulation based on Command Lines. It allows developers to invoke quickly and simply, and screen instructions on different devices.
  • We recommend the use of Forward for a variety of (manufacturer, model) network equipment automation management scene, can quickly build the operation and maintenance scenario script.

Installation

  • Building virtual environment (optional) 构建虚拟环境 (可选)
  • 开发者用户推荐,使用pyenv和virtualenv构建纯净的python环境,基于python版本2.7.10
  • We recommend that developer users use pyenv and virtualenv to build a pure Python environment which is based on Python version 2.7.10.
代码语言:javascript
复制
pyenv virtualenv 2.7.10 forward
pyenv activate forward
  • Pull 拉取当前版本
代码语言:javascript
复制
git clone https://github.com/tecstack/forward.git
cd forward
  • Dependency 安装依赖包
代码语言:javascript
复制
pip install -r requirements.txt
  • Setup 安装
代码语言:javascript
复制
python setup.py install

Getting Started

  • 下方代码段展示了一个简易的forward场景实现,批量连接到两台设备(思科Nexus7018),执行指令并获取结果。
  • The code section below shows a simple forward scenario implementation that is batch connected to two devices (CISCO Nexus7018), executes instructions and gets the results.
代码语言:javascript
复制
from forward import Forward

new = Forward()
new.addTargets(['192.168.113.1-192.168.113.2'], 'n7018', 'username', 'password')
instances = new.getInstances()

cisco1 = instances['192.168.113.1']
cisco2 = instances['192.168.113.2']

result1 = cisco1.execute('show version')
result2 = cisco2.execute('show version')

if result1['status']:
    print '[%s] OS version info: %s' % ('cisco1', result1['content'])
if result2['status']:
    print '[%s] OS version info: %s' % ('cisco2', result2['content'])
  • 上述代码段中出现的'cisco1'和'cisco2'就是Forward设备类实例(N7018),不同设备类实例包含的方法可能不同,具体请查阅类库文档。
  • The 'cisco1' and 'cisco2' appearing in the above code segment are Forward device class instances (N7018). Different device class instances contain different methods. Please consult the detailed library documents.

Advanced Usage

  • 初始化 Initialize
  • 预登陆 PreLogin
  • 自定义指令 command

Class

  • Forward目前包含40多种特定型号设备类库,查看详细的类库文档。
  • Forward currently contains more than 40 specific type of device class libraries, here to look at the detailed library documents.

License

  • GNU General Public License v3.0
  • See COPYING to see the full text.

Branch Info

  • RC,Releases和Stables分支都以版本号+各种鱼类命名。
  • devel分支对应正在开发的分支。
  • alpha分支对应一个早期的内部测试版本。
  • RC,Releases and Stables are named after the version number plus any kind of fish.
  • The devel branch corresponds to the release actively under development.
  • The alpha branch corresponds to a early release which is used for In-House test.

Version Info

  • 在版本记录中查看所有历史记录,开源前的版本更新仅可以看到记录。
  • Looking at all the history records in Version Info, the pre - source version updates can only see the records.

往期开源项目介绍

Python开源项目介绍:用zmail简单地发邮件

Python开源项目介绍:网站日志分析工具

Python中文社区开源项目计划:ImagePy

Amas:基于大数据平台技术开发的统一监控平台

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-06-05,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Python中文社区 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档