├── .coveralls.yml
├── .gitignore
├── .python-version
├── .travis.yml
├── COPYING
├── Jenkinsfile
├── README.md
├── docs
├── Authors.md
├── BranchInfo.md
├── GettingStarted.md
├── Installation.md
├── License.md
├── VersionInfo.md
├── advance
│ ├── command.md
│ ├── initialize.md
│ └── prelogin.md
└── class
│ ├── README.md
│ ├── sshv1
│ ├── README.md
│ └── maipu
│ │ ├── README.md
│ │ └── s3300.md
│ ├── sshv2
│ ├── README.md
│ ├── baer
│ │ ├── README.md
│ │ ├── sr7750.md
│ │ └── sr7950.md
│ ├── brocade
│ │ ├── README.md
│ │ └── adx03100.md
│ ├── cisco
│ │ ├── README.md
│ │ ├── asa.md
│ │ ├── asr1006.md
│ │ ├── c2960.md
│ │ ├── c4510.md
│ │ ├── c6506.md
│ │ ├── c6509.md
│ │ ├── n5548.md
│ │ ├── n5596.md
│ │ ├── n7010.md
│ │ ├── n7018.md
│ │ ├── n7710.md
│ │ └── n7718.md
│ ├── depp
│ │ ├── README.md
│ │ └── f1000.md
│ ├── f5
│ │ ├── README.md
│ │ └── f510000.md
│ ├── fenghuo
│ │ ├── README.md
│ │ └── s5800.md
│ ├── fortinet
│ │ ├── README.md
│ │ ├── fg1240.md
│ │ ├── fg3040.md
│ │ └── fg3950.md
│ ├── huawei
│ │ ├── README.md
│ │ ├── e1000e.md
│ │ ├── e8000e.md
│ │ ├── e8160e.md
│ │ ├── ne40ex16.md
│ │ ├── ne40ex3.md
│ │ ├── s5328.md
│ │ ├── s5352.md
│ │ ├── s8512.md
│ │ ├── s9303.md
│ │ ├── s9306.md
│ │ └── s9312.md
│ ├── linux
│ │ ├── README.md
│ │ └── bclinux7.md
│ ├── raisecom
│ │ ├── README.md
│ │ └── r3048g.md
│ ├── ruijie
│ │ ├── README.md
│ │ └── rg5510.md
│ └── zte
│ │ ├── README.md
│ │ ├── m6000.md
│ │ └── zx5952.md
│ └── telnet
│ ├── README.md
│ ├── juniper
│ ├── README.md
│ ├── mx960.md
│ └── srx3400.md
│ └── venustech
│ ├── README.md
│ └── usg1000.md
├── example.md
├── lib
└── forward
│ ├── __init__.py
│ ├── devclass
│ ├── __init__.py
│ ├── adx03100.py
│ ├── asa.py
│ ├── asr1006.py
│ ├── baseBaer.py
│ ├── baseBrocade.py
│ ├── baseCisco.py
│ ├── baseDepp.py
│ ├── baseF5.py
│ ├── baseFenghuo.py
│ ├── baseFortinet.py
│ ├── baseH3C.py
│ ├── baseHuawei.py
│ ├── baseJuniper.py
│ ├── baseLinux.py
│ ├── baseMaipu.py
│ ├── baseRaisecom.py
│ ├── baseRuijie.py
│ ├── baseRuijieV1.py
│ ├── baseSSHV1.py
│ ├── baseSSHV2.py
│ ├── baseTELNET.py
│ ├── baseVenustech.py
│ ├── baseZte.py
│ ├── bclinux7.py
│ ├── c2960.py
│ ├── c4510.py
│ ├── c6506.py
│ ├── c6509.py
│ ├── ce12812.py
│ ├── e1000e.py
│ ├── e8000e.py
│ ├── e8160e.py
│ ├── f1000.py
│ ├── f510000.py
│ ├── fg1240.py
│ ├── fg3040.py
│ ├── fg3950.py
│ ├── m6000.py
│ ├── m9006.py
│ ├── mx960.py
│ ├── n5548.py
│ ├── n5596.py
│ ├── n7010.py
│ ├── n7018.py
│ ├── n7710.py
│ ├── n7718.py
│ ├── ne40ex16.py
│ ├── ne40ex3.py
│ ├── r3048g.py
│ ├── rg5510.py
│ ├── rg5510v1.py
│ ├── s3300.py
│ ├── s5328.py
│ ├── s5352.py
│ ├── s5800.py
│ ├── s8512.py
│ ├── s9303.py
│ ├── s9306.py
│ ├── s9312.py
│ ├── s9312e.py
│ ├── sr7750.py
│ ├── sr7950.py
│ ├── srx3400.py
│ ├── unusable_command_interface.py
│ ├── usg1000.py
│ ├── vlb.py
│ ├── vyoslinux.py
│ └── zx5952.py
│ ├── release.py
│ └── utils
│ ├── __init__.py
│ ├── boolean.py
│ ├── deviceListSplit.py
│ ├── display.py
│ ├── error.py
│ ├── forwardError.py
│ ├── log.py
│ ├── loginThread.py
│ ├── output.py
│ ├── paraCheck.py
│ ├── parse.py
│ ├── path.py
│ ├── sshv1.py
│ ├── sshv2.py
│ └── telnet.py
├── nosetests.ini
├── protocol
├── flake8
└── pre-commit
├── requirements.txt
├── setup.py
└── unittests
├── __init__.py
├── baseBaseBrocade.py
├── testAdx03100.py
├── testAsa.py
├── testAsr1006.py
├── testBaseBaer.py
├── testBaseCisco.py
├── testBaseDepp.py
├── testBaseF5.py
├── testBaseFenghuo.py
├── testBaseFortinet.py
├── testBaseHuawei.py
├── testBaseJuniper.py
├── testBaseLinux.py
├── testBaseMaipu.py
├── testBaseRaisecom.py
├── testBaseSSHV1.py
├── testBaseSSHV2.py
├── testBaseTELNET.py
├── testBaseVenustech.py
├── testBaseZte.py
├── testC2960.py
├── testC4510.py
├── testC6506.py
├── testC6509.py
├── testDevclassInit.py
├── testE1000e.py
├── testE8000e.py
├── testE8160e.py
├── testF1000.py
├── testF510000.py
├── testFg1240.py
├── testFg3040.py
├── testFg3950.py
├── testM6000.py
├── testMainClass.py
├── testMx960.py
├── testN5548.py
├── testN5596.py
├── testN7010.py
├── testN7018.py
├── testN7710.py
├── testN7718.py
├── testNe40ex16.py
├── testNe40ex3.py
├── testR3048g.py
├── testRg5510.py
├── testS3300.py
├── testS5328.py
├── testS5352.py
├── testS5800.py
├── testS8512.py
├── testS9303.py
├── testS9306.py
├── testS9312.py
├── testSr7750.py
├── testSr7950.py
├── testSrx3400.py
├── testUsg1000.py
├── testVlb.py
├── testVyoslinux.py
└── testZx5952.py
/.coveralls.yml:
--------------------------------------------------------------------------------
1 | service_name: travis-pro
2 | repo_token: e0vlxNxhi7UEjj1KjKbz7BSl7x2YADO6j
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 |
5 | # Unit test / coverage reports
6 | htmlcov/
7 | .tox/
8 | .coverage
9 | .coverage.*
10 | .cache
11 | nosetests.xml
12 | coverage.xml
13 | *,cover
14 |
15 | # PyInstaller
16 | # Usually these files are written by a python script from a template
17 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
18 | *.manifest
19 | *.spec
20 |
21 | # Installer logs
22 | pip-log.txt
23 | pip-delete-this-directory.txt
24 |
25 | # Distribution / packaging
26 | .Python
27 | env/
28 | build/
29 | develop-eggs/
30 | dist/
31 | downloads/
32 | eggs/
33 | .eggs/
34 | lib64/
35 | parts/
36 | sdist/
37 | *.egg-info/
38 | .installed.cfg
39 | *.egg
40 |
41 | # Custom
42 | conf/
43 | data/
44 | log/
45 | .tmp/
46 |
--------------------------------------------------------------------------------
/.python-version:
--------------------------------------------------------------------------------
1 | forward
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | python:
3 | - "2.7.10"
4 |
5 | install:
6 | - pip install -r requirements.txt
7 | - python setup.py install
8 |
9 | script:
10 | - flake8 ./ --config=protocol/flake8
11 | - nosetests -v --with-coverage --cover-package=lib/forward
12 |
13 | notifications:
14 | email:
15 | recipients:
16 | - azrael-ex@139.com
17 | on_success: always
18 | on_failure: always
19 |
20 | after_success:
21 | - coveralls
22 |
--------------------------------------------------------------------------------
/docs/Authors.md:
--------------------------------------------------------------------------------
1 | ## Authors 作者
2 | * Forward由王喆(Headkarl: azrael-ex@139.com)创建,并且由张其川(cheung kei-chuen: qichuan.zhang@qq.com)、麦艺帆(Leann Mak:leannmak@139.com)、戴声(Shawn.T:shawntai.ds@gmail.com)等多位用户参与贡献,在此衷心感谢每一位。
3 | * Forward was created by Wang Zhe(Headkarl: azrael-ex@139.com) and contributed by many users, such as Zhang Qichuan(cheung kei-chuen: qichuan.zhang@qq.com), Mai Yi Fan(Leann Mak:leannmak@139.com) and Dai Sheng(Shawn.T:shawntai.ds@gmail.com), and sincerely thanks each one.
4 |
--------------------------------------------------------------------------------
/docs/BranchInfo.md:
--------------------------------------------------------------------------------
1 | ## Brance Info 分支信息
2 | * RC,Releases和Stables分支都以版本号+各种鱼类命名。
3 | * devel分支对应正在开发的分支。
4 | * alpha分支对应一个早期的内部测试版本。
5 | * RC,Releases and Stables are named after the version number plus any kind of fish.
6 | * The devel branch corresponds to the release actively under development.
7 | * The alpha branch corresponds to a early release which is used for In-House test.
8 |
--------------------------------------------------------------------------------
/docs/GettingStarted.md:
--------------------------------------------------------------------------------
1 | ## Getting Started
2 | * 下方代码段展示了一个简易的forward场景实现,批量连接到两台设备(思科Nexus7018),执行指令并获取结果。
3 | * 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.
4 |
5 | ```Python
6 | from forward import Forward
7 |
8 | new = Forward()
9 | new.addTargets(['192.168.113.1-192.168.113.2'],'n7018','username','password')
10 | instances = new.getInstances()
11 |
12 | cisco1 = instances['192.168.113.1']
13 | cisco2 = instances['192.168.113.2']
14 |
15 | result1 = cisco1.execute('show version')
16 | result2 = cisco2.execute('show version')
17 |
18 | if result1['status']:
19 | # python 2
20 | print '[%s] OS version info: %s' % ('cisco1', result1['content'])
21 | # python 3
22 | print('[%s] OS version info: %s' % ('cisco1', result1['content']))
23 | if result2['status']:
24 | # python 2
25 | print '[%s] OS version info: %s' % ('cisco2', result1['content'])
26 | # python 3
27 | print('[%s] OS version info: %s' % ('cisco2', result1['content']))
28 | ```
29 | * 上述代码段中出现的'cisco1'和'cisco2'就是Forward设备类实例(N7018),不同设备类实例包含的方法可能不同,具体请查阅类库文档。
30 | * 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 class library document.
31 |
--------------------------------------------------------------------------------
/docs/Installation.md:
--------------------------------------------------------------------------------
1 | ## Installation
2 | 1. Building virtual environment (optional) 构建虚拟环境 (可选)
3 | * 开发者用户推荐,使用pyenv和virtualenv构建纯净的python环境,推荐python版本2.7.10及以上版本,兼容python3
4 | * We recommend that developer users use pyenv and virtualenv to build a pure Python environment, and recommend Python version 2.7.10 and later versions, including python3.
5 | ```Bash
6 | pyenv virtualenv 2.7.10 forward
7 | pyenv activate forward
8 | ```
9 | 2. Pull 拉取当前版本
10 | ```Bash
11 | git clone https://github.com/tecstack/forward.git
12 | cd forward
13 | ```
14 | 3. Dependency 安装依赖包
15 | ```Bash
16 | pip install -r requirements.txt
17 | ```
18 | 4. Setup 安装
19 | ```Bash
20 | python setup.py install
21 | ```
22 |
--------------------------------------------------------------------------------
/docs/License.md:
--------------------------------------------------------------------------------
1 | ## License
2 | * GNU General Public License v3.0
3 | * See [COPYING](COPYING) to see the full text.
4 |
--------------------------------------------------------------------------------
/docs/VersionInfo.md:
--------------------------------------------------------------------------------
1 | ## Version Update Record 版本更新记录
2 | ### V3.2.0
3 | 1. 实现Forward对python3的兼容性。
4 | 2. 新增了一批设备方法,包括查询系统坂本、端口信息、路由信息、vlan、ntp信息等,详见[类库文档](/docs/class)。
5 | 3. 完善文档。
6 |
7 | ### V3.1.0
8 | 1. 简化command方法调用格式,详见[自定义指令 command](/docs/advance/command.md)。
9 | 2. 修复优化了部分核心代码。
10 |
11 | ### V3.0.8
12 | 1. 新增sshv1和telnet通道标准类的command命令模式。
13 |
14 | ### V3.0.7
15 | 1. 新增sshv2通道标准类的command命令模式,通过高度自定义用法来实现网络设备配置模式。
16 | 2. 新增baseFenghuo标准类库。
17 | 3. 修复S9312,S5800,NE40EX16,S9300,S9312类库中的部分bug。
18 |
19 | ### V3.0.6
20 | 1. 新增vyoslinux类的zcli命令模式
21 | 2. 修复vyoslinux执行命令返回状态不正确的缺陷和特别字符问题。
22 | 3. 新增S5800类支持创建VLan、设置Vlan接口、设置Trunk接口。
23 | 4. 新增S9312类支持创建VLan、设置VLan接口。
24 | 5. 修复baseTELNET参数不一致问题。
25 |
26 | ### V3.0.5
27 | 1. 修复bug:
28 | * 修复了USG设备的privilege模式。
29 | * 修复了vyos设备的部分指令返回卡死的问题。
30 | * 添加了bclinux7设备的zcli模式。
31 |
32 | ### V3.0.4
33 | 1. 修复bug:
34 | * telnet与sshv1分支系列设备不能成功初始化的问题已经修复。
35 | * cisco系列设备的二次认证问题已经修复。
36 |
37 | ### V3.0.3
38 | 1. 新增类库: 目前所有1.0版本中的类库已经重构完毕,可以使用,但未经过测试。
39 | * 根级基础类:baseTELNET,baseSSHV1
40 | * 厂家级基础类:baseJuniper,baseBear,baseDepp,baseF5,baseFortinet,baseRaisecom,baseZte
41 | * 华为类:s3300,e1000e
42 | * Juniper类:mx960,srx3400
43 | * 启明星辰类:usg1000
44 | 2. 修复继承关系:
45 | * f510000,fg1240,fg3040,fg3950,m6000,r3048g,s5800,sr7750,zx5952:这些类库目前正确地继承了厂家基础类。
46 |
47 | ### V3.0.2
48 | 1. 新增类库:
49 | * 华为类:e8000e,s9306,s9312,e8160e,ne40ex3,ne40ex16,s5328,s5352,s8512
50 | * 思科类:adx03100,asa,asr1006,f1000,f510000
51 | * linux类:bclinux7
52 | * 其他类:sr7750,zx5952,fg1240,fg3040,fg3950,m6000,r3048g,s5800,vlb
53 |
54 | ### V3.0.1
55 | 1. 新增类库:
56 | * 厂家级基础类:baseHuawei
57 | * 华为类:s9303
58 | 2. 修正bug: n7018类现在可以被正确的调用了。
59 |
60 | ### V3.0.0
61 | 1. 版本重构,欢迎体验精简的Forward3.0,参考快速入门。
62 | 2. 当前支持的类库:
63 | * 根级基础类:basesshv2
64 | * 厂家级基础类:basecisco,baselinux
65 | * 思科类:c2960,c4510,c6506,c6509,n5548,n5596,n7010,n7018,n7710,n7718
66 | 3. 添加预登陆模式: 默认所有类实例将会在用户调用getInstances方法时批量登陆,如果你不需要预先登陆所有机器,可以指定preLogin属性,例如:Forward.getInstances(preLogin=False),然后在单独的实例中调用login()方法进行登陆。
67 |
--------------------------------------------------------------------------------
/docs/advance/initialize.md:
--------------------------------------------------------------------------------
1 | ## 初始化 Initialize
2 |
3 | ##### Forward初始化过程可以简单分为三步:
4 |
5 | ```Python
6 | # import
7 | from forward import Forward
8 | fw = Forward()
9 |
10 | # add targets
11 | fw.addTargets(['192.168.1.10', '192.168.1.21-192.168.1.30'], 'n7018', 'username', 'password')
12 | fw.addTargets(['192.168.2.10'], 'mx960', 'username2', 'password2')
13 | fw.addTargets(['192.168.3.10', '192.168.3.11-192.168.3.20'], 's5328', 'username3', 'password3')
14 |
15 | # get instances
16 | instances = fw.getInstances()
17 | ```
18 |
19 | * 在这个代码段中,forward接受到了11台cisco n7018、1台juniper mx960和11台huawei s5328,共计23台设备信息作为目标,完成初始化并返回一个包含23台设备forward类实例的字典结构,用户可以通过下面的方法拿到其中任何一个实例,每一种设备类实例包含的属性和方法可能是不一样的,请参考详细的[类库文档](/docs/class):
20 |
21 | ```Python
22 | cisco1 = instances['192.168.1.10']
23 | ```
24 |
25 | * 这些类实例已经完成登陆,可以直接调用execute和command方法执行指令,如果你不需要在初始化环节进行登陆而希望自己控制登陆行为,请在第三步设置一个简单参数即可(例子中关闭了预登陆,并且代码控制只登陆了其中一台设备),更多关于预登陆的信息请参考[预登陆](/docs/advance/prelogin):
26 |
27 | ```Python
28 | instances = fw.getInstances(preLogin=False)
29 | instances['192.168.1.21'].login()
30 | ```
31 |
--------------------------------------------------------------------------------
/docs/advance/prelogin.md:
--------------------------------------------------------------------------------
1 | ## 预登陆 Prelogin
2 |
3 | * 预登陆模式(默认),获取实例同时完成自动登录,可直接执行指令。
4 |
5 | ```Python
6 | # get instances that have logined
7 | instances = fw.getInstances()
8 | ```
9 |
10 | * 非登陆模式,获取实例时只做初始化操作,不执行自动登陆,可后续代码控制登陆。
11 |
12 | ```Python
13 | # get instances that haven't logined
14 | instances = fw.getInstances(preLogin=False)
15 | # manual login
16 | instances['192.168.1.10'].login()
17 | ```
18 |
19 | * 非登陆模式主要用于应对以下场景:
20 | * 目标节点数量巨大,且不需要全部登陆,例如在庞大组网结构中逐跳定位路径场景。
21 | * 设备执行指令耗时巨大,可能导致其他等待节点自动断开连接,从而影响场景执行,例如核查分析全量配置场景。
22 | * 其他类似场景。
23 |
--------------------------------------------------------------------------------
/docs/class/sshv2/linux/README.md:
--------------------------------------------------------------------------------
1 | ## 基本介绍
2 |
3 | * 支持Linux设备的操作。
4 |
5 | ## 接口列表
6 |
7 |
8 | | 接口名 | 描述 |
9 | | --- | --- |
10 | | __init__ | 实例初始化 |
11 | | login | 登录目标设备 |
12 | | logout | 登出目标设备 |
13 | | execute | 执行查询命令(普通) |
14 | | command | 执行所有命令(高级) |
15 | | getPrompt | 获取主机提示符,并识别登录设备后所处模式 |
16 | | getMore | 自动获取分页消息 |
17 | | cleanBuffer | 清除通道内残留信息 |
18 |
19 |
20 | ## 接口详情
21 |
22 |
23 | * __init__
24 |
25 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
26 |
27 | ---
28 |
29 | * login
30 |
31 | 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。
32 |
33 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
34 |
35 | ---
36 |
37 | * logout
38 |
39 | 注销与单个设备的会话。
40 |
41 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
42 |
43 | ---
44 |
45 | * execute
46 |
47 | 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。
48 |
49 | 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。
50 |
51 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
52 |
53 | ---
54 |
55 | * command
56 |
57 | 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。
58 |
59 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
60 |
61 | ---
62 |
63 | * getPrompt
64 |
65 | 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。
66 |
67 | `注意:该接口一般仅用于Forward内部使用。`
68 |
69 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
70 |
71 | ---
72 |
73 | * getMore
74 |
75 | 自动获取因一个命令结果较长而导致的分页内容。
76 |
77 | `注意:该接口仅用于Forward内部使用`。
78 |
79 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
80 |
81 | ---
82 |
83 | * cleanBuffer
84 |
85 | 清除在`socket`内,因接受消息不彻底而遗留的字符数据。
86 |
87 | 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。
88 |
89 | 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md)
90 |
--------------------------------------------------------------------------------
/docs/class/sshv2/linux/bclinux7.md:
--------------------------------------------------------------------------------
1 | ## 基本介绍
2 |
3 | * 支持Linux设备的操作。
4 |
5 | ## 接口列表
6 |
7 |
8 | | 接口名 | 描述 |
9 | | --- | --- |
10 | | __init__ | 实例初始化 |
11 | | login | 登录目标设备 |
12 | | logout | 登出目标设备 |
13 | | execute | 执行查询命令(普通) |
14 | | command | 执行所有命令(高级) |
15 | | getPrompt | 获取主机提示符,并识别登录设备后所处模式 |
16 | | getMore | 自动获取分页消息 |
17 | | cleanBuffer | 清除通道内残留信息 |
18 |
19 |
20 | ## 接口详情
21 |
22 |
23 | * __init__
24 |
25 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
26 |
27 | ---
28 |
29 | * login
30 |
31 | 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。
32 |
33 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
34 |
35 | ---
36 |
37 | * logout
38 |
39 | 注销与单个设备的会话。
40 |
41 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
42 |
43 | ---
44 |
45 | * execute
46 |
47 | 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。
48 |
49 | 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。
50 |
51 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
52 |
53 | ---
54 |
55 | * command
56 |
57 | 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。
58 |
59 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
60 |
61 | ---
62 |
63 | * getPrompt
64 |
65 | 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。
66 |
67 | `注意:该接口一般仅用于Forward内部使用。`
68 |
69 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
70 |
71 | ---
72 |
73 | * getMore
74 |
75 | 自动获取因一个命令结果较长而导致的分页内容。
76 |
77 | `注意:该接口仅用于Forward内部使用`。
78 |
79 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
80 |
81 | ---
82 |
83 | * cleanBuffer
84 |
85 | 清除在`socket`内,因接受消息不彻底而遗留的字符数据。
86 |
87 | 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。
88 |
89 | 功能特性继承自[baseLinux](/docs/class/sshv2/linux/README.md)
90 |
--------------------------------------------------------------------------------
/example.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tecstack/forward/7da8a29a985edc1dbd2dfb2cd945ce4408602598/example.md
--------------------------------------------------------------------------------
/lib/forward/devclass/__init__.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
--------------------------------------------------------------------------------
/lib/forward/devclass/adx03100.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for ADX03100.
21 | """
22 |
23 | from forward.devclass.baseBrocade import BASEBROCADE
24 |
25 |
26 | class ADX03100(BASEBROCADE):
27 | """The device model belongs to the BROCADE series
28 | so the attributes and methods of BASEBROCADE are inherited.
29 | """
30 | pass
31 |
--------------------------------------------------------------------------------
/lib/forward/devclass/asr1006.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for ASR1006.
21 | """
22 | import re
23 | from forward.devclass.baseCisco import BASECISCO
24 |
25 |
26 | class ASR1006(BASECISCO):
27 | """The device model belongs to the cisco series
28 | so the attributes and methods of BASECISCO are inherited.
29 | """
30 | def addUser(self, username, password):
31 | # Overriding methods
32 | return BASECISCO.addUser(self,
33 | username=username,
34 | password=password,
35 | addCommand='username {username} secret {password}\n')
36 |
37 | def changePassword(self, username, password):
38 | # Overriding methods
39 | return BASECISCO.addUser(self,
40 | username=username,
41 | password=password,
42 | addCommand='username {username} secret {password}\n')
43 |
--------------------------------------------------------------------------------
/lib/forward/devclass/bclinux7.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | #
18 |
19 | """
20 | -----Introduction-----
21 | [Core][forward] Device class for bclinux7.
22 | """
23 |
24 | from forward.devclass.baseLinux import BASELINUX
25 |
26 |
27 | class BCLINUX7(BASELINUX):
28 | """This is a manufacturer of linux, using the
29 | SSHV2 version of the protocol, so it is integrated with BASESSHV2 library.
30 | """
31 | pass
32 |
--------------------------------------------------------------------------------
/lib/forward/devclass/ce12812.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for ce12812.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class CE12812(BASEHUAWEI):
26 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/e1000e.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for E1000E.
20 | """
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class E1000E(BASEHUAWEI):
25 | """This is a manufacturer of huawei, it is integrated with BASEHUAWEI library.
26 | """
27 |
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/e8160e.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for e8160e.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class E8160E(BASEHUAWEI):
26 | """This is a manufacturer of huawei, it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/f1000.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for f1000.
21 | """
22 | from forward.devclass.baseDepp import BASEDEPP
23 |
24 |
25 | class F1000(BASEDEPP):
26 | """This is a manufacturer of depp, it is integrated with BASEDEPP library.
27 | """
28 | def showLog(self):
29 | # Firewall has no syslog configuration
30 | njInfo = {
31 | "status": False,
32 | "content": [],
33 | "errLog": ""
34 | }
35 | njInfo["status"] = True
36 | return njInfo
37 |
--------------------------------------------------------------------------------
/lib/forward/devclass/f510000.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for F510000.
21 | """
22 | from forward.devclass.baseF5 import BASEF5
23 |
24 |
25 | class F510000(BASEF5):
26 | """This is a manufacturer of F5, it is integrated with BASEF5 library.
27 | """
28 |
29 | def addUser(self, username, password):
30 | """Because the device of this model is different from the other F5
31 | devices in creating user parameters, it is rewritten.
32 | """
33 | return BASEF5.addUser(self,
34 | username=username,
35 | password=password,
36 | addCommand='user {username} password {password} role network-admin\n')
37 |
38 | def _commit(self):
39 | """Because the device of this model is different from the other
40 | F5 devices in deleting user parameters, it is rewritten.
41 | """
42 | return BASEF5._commit(self,
43 | saveCommand='copy running-config startup-config',
44 | exitCommand='end')
45 |
--------------------------------------------------------------------------------
/lib/forward/devclass/fg1240.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for fg1240.
21 | """
22 | from forward.devclass.baseFortinet import BASEFORTINET
23 |
24 |
25 | class FG1240(BASEFORTINET):
26 | """This is a manufacturer of fortinet, so it is integrated with BASEFORTINET library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/fg3040.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for fg3040.
21 | """
22 | from forward.devclass.baseFortinet import BASEFORTINET
23 |
24 |
25 | class FG3040(BASEFORTINET):
26 | """This is a manufacturer of fortinet, so it is integrated with BASEFORTINET library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/fg3950.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for fg3950.
21 | """
22 | from forward.devclass.baseFortinet import BASEFORTINET
23 |
24 |
25 | class FG3950(BASEFORTINET):
26 | """This is a manufacturer of fortinet, so it is integrated with BASEFORTINET library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/m6000.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for m6000,zhong-xing.
20 | """
21 | from forward.devclass.baseZte import BASEZTE
22 |
23 |
24 | class M6000(BASEZTE):
25 | """This is a manufacturer of zte, so it is integrated with BASEZTE library.
26 | """
27 | pass
28 |
--------------------------------------------------------------------------------
/lib/forward/devclass/m9006.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for M9006.
21 | """
22 | from forward.devclass.baseH3C import BASEH3C
23 | import re
24 | import string
25 |
26 |
27 | class M9006(BASEH3C):
28 | """This is a manufacturer of h3c, it is integrated with BASEH3C library.
29 | """
30 | pass
--------------------------------------------------------------------------------
/lib/forward/devclass/mx960.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for m6000,zhong-xing.
20 | It applies only to models of network equipment mx960
21 | See the detailed comments mx960.py
22 | """
23 | from forward.devclass.baseJuniper import BASEJUNIPER
24 |
25 |
26 | class MX960(BASEJUNIPER):
27 | """This is a manufacturer of juniper, so it is integrated with BASEJUNIPER library.
28 | """
29 | pass
30 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n5548.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for n5548.
21 | """
22 | import re
23 | from forward.devclass.baseCisco import BASECISCO
24 |
25 |
26 | class N5548(BASECISCO):
27 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
28 | """
29 |
30 | def addUser(self, username, password, admin=False):
31 | """Because the device of this model is different from the other Cisco
32 | devices in creating user parameters, it is rewritten.
33 | """
34 | # default is not admin
35 | if admin:
36 | return BASECISCO.addUser(self,
37 | username=username,
38 | password=password,
39 | addCommand='user {username} password {password} role network-admin\n')
40 | else:
41 | return BASECISCO.addUser(self,
42 | username=username,
43 | password=password,
44 | addCommand='user {username} password {password} role priv-1\n')
45 |
46 | def _commit(self):
47 | """Because the device of this model is different from the other
48 | Cisco devices in commit parameters, it is rewritten.
49 | """
50 | return BASECISCO._commit(self,
51 | saveCommand='copy running-config startup-config',
52 | exitCommand='end')
53 |
54 | def changePassword(self, username, password):
55 | """Because the device of this model is different from the other
56 | Cisco devices in change user's password parameters, it is rewritten.
57 | """
58 | return BASECISCO.addUser(self,
59 | username=username,
60 | password=password,
61 | addCommand='user {username} password {password} role network-admin\n')
62 |
63 | def basicInfo(self):
64 | return BASECISCO.basicInfo(self, "show version")
65 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n5596.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for n5596.
21 | """
22 | import re
23 | from forward.devclass.baseCisco import BASECISCO
24 |
25 |
26 | class N5596(BASECISCO):
27 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
28 | """
29 |
30 | def addUser(self, username, password, admin=False):
31 | """Because the device of this model is different from the other Cisco
32 | devices in creating user parameters, it is rewritten.
33 | """
34 | # default is not admin
35 | if admin:
36 | return BASECISCO.addUser(self,
37 | username=username,
38 | password=password,
39 | addCommand='user {username} password {password} role network-admin\n')
40 | else:
41 | return BASECISCO.addUser(self,
42 | username=username,
43 | password=password,
44 | addCommand='user {username} password {password} role priv-1\n')
45 |
46 | def _commit(self):
47 | """Because the device of this model is different from the other
48 | Cisco devices in commit parameters, it is rewritten.
49 | """
50 | return BASECISCO._commit(self,
51 | saveCommand='copy running-config startup-config',
52 | exitCommand='end')
53 |
54 | def changePassword(self, username, password):
55 | """Because the device of this model is different from the other
56 | Cisco devices in change user's password parameters, it is rewritten.
57 | """
58 | return BASECISCO.addUser(self,
59 | username=username,
60 | password=password,
61 | addCommand='user {username} password {password} role network-admin\n')
62 |
63 | def basicInfo(self):
64 | return BASECISCO.basicInfo(self, "show version")
65 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n7010.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for n7010.
21 | """
22 | import datetime
23 | import time
24 | import re
25 | from forward.devclass.baseCisco import BASECISCO
26 |
27 |
28 | class N7010(BASECISCO):
29 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
30 | """
31 |
32 | def addUser(self, username, password, admin=False):
33 | """Because the device of this model is different from the other Cisco
34 | devices in creating user parameters, it is rewritten.
35 | """
36 | # param admin: defualt is not admin
37 | if admin:
38 | return BASECISCO.addUser(self,
39 | username=username,
40 | password=password,
41 | addCommand='user {username} password {password} role network-admin\n')
42 | else:
43 | return BASECISCO.addUser(self,
44 | username=username,
45 | password=password,
46 | addCommand='user {username} password {password} role priv-1\n')
47 |
48 | def _commit(self):
49 | """Because the device of this model is different from the other
50 | Cisco devices in commit parameters, it is rewritten.
51 | """
52 | return BASECISCO._commit(self,
53 | saveCommand='copy running-config startup-config',
54 | exitCommand='end')
55 |
56 | def changePassword(self, username, password):
57 | """Because the device of this model is different from the other
58 | Cisco devices in change user's password parameters, it is rewritten.
59 | """
60 | return BASECISCO.addUser(self,
61 | username=username,
62 | password=password,
63 | addCommand='user {username} password {password} role network-admin\n')
64 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n7018.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for n7018.
21 | """
22 | import re
23 | from forward.devclass.baseCisco import BASECISCO
24 |
25 |
26 | class N7018(BASECISCO):
27 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
28 | """
29 |
30 | def addUser(self, username, password, admin=False):
31 | """Because the device of this model is different from the other Cisco
32 | devices in creating user parameters, it is rewritten.
33 | """
34 | # default not is Admin
35 | if admin:
36 | return BASECISCO.addUser(self,
37 | username=username,
38 | password=password,
39 | addCommand='user {username} password {password} role network-admin\n')
40 | else:
41 | return BASECISCO.addUser(self,
42 | username=username,
43 | password=password,
44 | addCommand='user {username} password {password} role priv-1\n')
45 |
46 | def _commit(self):
47 | """Because the device of this model is different from the other
48 | Cisco devices in commit parameters, it is rewritten.
49 | """
50 | return BASECISCO._commit(self,
51 | saveCommand='copy running-config startup-config',
52 | exitCommand='end')
53 |
54 | def changePassword(self, username, password):
55 | """Because the device of this model is different from the other
56 | Cisco devices in change user's password parameters, it is rewritten.
57 | """
58 | return BASECISCO.addUser(self,
59 | username=username,
60 | password=password,
61 | addCommand='user {username} password {password} role network-admin\n')
62 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n7710.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for n7018.
20 | """
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class N7710(BASECISCO):
25 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
26 | """
27 |
28 | def addUser(self, username, password, admin=False):
29 | """Because the device of this model is different from the other Cisco
30 | devices in creating user parameters, it is rewritten.
31 | """
32 | # default not is Admin
33 | if admin:
34 | return BASECISCO.addUser(self,
35 | username=username,
36 | password=password,
37 | addCommand='user {username} password {password} role network-admin\n')
38 | else:
39 | return BASECISCO.addUser(self,
40 | username=username,
41 | password=password,
42 | addCommand='user {username} password {password} role priv-1\n')
43 |
44 | def _commit(self):
45 | """Because the device of this model is different from the other
46 | Cisco devices in commit parameters, it is rewritten.
47 | """
48 | return BASECISCO._commit(self,
49 | saveCommand='copy running-config startup-config',
50 | exitCommand='end')
51 |
52 | def changePassword(self, username, password):
53 | """Because the device of this model is different from the other
54 | Cisco devices in change user's password parameters, it is rewritten.
55 | """
56 | return BASECISCO.addUser(self,
57 | username=username,
58 | password=password,
59 | addCommand='user {username} password {password} role network-admin\n')
60 |
--------------------------------------------------------------------------------
/lib/forward/devclass/n7718.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for n7018.
21 | """
22 | from forward.devclass.baseCisco import BASECISCO
23 |
24 |
25 | class N7718(BASECISCO):
26 | """This is a manufacturer of cisco, so it is integrated with BASECISCO library.
27 | """
28 |
29 | def addUser(self, username, password, admin=False):
30 | """Because the device of this model is different from the other Cisco
31 | devices in creating user parameters, it is rewritten.
32 | """
33 | # default not is Admin
34 | if admin:
35 | return BASECISCO.addUser(self,
36 | username=username,
37 | password=password,
38 | addCommand='user {username} password {password} role network-admin\n')
39 | else:
40 | return BASECISCO.addUser(self,
41 | username=username,
42 | password=password,
43 | addCommand='user {username} password {password} role priv-1\n')
44 |
45 | def _commit(self):
46 | """Because the device of this model is different from the other
47 | Cisco devices in commit parameters, it is rewritten.
48 | """
49 | return BASECISCO._commit(self,
50 | saveCommand='copy running-config startup-config',
51 | exitCommand='end')
52 |
53 | def changePassword(self, username, password):
54 | """Because the device of this model is different from the other
55 | Cisco devices in change user's password parameters, it is rewritten.
56 | """
57 | return BASECISCO.addUser(self,
58 | username=username,
59 | password=password,
60 | addCommand='user {username} password {password} role network-admin\n')
61 |
--------------------------------------------------------------------------------
/lib/forward/devclass/ne40ex3.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for ne40ex3.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class NE40EX3(BASEHUAWEI):
26 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/r3048g.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for n7018.
20 | """
21 | from forward.devclass.baseRaisecom import BASERAISECOM
22 | from forward.utils.forwardError import ForwardError
23 | import re
24 |
25 |
26 | class R3048G(BASERAISECOM):
27 | """This is a manufacturer of raisecom, so it is integrated with BASERAISECOM library.
28 | """
29 | pass
30 |
--------------------------------------------------------------------------------
/lib/forward/devclass/rg5510.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for rg5510-sshv2.
21 | """
22 | from forward.devclass.baseRuijie import BASERUIJIE
23 |
24 |
25 | class RG5510(BASERUIJIE):
26 |
27 | pass
28 |
--------------------------------------------------------------------------------
/lib/forward/devclass/rg5510v1.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for rg5510-sshv1.
21 | """
22 | from forward.devclass.baseRuijieV1 import BASERUIJIE
23 |
24 |
25 | class RG5510V1(BASERUIJIE):
26 |
27 | pass
28 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s5328.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for s5328.
21 | """
22 |
23 | from forward.devclass.baseHuawei import BASEHUAWEI
24 |
25 |
26 | class S5328(BASEHUAWEI):
27 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
28 | """
29 | pass
30 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s5352.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for s5352.
20 | """
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class S5352(BASEHUAWEI):
25 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
26 | """
27 | pass
28 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s8512.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for s8512.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class S8512(BASEHUAWEI):
26 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s9303.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for s9303.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class S9303(BASEHUAWEI):
26 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s9306.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for s9306.
21 | """
22 | from forward.devclass.baseHuawei import BASEHUAWEI
23 |
24 |
25 | class S9306(BASEHUAWEI):
26 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/s9312e.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for s9312e.
21 | """
22 | import re
23 |
24 | from forward.devclass.baseHuawei import BASEHUAWEI
25 |
26 |
27 | class S9312E(BASEHUAWEI):
28 | """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library.
29 | """
30 | pass
31 |
--------------------------------------------------------------------------------
/lib/forward/devclass/srx3400.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | """
19 | -----Introduction-----
20 | [Core][forward] Device class for srx3400.
21 | """
22 | from forward.devclass.baseJuniper import BASEJUNIPER
23 |
24 |
25 | class SRX3400(BASEJUNIPER):
26 | """This is a manufacturer of juniper, so it is integrated with BASEJUNIPER library.
27 | """
28 | pass
29 |
--------------------------------------------------------------------------------
/lib/forward/devclass/zx5952.py:
--------------------------------------------------------------------------------
1 | # coding:utf-8
2 | #
3 | # This file is part of Forward.
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 | """
18 | -----Introduction-----
19 | [Core][forward] Device class for zx5952.
20 | """
21 | from forward.devclass.baseZte import BASEZTE
22 |
23 |
24 | class ZX5952(BASEZTE):
25 | """This is a manufacturer of zte, so it is integrated with BASEZTE library.
26 | """
27 | pass
28 |
--------------------------------------------------------------------------------
/lib/forward/release.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 |
17 | __version__ = '3.2.0'
18 | __author__ = 'Wang Zhe, Zhang Qi Chuan'
19 |
--------------------------------------------------------------------------------
/lib/forward/utils/__init__.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
--------------------------------------------------------------------------------
/lib/forward/utils/boolean.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | BOOL_TRUE = frozenset(["true", "t", "y", "1", "yes", "on"])
9 |
10 |
11 | def boolean(value):
12 | if value is None:
13 | return False
14 | val = str(value)
15 | if val.lower() in BOOL_TRUE:
16 | return True
17 | else:
18 | return False
19 |
--------------------------------------------------------------------------------
/lib/forward/utils/deviceListSplit.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | """
17 | -----Introduction-----
18 | [Core][Forward] Split deviceList.
19 | ['1.1.1.1','2.2.2.2-2.2.2.4'] -> ['1.1.1.1','2.2.2.2','2.2.2.3','2.2.2.4']
20 | Author: Skate from CSDN blog. Wang Zhe
21 | """
22 |
23 |
24 | class DEVICELIST:
25 | def __init__(self, deviceList):
26 | self.deviceList = deviceList
27 | self.deviceListSplited = []
28 |
29 | def ipToNum(self, ip):
30 | # ip address transformat into binary
31 | ip = [int(x) for x in ip.split('.')]
32 | return ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]
33 |
34 | def numToIp(self, num):
35 | # binary ip address transformat into x.x.x.x
36 | return '%s.%s.%s.%s' % ((num & 0xff000000) >> 24,
37 | (num & 0x00ff0000) >> 16,
38 | (num & 0x0000ff00) >> 8,
39 | num & 0x000000ff)
40 |
41 | def getIp(self, ip):
42 | # input 'x.x.x.x-y.y.y.y' or 'z.z.z.z'
43 | # output all ip within list belongs to 'x.x.x.x-y.y.y.y', except '0.0.0.0'
44 | ipRangeList = [self.ipToNum(x) for x in ip.split('-')]
45 | start, end = ipRangeList[0], ipRangeList[-1]
46 | return [self.numToIp(num) for num in range(start, end + 1) if num & 0xff]
47 |
48 | def getIpList(self):
49 | # deviceList:['1.1.1.1','2.2.2.2-2.2.3.4']
50 | # output all legal ip address within list
51 | for element in self.deviceList:
52 | self.deviceListSplited.extend(self.getIp(element))
53 | return self.deviceListSplited
54 |
--------------------------------------------------------------------------------
/lib/forward/utils/display.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | import sys
9 | import errno
10 |
11 |
12 | class Display(object):
13 | '''
14 | Display messages on screen if necessary.
15 | '''
16 | def __init__(self):
17 | super(Display, self).__init__()
18 |
19 | def display(self, msg, stderr=False):
20 | ''' display a message to the user '''
21 | if not msg.endswith(u'\n'):
22 | msg += u'\n'
23 | output = sys.stderr if stderr else sys.stdout
24 | output.write(msg)
25 | try:
26 | output.flush()
27 | except IOError as e:
28 | if e.errno != errno.EPIPE:
29 | raise
30 |
--------------------------------------------------------------------------------
/lib/forward/utils/error.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 |
9 | class ForwardError(Exception):
10 | '''
11 | This is the base class for all errors raised from Forward code.
12 | '''
13 | pass
14 |
15 |
16 | class ForwardScriptError(ForwardError):
17 | '''
18 | This is the user script error.
19 | '''
20 | pass
21 |
--------------------------------------------------------------------------------
/lib/forward/utils/forwardError.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | """
17 | #Author: Cheung Kei-Chuen
18 | forward specific types of errors
19 | """
20 |
21 |
22 | class ForwardError(Exception):
23 | pass
24 |
--------------------------------------------------------------------------------
/lib/forward/utils/log.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | import os
9 | import sys
10 | import getpass
11 | import logging
12 | from logging.handlers import TimedRotatingFileHandler
13 |
14 | from forward import constants as C
15 | from forward.utils.boolean import boolean
16 | from forward.utils.error import ForwardError
17 |
18 | formatter = logging.Formatter(C.DEFAULT_LOG_FORMAT, C.DEFAULT_DATE_FORMAT)
19 |
20 | default_handler = logging.StreamHandler(sys.__stdout__)
21 | default_handler.formatter = formatter
22 | mypid = str(os.getpid())
23 | user = getpass.getuser()
24 | logger = logging.getLogger("p=%s u=%s |" % (mypid, user))
25 | logger.addHandler(default_handler)
26 | logger.setLevel(eval('logging.%s' % C.DEFAULT_LOGLEVEL))
27 |
28 |
29 | def check_loglevel(level):
30 | ''' check log level legitimacy '''
31 | if isinstance(level, str):
32 | if level.isalpha():
33 | level = level.upper()
34 | if level in logging._levelNames:
35 | level = logging._levelNames[level]
36 | elif level.isdigit():
37 | level = int(level)
38 | if not (isinstance(level, int) and level in logging._levelNames):
39 | raise ForwardError('Unknown Loglevel.')
40 | return level
41 |
42 |
43 | def set_loglevel_only(level=C.DEFAULT_LOGLEVEL):
44 | ''' set log level only '''
45 | try:
46 | level = check_loglevel(level)
47 | logger.setLevel(level)
48 | except:
49 | raise
50 | return logger
51 |
52 |
53 | def add_file_logger(
54 | level=C.DEFAULT_LOGLEVEL,
55 | file=C.DEFAULT_FORWARD_LOG_PATH, default=1):
56 | ''' add a file logger '''
57 | # check file legitimacy
58 | if file and ((os.path.exists(file) and os.access(file, os.W_OK)) or
59 | os.access(os.path.dirname(file), os.W_OK)):
60 | # add log file handler
61 | handler = TimedRotatingFileHandler(
62 | filename=file, when='d', backupCount=1)
63 | # set log format
64 | handler.formatter = formatter
65 | logger.addHandler(handler)
66 | if not boolean(default):
67 | logger.removeHandler(default_handler)
68 | # set log level
69 | level = check_loglevel(level)
70 | logger.setLevel(level)
71 | else:
72 | raise ForwardError('Log File Illegal.')
73 | return logger
74 |
--------------------------------------------------------------------------------
/lib/forward/utils/loginThread.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | """
17 | -----Introduction-----
18 | [Core][Forward] Login method thread function, used for the initialize multithread step
19 | """
20 |
21 | import six
22 |
23 |
24 | def loginThread(instance):
25 | # Login method thread function, used for the initialize multithread step
26 | if not instance.isLogin:
27 | result = instance.login()
28 | if not result['status']:
29 | six.print_('[Login Error]: %s :%s' % (instance.ip, result['errLog']))
30 | # print '[Login Error]: %s :%s' % (instance.ip, result['errLog'])
31 |
--------------------------------------------------------------------------------
/lib/forward/utils/output.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | import os
9 |
10 | from forward import constants as C
11 | from forward.utils.error import ForwardError
12 | from forward.utils.display import Display
13 |
14 |
15 | class Output:
16 |
17 | @staticmethod
18 | def output(data, path, format):
19 | ''' runs a child defined method using the ouput_ pattern '''
20 | if format not in C.DEFAULT_OUTPUT_TYPES:
21 | raise ForwardError('Output Type Illegal.')
22 | output_function = getattr(Output, "output_%s" % format)
23 | if format == 'stdout':
24 | return output_function(data)
25 | if path and os.path.isdir(os.path.dirname(path)):
26 | return output_function(data, path)
27 | else:
28 | raise ForwardError('Output Path Illegal.')
29 |
30 | @staticmethod
31 | def output_stdout(data):
32 | '''print data to standard output'''
33 | data = to_string(data)
34 | delta = 80
35 | display = Display()
36 | display.display('\r\nOUTPUT%s' % ('-' * 74))
37 | for i in range(0, len(data), delta):
38 | display.display(data[i:(i + delta)])
39 | i += delta
40 |
41 | @staticmethod
42 | def output_txt(data, path):
43 | '''write data to specified text file'''
44 | data = to_string(data)
45 | with open('%s.txt' % path, 'w') as f:
46 | f.write(data)
47 |
48 | @staticmethod
49 | def output_xls(data, path):
50 | '''write data to specified excel'''
51 | pass
52 |
53 |
54 | def to_string(data):
55 | try:
56 | data = str(data)
57 | return data
58 | except:
59 | raise ForwardError('Output FORMAT Illegal.')
60 |
--------------------------------------------------------------------------------
/lib/forward/utils/paraCheck.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | """
17 | -----Introduction-----
18 | [Core][Forward] addTargets parameters legal check function
19 | Author: Wang Zhe
20 | """
21 |
22 |
23 | def paraCheck(targets):
24 | # Legal targets: [target1, target2, target3....]
25 | # Legal target type: [ip-str, model-str, user-str, pw-str, kwargs-dict]
26 | # Legal target: ['192.168.1.1', 'n7k', 'admin', 'admin_pw', {'port': 22, 'timeout': 30}]
27 | # Legal target: ['192.168.1.1', 'n7k', 'admin', 'admin_pw', {'port': 22}]
28 | # Legal target: ['192.168.1.1', 'n7k', 'admin', 'admin_pw', {'timeout': 30}]
29 | # Legal target: ['192.168.1.1', 'n7k', 'admin', 'admin_pw']
30 | bool_legal = isinstance(targets, list)
31 |
32 | if bool_legal:
33 | for target in targets:
34 | try:
35 | bool_legal &= (len(target) >= 4 and len(target) < 6)
36 | bool_legal &= isinstance(target[0], str)
37 | bool_legal &= isinstance(target[1], str)
38 | bool_legal &= isinstance(target[2], str)
39 | bool_legal &= isinstance(target[3], str)
40 | if len(target) > 4:
41 | bool_legal &= isinstance(target[4], dict)
42 | else:
43 | bool_legal &= True
44 | except Exception:
45 | return False
46 | if not bool_legal:
47 | break
48 | return bool_legal
49 | else:
50 | return False
51 |
52 |
53 | def int_to_mask(mask_int):
54 | # 24 --> 255.25.255.0
55 | bin_arr = ['0' for i in range(32)]
56 | for i in range(mask_int):
57 | bin_arr[i] = '1'
58 | tmpmask = [''.join(bin_arr[i * 8:i * 8 + 8]) for i in range(4)]
59 | tmpmask = [str(int(tmpstr, 2)) for tmpstr in tmpmask]
60 | return '.'.join(tmpmask)
61 |
62 |
63 | def mask_to_int(mask):
64 | # 255.255.255.0 --> 24
65 | return sum(bin(int(i)).count('1') for i in mask.split('.'))
66 |
67 |
68 | def checkIP(ip):
69 | seg = ip.split(".")
70 | if len(seg) != 4:
71 | return False
72 | else:
73 | return True
74 | for i in seg:
75 | try:
76 | i = int(i)
77 | if i < 0 or i > 255:
78 | return False
79 | except Exception:
80 | return False
81 | return True
82 |
--------------------------------------------------------------------------------
/lib/forward/utils/parse.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | import re
9 |
10 |
11 | def is_quoted(data):
12 | return len(data) > 1 and data[0] == data[-1] \
13 | and data[0] in ('"', "'") and data[-2] != '\\'
14 |
15 |
16 | def unquote(data):
17 | """
18 | removes first and last quotes from a string,
19 | if the string starts and ends with the same quotes
20 | """
21 | if is_quoted(data):
22 | return data[1:-1]
23 | return data
24 |
25 |
26 | def check_ip_format(ip_str):
27 | pattern_string = r"""
28 | \b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
29 | (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
30 | (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
31 | (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b
32 | """
33 | pattern = re.compile(pattern_string, re.X)
34 | if re.match(pattern, ip_str):
35 | return True
36 | else:
37 | return False
38 |
39 |
40 | def ip_to_num(ip):
41 | ''' ip address transformat into binary '''
42 | ip = [int(x) for x in ip.split('.')]
43 | return ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]
44 |
45 |
46 | def num_to_ip(num):
47 | ''' binary ip address transformat into x.x.x.x '''
48 | return '%s.%s.%s.%s' % ((num & 0xff000000) >> 24,
49 | (num & 0x00ff0000) >> 16,
50 | (num & 0x0000ff00) >> 8,
51 | num & 0x000000ff)
52 |
53 |
54 | def get_ip_in_range(ip_range):
55 | """
56 | input 'x.x.x.x-y.y.y.y' or 'z.z.z.z'
57 | output all ip within list belongs to 'x.x.x.x-y.y.y.y',
58 | except '0.0.0.0'
59 | """
60 | ip = [ip_to_num(x) for x in ip_range.split('-')]
61 | return [num_to_ip(x) for x in range(ip[0], ip[-1] + 1) if x & 0xff]
62 |
63 |
64 | def get_ip_list(inventory):
65 | """
66 | input ['1.1.1.1','2.2.2.2-2.2.3.4']
67 | output all legal ip address within list
68 | """
69 | ip_list = []
70 | for x in inventory:
71 | ip_list.extend(get_ip_in_range(x))
72 | return ip_list
73 |
--------------------------------------------------------------------------------
/lib/forward/utils/path.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding:utf-8 -*-
3 | #
4 | # (c) 2016, Leann Mak
5 | #
6 | # This file is part of Forward.
7 |
8 | import os
9 | from errno import EEXIST
10 |
11 | from forward.utils.error import ForwardError
12 |
13 | __all__ = ['purepath', 'makedirs_safe']
14 |
15 |
16 | def purepath(path):
17 | """
18 | returns a path that is free of symlinks, environment
19 | variables, relative path traversals and symbols (~)
20 |
21 | example:
22 | '$HOME/../../var/mail' becomes '/var/spool/mail'
23 | """
24 | return os.path.normpath(
25 | os.path.realpath(os.path.expanduser(
26 | os.path.expandvars(path))))
27 |
28 |
29 | def makedirs_safe(path, mode=None):
30 | """ safe way to create dirs in muliprocess/thread environments """
31 | path = purepath(path)
32 | if not os.path.exists(path):
33 | try:
34 | if mode:
35 | os.makedirs(path, mode)
36 | else:
37 | os.makedirs(path)
38 | except OSError as e:
39 | if e.errno != EEXIST:
40 | raise ForwardError(
41 | 'Unable to create local directories(%s): %s'
42 | % (path, str(e)))
43 |
--------------------------------------------------------------------------------
/lib/forward/utils/sshv2.py:
--------------------------------------------------------------------------------
1 | # This file is part of Forward.
2 | #
3 | # Forward is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Forward is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with this program. If not, see .
15 |
16 | """
17 | -----Introduction-----
18 | [Core][forward] Function for sshv2, by using paramiko module.
19 | Author: Cheung Kei-Chuen, Wang Zhe
20 | """
21 |
22 | import paramiko
23 |
24 |
25 | def sshv2(ip='', username='', password='', timeout=30, port=22):
26 | # return SSH channel, use ssh.invoke_shell() to active a shell, and resize window size
27 | njInfo = {
28 | 'status': True,
29 | 'errLog': '',
30 | 'content': ''
31 | }
32 | try:
33 | port = int(port)
34 | ssh = paramiko.SSHClient()
35 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
36 | ssh.connect(ip, port, username, password, timeout=timeout, allow_agent=False, look_for_keys=False)
37 | njInfo['content'] = ssh
38 | except Exception as e:
39 | njInfo['status'] = False
40 | njInfo['errLog'] = str(e)
41 | return njInfo
42 |
--------------------------------------------------------------------------------
/nosetests.ini:
--------------------------------------------------------------------------------
1 | [nosetests]
2 | verbosity=3
3 | where=unittests
4 | stop=1
5 | with-xunit=1
6 | xunit-file=unittests/nosetests.xml
7 | with-coverage=1
8 | cover-package=lib/forward
9 | cover-xml=1
10 | cover-xml-file=coverage.xml
11 | exe=1
12 |
--------------------------------------------------------------------------------
/protocol/flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | exclude = unittests,build,tests,migrations,.git,.tox,docs,*egg,env,instance,callback
3 | ignore = E402, E123, F401, W605, E501, W601
4 | max-line-length = 120
5 |
--------------------------------------------------------------------------------
/protocol/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #set_env_path
4 | export PATH=/usr/local/bin:$PATH
5 | source /Users/Azrael/.bashrc
6 |
7 | #flake8_check
8 | echo ">[run flake8]"
9 | flake8 ./ --config=protocol/flake8
10 | result_flake8=$?
11 | if ((result_flake8 != 0))
12 | then
13 | exit 1
14 | fi
15 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | flake8==2.4.1
2 | mock==2.0.0
3 | paramiko==1.16.0
4 | pexpect>=4.2.0
5 | nose>=1.3.0
6 | coverage>=4.4.0
7 | six>=1.0.0
8 |
--------------------------------------------------------------------------------
/unittests/__init__.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
--------------------------------------------------------------------------------
/unittests/testAdx03100.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseBrocade import BASEBROCADE
22 |
23 |
24 | class deviceClassAdx03100(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "adx03100"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEBROCADE)
66 |
--------------------------------------------------------------------------------
/unittests/testAsa.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassAsa(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "asa"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testAsr1006.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassAsr1006(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "asr1006"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseBaer.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseBaer(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseBaer"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseCisco.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseCisco(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseCisco"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseDepp.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseDepp(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseDepp"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseF5.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseF5(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseF5"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseHuawei.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseHuawei(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseHuawei"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testBaseSSHV1.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 |
22 |
23 | class deviceClassBaseSSHV1(unittest.TestCase):
24 | def setUp(self):
25 | self.deviceClassName = "baseSSHV1"
26 | self.initParameters = ["ip",
27 | "username",
28 | "password",
29 | "port",
30 | "timeout",
31 | "privilegePw",
32 | "isLogin",
33 | "isEnable",
34 | "channel",
35 | "shell",
36 | "basePrompt",
37 | "prompt",
38 | "moreFlag"]
39 | self.baseClassMethod = ["login",
40 | "logout",
41 | "execute",
42 | "getMore",
43 | "getPrompt",
44 | "cleanBuffer"]
45 |
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | """def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASESSHV2)"""
65 |
--------------------------------------------------------------------------------
/unittests/testBaseSSHV2.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 |
22 |
23 | class deviceClassBaseSSHV2(unittest.TestCase):
24 | def setUp(self):
25 | self.deviceClassName = "baseSSHV2"
26 | self.initParameters = ["ip",
27 | "username",
28 | "password",
29 | "port",
30 | "timeout",
31 | "privilegePw",
32 | "isLogin",
33 | "isEnable",
34 | "channel",
35 | "shell",
36 | "basePrompt",
37 | "prompt",
38 | "moreFlag"]
39 | self.baseClassMethod = ["login",
40 | "logout",
41 | "execute",
42 | "getMore",
43 | "getPrompt",
44 | "cleanBuffer"]
45 |
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | """def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASESSHV2)"""
65 |
--------------------------------------------------------------------------------
/unittests/testBaseTELNET.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 |
22 |
23 | class deviceClassBaseTELNET(unittest.TestCase):
24 | def setUp(self):
25 | self.deviceClassName = "baseTELNET"
26 | self.initParameters = ["ip",
27 | "username",
28 | "password",
29 | "port",
30 | "timeout",
31 | "privilegePw",
32 | "isLogin",
33 | "isEnable",
34 | "channel",
35 | "shell",
36 | "basePrompt",
37 | "prompt",
38 | "moreFlag"]
39 | self.baseClassMethod = ["login",
40 | "logout",
41 | "execute",
42 | "getMore",
43 | "getPrompt",
44 | "cleanBuffer"]
45 |
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | """def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASESSHV2)"""
65 |
--------------------------------------------------------------------------------
/unittests/testBaseZte.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseSSHV2 import BASESSHV2
22 |
23 |
24 | class deviceClassBaseZte(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "baseZte"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASESSHV2)
66 |
--------------------------------------------------------------------------------
/unittests/testC2960.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassC2960(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "c2960"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testC4510.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassC4510(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "c4510"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testC6506.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassC6506(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "c6506"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testC6509.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassC6509(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "c6509"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testE1000e.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassE1000(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "e1000e"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1, 2, 3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1, 2, 3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testE8000e.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassE8000e(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "e8000e"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testE8160e.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassE8160e(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "e8160e"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testF1000.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseDepp import BASEDEPP
22 |
23 |
24 | class deviceClassF1000(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "f1000"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1, 2, 3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1, 2, 3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEDEPP)
66 |
--------------------------------------------------------------------------------
/unittests/testF510000.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseF5 import BASEF5
22 |
23 |
24 | class deviceClassBaseF510000(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "f510000"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEF5)
66 |
--------------------------------------------------------------------------------
/unittests/testM6000.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseZte import BASEZTE
22 |
23 |
24 | class deviceClassM6000(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "m6000"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEZTE)
66 |
--------------------------------------------------------------------------------
/unittests/testMx960.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseJuniper import BASEJUNIPER
22 |
23 |
24 | class deviceClassMx6000(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "mx960"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEJUNIPER)
66 |
--------------------------------------------------------------------------------
/unittests/testN5548.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN5548(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n5548"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testN5596.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN5596(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n5596"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testN7010.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN7010(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n7010"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testN7018.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN7018(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n7018"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testN7710.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN7710(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n7710"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASECISCO)
66 |
--------------------------------------------------------------------------------
/unittests/testN7718.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseCisco import BASECISCO
22 |
23 |
24 | class deviceClassN7718(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "n7718"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASECISCO)
65 |
--------------------------------------------------------------------------------
/unittests/testNe40ex3.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassNe40ex3(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "ne40ex3"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
65 |
--------------------------------------------------------------------------------
/unittests/testRg5510.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseRuijie import BASERUIJIE
22 |
23 |
24 | class deviceClassRg5510(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "rg5510"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASERUIJIE)
66 |
--------------------------------------------------------------------------------
/unittests/testS3300.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseMaipu import BASEMAIPU
22 |
23 |
24 | class deviceClassS3300(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s3300"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1, 2, 3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1, 2, 3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASEMAIPU
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEMAIPU)
66 |
--------------------------------------------------------------------------------
/unittests/testS5328.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS5328(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s5328"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testS5352.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS5352(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s5352"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testS5800.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseFenghuo import BASEFENGHUO
22 |
23 |
24 | class deviceClassS5800(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s5800"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEFENGHUO)
66 |
--------------------------------------------------------------------------------
/unittests/testS8512.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS8512(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s8512"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testS9303.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS9303(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s9303"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testS9306.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS9306(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s9306"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASESSHV2
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
66 |
--------------------------------------------------------------------------------
/unittests/testS9312.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseHuawei import BASEHUAWEI
22 |
23 |
24 | class deviceClassS9312(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "s9312"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | def test_inherit_check(self):
61 | # Inherit from BASESSHV2
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASEHUAWEI)
65 |
--------------------------------------------------------------------------------
/unittests/testSr7750.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseBaer import BASEBAER
22 |
23 |
24 | class deviceClassSr7750(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "sr7750"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASETELNET
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEBAER)
66 |
--------------------------------------------------------------------------------
/unittests/testSr7950.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseBaer import BASEBAER
22 |
23 |
24 | class deviceClassSr7950(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "sr7950"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASEBAER
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEBAER)
66 |
--------------------------------------------------------------------------------
/unittests/testSrx3400.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseJuniper import BASEJUNIPER
22 |
23 | class deviceClassSrx3400(unittest.TestCase):
24 | def setUp(self):
25 | self.deviceClassName = "srx3400"
26 | self.initParameters = ["ip",
27 | "username",
28 | "password",
29 | "port",
30 | "timeout",
31 | "privilegePw",
32 | "isLogin",
33 | "isEnable",
34 | "channel",
35 | "shell",
36 | "basePrompt",
37 | "prompt",
38 | "moreFlag"]
39 | self.baseClassMethod = ["login",
40 | "logout",
41 | "execute",
42 | "getMore",
43 | "getPrompt",
44 | "cleanBuffer"]
45 |
46 | def test_class_parameters(self):
47 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
48 | self.deviceClassName.upper())
49 | for parameter in self.initParameters:
50 | if not hasattr(_dev(1,2,3), parameter):
51 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
52 |
53 | def test_base_class_method(self):
54 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
55 | self.deviceClassName.upper())
56 | for method in self.baseClassMethod:
57 | if not hasattr(_dev(1,2,3), method):
58 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
59 |
60 | def test_inherit_check(self):
61 | # Inherit from BASETELNET
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASEJUNIPER)
65 |
--------------------------------------------------------------------------------
/unittests/testVlb.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseBrocade import BASEBROCADE
22 |
23 |
24 | class deviceClassVlb(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "vlb"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1, 2, 3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1, 2, 3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
63 | self.deviceClassName.upper())
64 | self.assertEquals(cls.__bases__[0], BASEBROCADE)
65 |
--------------------------------------------------------------------------------
/unittests/testVyoslinux.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.bclinux7 import BCLINUX7
22 |
23 | class deviceClassVyoslinux(unittest.TestCase):
24 | def setUp(self):
25 | self.deviceClassName = "vyoslinux"
26 | self.initParameters = ["ip",
27 | "username",
28 | "password",
29 | "port",
30 | "timeout",
31 | "privilegePw",
32 | "isLogin",
33 | "isEnable",
34 | "channel",
35 | "shell",
36 | "basePrompt",
37 | "prompt",
38 | "moreFlag"]
39 | self.baseClassMethod = ["login",
40 | "logout",
41 | "execute",
42 | "getMore",
43 | "getPrompt",
44 | "cleanBuffer"]
45 | def test_class_parameters(self):
46 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
47 | self.deviceClassName.upper())
48 | for parameter in self.initParameters:
49 | if not hasattr(_dev(1,2,3), parameter):
50 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
51 |
52 | def test_base_class_method(self):
53 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
54 | self.deviceClassName.upper())
55 | for method in self.baseClassMethod:
56 | if not hasattr(_dev(1,2,3), method):
57 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
58 |
59 | def test_inherit_check(self):
60 | # Inherit from BCLINUX7
61 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
62 | self.deviceClassName.upper())
63 | self.assertEquals(cls.__bases__[0], BCLINUX7)
64 |
--------------------------------------------------------------------------------
/unittests/testZx5952.py:
--------------------------------------------------------------------------------
1 | # (c) 2015-2018, Wang Zhe , Zhang Qi Chuan
2 | #
3 | # This file is part of Ansible
4 | #
5 | # Forward is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation, either version 3 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # Forward is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program. If not, see .
17 |
18 | import unittest
19 | import importlib
20 | from forward.utils.forwardError import ForwardError
21 | from forward.devclass.baseZte import BASEZTE
22 |
23 |
24 | class deviceClassZx5952(unittest.TestCase):
25 | def setUp(self):
26 | self.deviceClassName = "zx5952"
27 | self.initParameters = ["ip",
28 | "username",
29 | "password",
30 | "port",
31 | "timeout",
32 | "privilegePw",
33 | "isLogin",
34 | "isEnable",
35 | "channel",
36 | "shell",
37 | "basePrompt",
38 | "prompt",
39 | "moreFlag"]
40 | self.baseClassMethod = ["login",
41 | "logout",
42 | "execute",
43 | "getMore",
44 | "getPrompt",
45 | "cleanBuffer"]
46 |
47 | def test_class_parameters(self):
48 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
49 | self.deviceClassName.upper())
50 | for parameter in self.initParameters:
51 | if not hasattr(_dev(1,2,3), parameter):
52 | raise IOError('%s not have parameter:' % (self.deviceClassName), parameter)
53 |
54 | def test_base_class_method(self):
55 | _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
56 | self.deviceClassName.upper())
57 | for method in self.baseClassMethod:
58 | if not hasattr(_dev(1,2,3), method):
59 | raise IOError('%s not have parameter:' % (self.deviceClassName), method)
60 |
61 | def test_inherit_check(self):
62 | # Inherit from BASEZTE
63 | cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)),
64 | self.deviceClassName.upper())
65 | self.assertEquals(cls.__bases__[0], BASEZTE)
66 |
--------------------------------------------------------------------------------