From e22a2a48092cae1d07f4a48abd547eb41d1dd11b Mon Sep 17 00:00:00 2001 From: Zhang Qi-chuan Date: Thu, 26 Dec 2019 15:13:21 +0800 Subject: [PATCH 1/5] increased document of showRun. --- docs/class/sshv2/baer/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/baer/sr7750.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/baer/sr7950.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/brocade/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/brocade/adx03100.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/asa.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/asr1006.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/c2960.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/c4510.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/c6506.md | 29 +++++++++++++++++++++++++ docs/class/sshv2/cisco/c6509.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/n5548.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/n5596.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/n7010.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/n7018.md | 27 +++++++++++++++++++++++ docs/class/sshv2/cisco/n7710.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/cisco/n7718.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/depp/README.md | 29 +++++++++++++++++++++++++ docs/class/sshv2/depp/f1000.md | 29 +++++++++++++++++++++++++ docs/class/sshv2/f5/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/f5/f510000.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/fenghuo/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/fenghuo/s5800.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/fortinet/README.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/fortinet/fg1240.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/fortinet/fg3040.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/fortinet/fg3950.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/README.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/e1000e.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/e8000e.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/e8160e.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/ne40ex16.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/ne40ex3.md | 28 ++++++++++++++++++++++++ docs/class/sshv2/huawei/s5328.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/s5352.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/s8512.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/s9303.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/s9306.md | 27 +++++++++++++++++++++++ docs/class/sshv2/huawei/s9312.md | 27 +++++++++++++++++++++++ docs/class/sshv2/raisecom/README.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/raisecom/r3048g.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/ruijie/README.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/ruijie/rg5510.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/zte/README.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/zte/m6000.md | 30 +++++++++++++++++++++++++- docs/class/sshv2/zte/zx5952.md | 30 +++++++++++++++++++++++++- docs/class/telnet/juniper/README.md | 30 +++++++++++++++++++++++++- docs/class/telnet/juniper/mx960.md | 30 +++++++++++++++++++++++++- docs/class/telnet/juniper/srx3400.md | 30 +++++++++++++++++++++++++- docs/class/telnet/venustech/README.md | 30 +++++++++++++++++++++++++- docs/class/telnet/venustech/usg1000.md | 30 +++++++++++++++++++++++++- 52 files changed, 1464 insertions(+), 13 deletions(-) diff --git a/docs/class/sshv2/baer/README.md b/docs/class/sshv2/baer/README.md index 8b71f98..8a2b8b7 100644 --- a/docs/class/sshv2/baer/README.md +++ b/docs/class/sshv2/baer/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/baer/sr7750.md b/docs/class/sshv2/baer/sr7750.md index 509bf39..f28c0c9 100644 --- a/docs/class/sshv2/baer/sr7750.md +++ b/docs/class/sshv2/baer/sr7750.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/baer/sr7950.md b/docs/class/sshv2/baer/sr7950.md index 69c7ee3..d99ff35 100644 --- a/docs/class/sshv2/baer/sr7950.md +++ b/docs/class/sshv2/baer/sr7950.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/brocade/README.md b/docs/class/sshv2/brocade/README.md index 5f33869..fce4e36 100644 --- a/docs/class/sshv2/brocade/README.md +++ b/docs/class/sshv2/brocade/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/brocade/adx03100.md b/docs/class/sshv2/brocade/adx03100.md index 32f1fad..5f9e03a 100644 --- a/docs/class/sshv2/brocade/adx03100.md +++ b/docs/class/sshv2/brocade/adx03100.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/cisco/README.md b/docs/class/sshv2/cisco/README.md index 0197caa..12d899b 100644 --- a/docs/class/sshv2/cisco/README.md +++ b/docs/class/sshv2/cisco/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/asa.md b/docs/class/sshv2/cisco/asa.md index c6d717d..08c6c68 100644 --- a/docs/class/sshv2/cisco/asa.md +++ b/docs/class/sshv2/cisco/asa.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/asr1006.md b/docs/class/sshv2/cisco/asr1006.md index 692403b..b05f3ac 100644 --- a/docs/class/sshv2/cisco/asr1006.md +++ b/docs/class/sshv2/cisco/asr1006.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/cisco/c2960.md b/docs/class/sshv2/cisco/c2960.md index 43b1fc0..ae594d2 100644 --- a/docs/class/sshv2/cisco/c2960.md +++ b/docs/class/sshv2/cisco/c2960.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/c4510.md b/docs/class/sshv2/cisco/c4510.md index 45bc806..48bd5c0 100644 --- a/docs/class/sshv2/cisco/c4510.md +++ b/docs/class/sshv2/cisco/c4510.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/cisco/c6506.md b/docs/class/sshv2/cisco/c6506.md index 86859a0..a6acdd5 100644 --- a/docs/class/sshv2/cisco/c6506.md +++ b/docs/class/sshv2/cisco/c6506.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,31 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/cisco/c6509.md b/docs/class/sshv2/cisco/c6509.md index f9957cc..dceab8a 100644 --- a/docs/class/sshv2/cisco/c6509.md +++ b/docs/class/sshv2/cisco/c6509.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/cisco/n5548.md b/docs/class/sshv2/cisco/n5548.md index 3ef91a5..d679b4c 100644 --- a/docs/class/sshv2/cisco/n5548.md +++ b/docs/class/sshv2/cisco/n5548.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/n5596.md b/docs/class/sshv2/cisco/n5596.md index 5d74219..21fed3e 100644 --- a/docs/class/sshv2/cisco/n5596.md +++ b/docs/class/sshv2/cisco/n5596.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/n7010.md b/docs/class/sshv2/cisco/n7010.md index a7cbd29..41787d2 100644 --- a/docs/class/sshv2/cisco/n7010.md +++ b/docs/class/sshv2/cisco/n7010.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/n7018.md b/docs/class/sshv2/cisco/n7018.md index 3f41ebd..41787d2 100644 --- a/docs/class/sshv2/cisco/n7018.md +++ b/docs/class/sshv2/cisco/n7018.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/n7710.md b/docs/class/sshv2/cisco/n7710.md index 4ca15d2..829930d 100644 --- a/docs/class/sshv2/cisco/n7710.md +++ b/docs/class/sshv2/cisco/n7710.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/cisco/n7718.md b/docs/class/sshv2/cisco/n7718.md index 7c5e3c1..9d347f2 100644 --- a/docs/class/sshv2/cisco/n7718.md +++ b/docs/class/sshv2/cisco/n7718.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/depp/README.md b/docs/class/sshv2/depp/README.md index 05f8070..3405b22 100644 --- a/docs/class/sshv2/depp/README.md +++ b/docs/class/sshv2/depp/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,31 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/depp/f1000.md b/docs/class/sshv2/depp/f1000.md index eea5af5..a938d72 100644 --- a/docs/class/sshv2/depp/f1000.md +++ b/docs/class/sshv2/depp/f1000.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,31 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/f5/README.md b/docs/class/sshv2/f5/README.md index 8b71f98..8a2b8b7 100644 --- a/docs/class/sshv2/f5/README.md +++ b/docs/class/sshv2/f5/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/f5/f510000.md b/docs/class/sshv2/f5/f510000.md index 29ffad7..a29f65a 100644 --- a/docs/class/sshv2/f5/f510000.md +++ b/docs/class/sshv2/f5/f510000.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -408,4 +409,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/fenghuo/README.md b/docs/class/sshv2/fenghuo/README.md index a620ca6..d5a146d 100644 --- a/docs/class/sshv2/fenghuo/README.md +++ b/docs/class/sshv2/fenghuo/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/fenghuo/s5800.md b/docs/class/sshv2/fenghuo/s5800.md index 49de3d4..72f2adc 100644 --- a/docs/class/sshv2/fenghuo/s5800.md +++ b/docs/class/sshv2/fenghuo/s5800.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/fortinet/README.md b/docs/class/sshv2/fortinet/README.md index d62face..5491f37 100644 --- a/docs/class/sshv2/fortinet/README.md +++ b/docs/class/sshv2/fortinet/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,30 @@ >>> instance.login() >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/fortinet/fg1240.md b/docs/class/sshv2/fortinet/fg1240.md index c2f978d..4f3e204 100644 --- a/docs/class/sshv2/fortinet/fg1240.md +++ b/docs/class/sshv2/fortinet/fg1240.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/fortinet/fg3040.md b/docs/class/sshv2/fortinet/fg3040.md index 7749c0a..3c6cad7 100644 --- a/docs/class/sshv2/fortinet/fg3040.md +++ b/docs/class/sshv2/fortinet/fg3040.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/fortinet/fg3950.md b/docs/class/sshv2/fortinet/fg3950.md index 6c7ae42..5b3ef2c 100644 --- a/docs/class/sshv2/fortinet/fg3950.md +++ b/docs/class/sshv2/fortinet/fg3950.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -410,3 +411,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/huawei/README.md b/docs/class/sshv2/huawei/README.md index 3e43616..51fada5 100644 --- a/docs/class/sshv2/huawei/README.md +++ b/docs/class/sshv2/huawei/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,3 +410,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/e1000e.md b/docs/class/sshv2/huawei/e1000e.md index 0411d09..85fc021 100644 --- a/docs/class/sshv2/huawei/e1000e.md +++ b/docs/class/sshv2/huawei/e1000e.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/huawei/e8000e.md b/docs/class/sshv2/huawei/e8000e.md index a4a920b..0d9c346 100644 --- a/docs/class/sshv2/huawei/e8000e.md +++ b/docs/class/sshv2/huawei/e8000e.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/huawei/e8160e.md b/docs/class/sshv2/huawei/e8160e.md index e223a10..649a73d 100644 --- a/docs/class/sshv2/huawei/e8160e.md +++ b/docs/class/sshv2/huawei/e8160e.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/ne40ex16.md b/docs/class/sshv2/huawei/ne40ex16.md index 29d6ad1..e718073 100644 --- a/docs/class/sshv2/huawei/ne40ex16.md +++ b/docs/class/sshv2/huawei/ne40ex16.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/ne40ex3.md b/docs/class/sshv2/huawei/ne40ex3.md index f2cd5c2..5ee6f8a 100644 --- a/docs/class/sshv2/huawei/ne40ex3.md +++ b/docs/class/sshv2/huawei/ne40ex3.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,30 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/huawei/s5328.md b/docs/class/sshv2/huawei/s5328.md index 2de9ff6..fe944fa 100644 --- a/docs/class/sshv2/huawei/s5328.md +++ b/docs/class/sshv2/huawei/s5328.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/huawei/s5352.md b/docs/class/sshv2/huawei/s5352.md index fde3c72..f83ff7e 100644 --- a/docs/class/sshv2/huawei/s5352.md +++ b/docs/class/sshv2/huawei/s5352.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/huawei/s8512.md b/docs/class/sshv2/huawei/s8512.md index f6b9482..1a88b16 100644 --- a/docs/class/sshv2/huawei/s8512.md +++ b/docs/class/sshv2/huawei/s8512.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/huawei/s9303.md b/docs/class/sshv2/huawei/s9303.md index f0be5d8..b68b739 100644 --- a/docs/class/sshv2/huawei/s9303.md +++ b/docs/class/sshv2/huawei/s9303.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/huawei/s9306.md b/docs/class/sshv2/huawei/s9306.md index 42f9013..4936f51 100644 --- a/docs/class/sshv2/huawei/s9306.md +++ b/docs/class/sshv2/huawei/s9306.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/huawei/s9312.md b/docs/class/sshv2/huawei/s9312.md index 4abc07d..2de5d47 100644 --- a/docs/class/sshv2/huawei/s9312.md +++ b/docs/class/sshv2/huawei/s9312.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -389,3 +390,29 @@ >>> instance.showInterface() >>> {"status":True,"content":[{...},{...}],"errLog":""} +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/raisecom/README.md b/docs/class/sshv2/raisecom/README.md index 2062710..8ee6182 100644 --- a/docs/class/sshv2/raisecom/README.md +++ b/docs/class/sshv2/raisecom/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/raisecom/r3048g.md b/docs/class/sshv2/raisecom/r3048g.md index 5f74b3e..db21fd4 100644 --- a/docs/class/sshv2/raisecom/r3048g.md +++ b/docs/class/sshv2/raisecom/r3048g.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/ruijie/README.md b/docs/class/sshv2/ruijie/README.md index c4e1d4b..c6b1dfe 100644 --- a/docs/class/sshv2/ruijie/README.md +++ b/docs/class/sshv2/ruijie/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/ruijie/rg5510.md b/docs/class/sshv2/ruijie/rg5510.md index ba5835c..2a0b2cc 100644 --- a/docs/class/sshv2/ruijie/rg5510.md +++ b/docs/class/sshv2/ruijie/rg5510.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/zte/README.md b/docs/class/sshv2/zte/README.md index 4f2a3c3..5d37af4 100644 --- a/docs/class/sshv2/zte/README.md +++ b/docs/class/sshv2/zte/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/zte/m6000.md b/docs/class/sshv2/zte/m6000.md index 1e35613..fbaab02 100644 --- a/docs/class/sshv2/zte/m6000.md +++ b/docs/class/sshv2/zte/m6000.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/zte/zx5952.md b/docs/class/sshv2/zte/zx5952.md index e23429e..763c6c9 100644 --- a/docs/class/sshv2/zte/zx5952.md +++ b/docs/class/sshv2/zte/zx5952.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/telnet/juniper/README.md b/docs/class/telnet/juniper/README.md index 3eb83e7..8aec039 100644 --- a/docs/class/telnet/juniper/README.md +++ b/docs/class/telnet/juniper/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/telnet/juniper/mx960.md b/docs/class/telnet/juniper/mx960.md index d7094bd..23abc0b 100644 --- a/docs/class/telnet/juniper/mx960.md +++ b/docs/class/telnet/juniper/mx960.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/telnet/juniper/srx3400.md b/docs/class/telnet/juniper/srx3400.md index 4c87f65..cc2a534 100644 --- a/docs/class/telnet/juniper/srx3400.md +++ b/docs/class/telnet/juniper/srx3400.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/telnet/venustech/README.md b/docs/class/telnet/venustech/README.md index a50b83a..edf89d3 100644 --- a/docs/class/telnet/venustech/README.md +++ b/docs/class/telnet/venustech/README.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file diff --git a/docs/class/telnet/venustech/usg1000.md b/docs/class/telnet/venustech/usg1000.md index ad3f4b6..0ad5a8b 100644 --- a/docs/class/telnet/venustech/usg1000.md +++ b/docs/class/telnet/venustech/usg1000.md @@ -25,6 +25,7 @@ | showLog | 查看SYSLOG服务器地址信息 | | showSnmp | 查看SNMP服务端地址信息 | | showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | ## 接口详情 @@ -409,4 +410,31 @@ >>> instance=...... >>> instance.login() >>> instance.showInterface() - >>> {"status":True,"content":[{...},{...}],"errLog":""} \ No newline at end of file + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} \ No newline at end of file From caf4b2b0bfbf0b302717ab6be6d13fd787d6c894 Mon Sep 17 00:00:00 2001 From: linzhigeng Date: Mon, 2 Mar 2020 17:00:33 +0800 Subject: [PATCH 2/5] add Array(apv11600),Huawei(ce16808,ce16816,ce6881,ne40exx8),Fortinet(fg3800),Baer(7850,),H3C(m9008,m9012,s12508,s12516,s6900),Fenghuo(s5700) --- lib/forward/devclass/apv11600.py | 81 ++++++++++ lib/forward/devclass/asr1006.py | 2 +- lib/forward/devclass/baer7850.py | 131 ++++++++++++++++ lib/forward/devclass/baseArray.py | 51 ++++++ lib/forward/devclass/baseBrocade.py | 10 +- lib/forward/devclass/baseCisco.py | 56 +++---- lib/forward/devclass/baseDepp.py | 2 +- lib/forward/devclass/baseFenghuo.py | 6 +- lib/forward/devclass/baseFortinet.py | 20 +-- lib/forward/devclass/baseH3C.py | 46 ++++-- lib/forward/devclass/baseHuawei.py | 24 +-- lib/forward/devclass/ce16808.py | 28 ++++ lib/forward/devclass/ce16816.py | 28 ++++ lib/forward/devclass/ce6881.py | 28 ++++ lib/forward/devclass/e8000e.py | 4 +- lib/forward/devclass/fg3800.py | 28 ++++ lib/forward/devclass/m9006.py | 6 +- lib/forward/devclass/m9008.py | 30 ++++ lib/forward/devclass/m9012.py | 30 ++++ lib/forward/devclass/ne40ex8.py | 78 ++++++++++ lib/forward/devclass/s12508.py | 30 ++++ lib/forward/devclass/s12516.py | 30 ++++ lib/forward/devclass/s3300.py | 2 +- lib/forward/devclass/s5700.py | 225 +++++++++++++++++++++++++++ lib/forward/devclass/s5800.py | 4 +- lib/forward/devclass/s6900.py | 30 ++++ lib/forward/devclass/s9312.py | 2 +- lib/forward/devclass/vyoslinux.py | 2 +- lib/forward/release.py | 4 +- 29 files changed, 939 insertions(+), 79 deletions(-) create mode 100644 lib/forward/devclass/apv11600.py create mode 100644 lib/forward/devclass/baer7850.py create mode 100644 lib/forward/devclass/baseArray.py create mode 100644 lib/forward/devclass/ce16808.py create mode 100644 lib/forward/devclass/ce16816.py create mode 100644 lib/forward/devclass/ce6881.py create mode 100644 lib/forward/devclass/fg3800.py create mode 100644 lib/forward/devclass/m9008.py create mode 100644 lib/forward/devclass/m9012.py create mode 100644 lib/forward/devclass/ne40ex8.py create mode 100644 lib/forward/devclass/s12508.py create mode 100644 lib/forward/devclass/s12516.py create mode 100644 lib/forward/devclass/s5700.py create mode 100644 lib/forward/devclass/s6900.py diff --git a/lib/forward/devclass/apv11600.py b/lib/forward/devclass/apv11600.py new file mode 100644 index 0000000..586576f --- /dev/null +++ b/lib/forward/devclass/apv11600.py @@ -0,0 +1,81 @@ +# coding:utf-8 +# +# This file is part of Forward +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for APV 11600D. +""" + +from forward.devclass.baseArray import BASEARRAY +import re + + +class APV11600(BASEARRAY): + """The device model belongs to the BROCADE series + so the attributes and methods of BASEBROCADE are inherited. + """ + def showVersion(self): + # cmd = 'show version' + # ArrayOS Rel.APV.10.3.0.35 build on Tue Jul 16 03:29:46 2019 -> Rel.APV.10.3.0.35 + njInfo = { + "status": False, + "content": "", + "errLog": "" + } + prompt = { + "success": "[\r\n]+\S+# ?$", + "eror": "Bad command[\s\S]+" + } + result = self.command("show version", prompt=prompt) + if result["state"] == "success": + # ArrayOS Rel.APV.10.3.0.35 build on Tue Jul 16 03:29:46 2019 -> Rel.APV.10.3.0.35 + tmp = re.search("(Rel\S+)", result["content"]) + if tmp: + njInfo["content"] = tmp.group(1) + else: + njInfo["errLog"] = "Version information was not available." + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showHostname(self): + # cmd = 'show hostname' + '''show hostname + Return: + device hostname + ''' + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'show hostname' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['content'] = result['content'] + njInfo['status'] = True + return njInfo + njInfo['errLog'] = result['errLog'] + return njInfo diff --git a/lib/forward/devclass/asr1006.py b/lib/forward/devclass/asr1006.py index c339467..3b1ff0f 100644 --- a/lib/forward/devclass/asr1006.py +++ b/lib/forward/devclass/asr1006.py @@ -19,7 +19,7 @@ -----Introduction----- [Core][forward] Device class for ASR1006. """ -import re +# import re from forward.devclass.baseCisco import BASECISCO diff --git a/lib/forward/devclass/baer7850.py b/lib/forward/devclass/baer7850.py new file mode 100644 index 0000000..17ff2cf --- /dev/null +++ b/lib/forward/devclass/baer7850.py @@ -0,0 +1,131 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for 7850. +""" +from forward.devclass.baseBaer import BASEBAER +import string +import re + + +class BAER7850(BASEBAER): + """This is a manufacturer of baer, so it is integrated with BASEBAER library.""" + def showInterfacePower(self, port): + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(#|>) ?$", + "error": "Unknown command[\s\S]+", + } + cmd = 'show port ' + port + ' detail | match dBm' + resultPower = self.command(cmd=cmd, prompt=prompt) + if not resultPower['status'] or resultPower['state'] != 'success': + njInfo['errLog'] = resultPower['errLog'] + return njInfo + result = {} + resultPower = resultPower['content'].split('\r\n') + resultPower.pop(0) + resultPower.pop(-1) + for line in resultPower: + power = line.strip().split() + if power[4] == 'dBm)': + _power = power[5] + _power_high = power[7] + _power_low = power[8] + else: + _power = power[4] + _power_high = power[6] + _power_low = power[7] + if string.atof(_power) > string.atof(_power_high): + result['TX'] = 'HIGH' + elif string.atof(_power) < string.atof(_power_low): + result['TX'] = 'LOW' + else: + result['TX'] = 'normal' + if string.atof(_power) > string.atof(_power_high): + result['RX'] = 'HIGH' + elif string.atof(_power) < string.atof(_power_low): + result['RX'] = 'LOW' + else: + result['RX'] = 'normal' + njInfo['status'] = True + njInfo['content'] = result + return njInfo + + def showSyslog(self): + """show the system syslog server and logbuffer + example cmd: + show log syslog + + Returns: + logbuffer level and syslog server level + """ + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+.+(#|>) ?$", + "error": "Unknown command[\s\S]+", + } + logInfo = { + 'status': True, + 'errLog': '', + 'content': {} + } + cmd = 'show log syslog' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status'] or result['state'] != 'success': + njInfo['errLog'] = result['errLog'] + return njInfo + syslogList= re.findall('(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\w+)', result['content']) + logInfo['content']['syslog_server'] = {} + for serinfo in syslogList: + logInfo['content']['syslog_server'][serinfo[0]] = serinfo[1] + logInfo['content']['logbuffer'] = 'NULL' + njInfo['status'] = True + njInfo['content'] = logInfo + return njInfo + + def showHostname(self): + # cmd = 'show system information' + # System Name : DGJD-PSC-P9F1-P0D1-S-HL-7850GW-1 -> DGJD-PSC-P9F1-P0D1-S-HL-7850GW-1 + njInfo = { + 'status': False, + 'content': "", + 'errLog': '' + } + cmd = "show system information" + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Unrecognized command[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = result["content"].split() + if tmp: + njInfo["content"] = tmp[1] + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo diff --git a/lib/forward/devclass/baseArray.py b/lib/forward/devclass/baseArray.py new file mode 100644 index 0000000..7607df6 --- /dev/null +++ b/lib/forward/devclass/baseArray.py @@ -0,0 +1,51 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +-----Introduction----- +[Core][forward] Device class for Array. +""" +from forward.devclass.baseSSHV2 import BASESSHV2 +# import re + + +class BASEARRAY(BASESSHV2): + """This is a manufacturer of baer, using the + SSHV2 version of the protocol, so it is integrated with BASESSHV2 library. + """ + def generalMode(self): + pass + + def privilegeMode(self): + pass + + def showLog(self): + pass + + def showVersion(self): + pass + + def showNtp(self): + pass + + def showInterface(self): + pass + + def showRun(self): + pass + + def showHostname(self): + pass diff --git a/lib/forward/devclass/baseBrocade.py b/lib/forward/devclass/baseBrocade.py index f6647f9..bbf31e1 100644 --- a/lib/forward/devclass/baseBrocade.py +++ b/lib/forward/devclass/baseBrocade.py @@ -277,11 +277,11 @@ def showRoute(self,): "via": "", } tmp = re.search("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+\ -([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+\ -([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+\ -(\S+)\s+\ -\S+\s+\ -(\S+)", _interfaceInfo) + ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+\ + ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+\ + (\S+)\s+\ + \S+\s+\ + (\S+)", _interfaceInfo) if tmp: lineInfo["net"] = tmp.group(1) lineInfo["mask"] = mask_to_int(tmp.group(2)) diff --git a/lib/forward/devclass/baseCisco.py b/lib/forward/devclass/baseCisco.py index fc0f7e9..ad5d9b1 100644 --- a/lib/forward/devclass/baseCisco.py +++ b/lib/forward/devclass/baseCisco.py @@ -23,7 +23,7 @@ import re from forward.devclass.baseSSHV2 import BASESSHV2 -from forward.utils.forwardError import ForwardError +# from forward.utils.forwardError import ForwardError from forward.utils.paraCheck import checkIP @@ -716,7 +716,7 @@ def createInterfaceVlan(self, vlan_id, ip=None, mask=None, description="None"): if not self.vlanExist(vlan_id)["status"]: # no exists. result["errLog"] = "The vlan({vlan_id}) does not exists,\ -thus can't create interface-vlan.".format(vlan_id=vlan_id) + thus can't create interface-vlan.".format(vlan_id=vlan_id) return result # Enter config-mode. tmp = self.configMode() @@ -848,15 +848,17 @@ def showOSPF(self, cmd="show ip ospf neighbors"): for line in dataLine: line = line.split() if len(line) == 7: - njInfo["content"].append({ - "neighbor-id": line[0], - "pri": line[1], - "state": line[2] + line[3], - "uptime": line[4], - "address": line[5], - "interface": line[6], - "deadTime": ""} - ) + njInfo["content"].append( + { + "neighbor-id": line[0], + "pri": line[1], + "state": line[2] + line[3], + "uptime": line[4], + "address": line[5], + "interface": line[6], + "deadTime": "" + } + ) else: # The line does not matched data of expection. continue @@ -880,21 +882,23 @@ def showVRRP(self, cmd="show hsrp brief"): for line in result["content"].split("\r\n"): dataLine = line.split() try: - njInfo["content"].append({ - "vr-state": "", - "vr-mode": "", - "timer": "", - "type": "", - "interface": dataLine[0], - "group": dataLine[1], - "prio": dataLine[2], - "p": dataLine[3], - "state": dataLine[4], - "active": dataLine[5], - "standby-addr": dataLine[6], - "group-addr": dataLine[7], - "address": dataLine[8]} - ) + njInfo["content"].append( + { + "vr-state": "", + "vr-mode": "", + "timer": "", + "type": "", + "interface": dataLine[0], + "group": dataLine[1], + "prio": dataLine[2], + "p": dataLine[3], + "state": dataLine[4], + "active": dataLine[5], + "standby-addr": dataLine[6], + "group-addr": dataLine[7], + "address": dataLine[8] + } + ) except Exception: pass return njInfo diff --git a/lib/forward/devclass/baseDepp.py b/lib/forward/devclass/baseDepp.py index c54b665..655190c 100644 --- a/lib/forward/devclass/baseDepp.py +++ b/lib/forward/devclass/baseDepp.py @@ -21,7 +21,7 @@ """ from forward.devclass.baseSSHV2 import BASESSHV2 import re -import os +# import os class BASEDEPP(BASESSHV2): diff --git a/lib/forward/devclass/baseFenghuo.py b/lib/forward/devclass/baseFenghuo.py index 0e07cb0..05a80ae 100644 --- a/lib/forward/devclass/baseFenghuo.py +++ b/lib/forward/devclass/baseFenghuo.py @@ -21,7 +21,7 @@ """ import re from forward.devclass.baseSSHV2 import BASESSHV2 -from forward.utils.forwardError import ForwardError +# from forward.utils.forwardError import ForwardError class BASEFENGHUO(BASESSHV2): @@ -289,8 +289,8 @@ def showRoute(self,): "via": "", } tmp = re.search("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/([0-9]{1,2})\s+\ -([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+([0-9]+/[0-9]+)\s+\ -(\S+)\s+(\S+)", _interfaceInfo) + ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+([0-9]+/[0-9]+)\s+\ + (\S+)\s+(\S+)", _interfaceInfo) if tmp: lineInfo["net"] = tmp.group(1) lineInfo["mask"] = tmp.group(2) diff --git a/lib/forward/devclass/baseFortinet.py b/lib/forward/devclass/baseFortinet.py index dee73d3..0cdfd22 100644 --- a/lib/forward/devclass/baseFortinet.py +++ b/lib/forward/devclass/baseFortinet.py @@ -503,15 +503,17 @@ def showOSPF(self, cmd="get router info ospf neighbor"): for line in dataLine: line = line.split() if len(line) == 7: - njInfo["content"].append({ - "neighbor-id": line[0], - "pri": line[1], - "state": line[2] + line[3], - "uptime": "", - "address": line[5], - "interface": line[6], - "deadTime": line[4]} - ) + njInfo["content"].append( + { + "neighbor-id": line[0], + "pri": line[1], + "state": line[2] + line[3], + "uptime": "", + "address": line[5], + "interface": line[6], + "deadTime": line[4] + } + ) else: # The line does not matched data of expection. continue diff --git a/lib/forward/devclass/baseH3C.py b/lib/forward/devclass/baseH3C.py index 2fa0ace..f3f3aab 100644 --- a/lib/forward/devclass/baseH3C.py +++ b/lib/forward/devclass/baseH3C.py @@ -25,7 +25,7 @@ import time import random from forward.devclass.baseSSHV2 import BASESSHV2 -from forward.utils.forwardError import ForwardError +# from forward.utils.forwardError import ForwardError from forward.utils.paraCheck import checkIP from forward.utils.deviceListSplit import DEVICELIST @@ -583,7 +583,7 @@ def createInterfaceVlan(self, vlan_id, ip=None, mask=None, description="None"): if not self.vlanExist(vlan_id)["status"]: # no exists. result["errLog"] = "The vlan({vlan_id}) does not exists,\ -thus can't create interface-vlan.".format(vlan_id=vlan_id) + thus can't create interface-vlan.".format(vlan_id=vlan_id) return result prompt1 = { "success": "[\r\n]+\S+Vlanif{vlan_id}\] ?$".format(vlan_id=vlan_id), @@ -696,15 +696,17 @@ def showOSPF(self, cmd="display ospf peer brief"): for line in dataLine: line = line.split() if len(line) == 4: - njInfo["content"].append({ - "neighbor-id": line[2], - "pri": "", - "state": line[3], - "uptime": "", - "address": line[0], - "deadTime": "", - "interface": line[1]}, - ) + njInfo["content"].append( + { + "neighbor-id": line[2], + "pri": "", + "state": line[3], + "uptime": "", + "address": line[0], + "deadTime": "", + "interface": line[1] + } + ) else: # The line does not matched data of expection. continue @@ -1101,3 +1103,25 @@ def showRun(self): else: njInfo["content"] = "\r\r\n".join(njInfo["content"].split("\r\r\n")[1:-1]) return njInfo + + def showHostname(self): + # cmd = 'display current-configuration | i sysname' + njInfo = { + 'status': False, + 'content': "", + 'errLog': '' + } + cmd = "display current-configuration | i sysname" + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Unrecognized command[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = result["content"].split() + if tmp: + njInfo["content"] = tmp[1] + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo diff --git a/lib/forward/devclass/baseHuawei.py b/lib/forward/devclass/baseHuawei.py index 0fcaaab..932bc2f 100644 --- a/lib/forward/devclass/baseHuawei.py +++ b/lib/forward/devclass/baseHuawei.py @@ -23,7 +23,7 @@ import re import logging from forward.devclass.baseSSHV2 import BASESSHV2 -from forward.utils.forwardError import ForwardError +# from forward.utils.forwardError import ForwardError from forward.utils.paraCheck import checkIP @@ -578,7 +578,7 @@ def createInterfaceVlan(self, vlan_id, ip=None, mask=None, description="None"): if not self.vlanExist(vlan_id)["status"]: # no exists. result["errLog"] = "The vlan({vlan_id}) does not exists,\ -thus can't create interface-vlan.".format(vlan_id=vlan_id) + thus can't create interface-vlan.".format(vlan_id=vlan_id) return result prompt1 = { "success": "[\r\n]+\S+Vlanif{vlan_id}\] ?$".format(vlan_id=vlan_id), @@ -692,15 +692,17 @@ def showOSPF(self, cmd="display ospf peer brief"): for line in dataLine: line = line.split() if len(line) == 4: - njInfo["content"].append({ - "neighbor-id": line[2], - "pri": "", - "state": line[3], - "uptime": "", - "address": line[0], - "deadTime": "", - "interface": line[1]}, - ) + njInfo["content"].append( + { + "neighbor-id": line[2], + "pri": "", + "state": line[3], + "uptime": "", + "address": line[0], + "deadTime": "", + "interface": line[1] + } + ) else: # The line does not matched data of expection. continue diff --git a/lib/forward/devclass/ce16808.py b/lib/forward/devclass/ce16808.py new file mode 100644 index 0000000..cd67ff6 --- /dev/null +++ b/lib/forward/devclass/ce16808.py @@ -0,0 +1,28 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for ce16808. +""" +from forward.devclass.baseHuawei import BASEHUAWEI + + +class CE16808(BASEHUAWEI): + """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. + """ + pass diff --git a/lib/forward/devclass/ce16816.py b/lib/forward/devclass/ce16816.py new file mode 100644 index 0000000..9772ded --- /dev/null +++ b/lib/forward/devclass/ce16816.py @@ -0,0 +1,28 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for ce16816. +""" +from forward.devclass.baseHuawei import BASEHUAWEI + + +class CE16816(BASEHUAWEI): + """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. + """ + pass diff --git a/lib/forward/devclass/ce6881.py b/lib/forward/devclass/ce6881.py new file mode 100644 index 0000000..f4dd3f5 --- /dev/null +++ b/lib/forward/devclass/ce6881.py @@ -0,0 +1,28 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for ce6881. +""" +from forward.devclass.baseHuawei import BASEHUAWEI + + +class CE6881(BASEHUAWEI): + """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. + """ + pass diff --git a/lib/forward/devclass/e8000e.py b/lib/forward/devclass/e8000e.py index cb972b8..c7a5b11 100644 --- a/lib/forward/devclass/e8000e.py +++ b/lib/forward/devclass/e8000e.py @@ -553,8 +553,8 @@ def showPolicy(self, sZone, dZone, bound, sourceAddress, destAddress, service): njInfo["errLog"] = "[Forward Error] Please specify a parameter for the service." return njInfo cmd = 'display policy interzone %s \ -%s %s source address-set %s destination \ -address-set %s service-set %s' % (sZone, dZone, bound, sourceAddress, destAddress, service) + %s %s source address-set %s destination \ + address-set %s service-set %s' % (sZone, dZone, bound, sourceAddress, destAddress, service) result = self.command(cmd=cmd, prompt=prompt) if not result['status'] or result['state'] != 'success': njInfo['errLog'] = result['errLog'] diff --git a/lib/forward/devclass/fg3800.py b/lib/forward/devclass/fg3800.py new file mode 100644 index 0000000..94671ed --- /dev/null +++ b/lib/forward/devclass/fg3800.py @@ -0,0 +1,28 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for fg3800. +""" +from forward.devclass.baseFortinet import BASEFORTINET + + +class FG3800(BASEFORTINET): + """This is a manufacturer of fortinet, so it is integrated with BASEFORTINET library. + """ + pass diff --git a/lib/forward/devclass/m9006.py b/lib/forward/devclass/m9006.py index 7f918f8..4e323eb 100644 --- a/lib/forward/devclass/m9006.py +++ b/lib/forward/devclass/m9006.py @@ -20,11 +20,11 @@ [Core][forward] Device class for M9006. """ from forward.devclass.baseH3C import BASEH3C -import re -import string +# import re +# import string class M9006(BASEH3C): """This is a manufacturer of h3c, it is integrated with BASEH3C library. """ - pass \ No newline at end of file + pass diff --git a/lib/forward/devclass/m9008.py b/lib/forward/devclass/m9008.py new file mode 100644 index 0000000..febc388 --- /dev/null +++ b/lib/forward/devclass/m9008.py @@ -0,0 +1,30 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for M9008. +""" +from forward.devclass.baseH3C import BASEH3C +# import re +# import string + + +class M9008(BASEH3C): + """This is a manufacturer of h3c, it is integrated with BASEH3C library. + """ + pass diff --git a/lib/forward/devclass/m9012.py b/lib/forward/devclass/m9012.py new file mode 100644 index 0000000..c6bac9f --- /dev/null +++ b/lib/forward/devclass/m9012.py @@ -0,0 +1,30 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for M9012. +""" +from forward.devclass.baseH3C import BASEH3C +# import re +# import string + + +class M9012(BASEH3C): + """This is a manufacturer of h3c, it is integrated with BASEH3C library. + """ + pass diff --git a/lib/forward/devclass/ne40ex8.py b/lib/forward/devclass/ne40ex8.py new file mode 100644 index 0000000..7d809a6 --- /dev/null +++ b/lib/forward/devclass/ne40ex8.py @@ -0,0 +1,78 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +-----Introduction----- +[Core][forward] Device class for ne40ex8/ne40ex8a. +""" +import re +from forward.devclass.baseHuawei import BASEHUAWEI +from forward.utils.sshv2 import sshv2 + + +class NE40EX8(BASEHUAWEI): + """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. + """ + + def showRun(self): + """show the system config + Returns: + the system config of the device + """ + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(#|>) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'dis cur' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['status'] = True + njInfo['content'] = result['content'] + return njInfo + + def showHostname(self): + '''show hostname + Return: + device hostname + ''' + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'display current-configuration | include sysname' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['content'] = re.findall('sysname (\S+)', result['content'])[0] + njInfo['status'] = True + return njInfo + njInfo['errLog'] = result['errLog'] + return njInfo diff --git a/lib/forward/devclass/s12508.py b/lib/forward/devclass/s12508.py new file mode 100644 index 0000000..c88f5fa --- /dev/null +++ b/lib/forward/devclass/s12508.py @@ -0,0 +1,30 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for s12508. +""" +from forward.devclass.baseH3C import BASEH3C +# import re +# import string + + +class S12508(BASEH3C): + """This is a manufacturer of h3c, it is integrated with BASEH3C library. + """ + pass diff --git a/lib/forward/devclass/s12516.py b/lib/forward/devclass/s12516.py new file mode 100644 index 0000000..cbdc932 --- /dev/null +++ b/lib/forward/devclass/s12516.py @@ -0,0 +1,30 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for s12516. +""" +from forward.devclass.baseH3C import BASEH3C +# import re +# import string + + +class S12516(BASEH3C): + """This is a manufacturer of h3c, it is integrated with BASEH3C library. + """ + pass diff --git a/lib/forward/devclass/s3300.py b/lib/forward/devclass/s3300.py index c7b1235..aa22333 100644 --- a/lib/forward/devclass/s3300.py +++ b/lib/forward/devclass/s3300.py @@ -34,7 +34,7 @@ def __init__(self, *args, **kws): """ BASEMAIPU.__init__(self, *args, **kws) self.moreFlag = re.escape('....press ENTER to next \ -line, Q to quit, other key to next page....') + line, Q to quit, other key to next page....') def _recv(self, _prompt): """A message returned after the receiving device has executed the command. diff --git a/lib/forward/devclass/s5700.py b/lib/forward/devclass/s5700.py new file mode 100644 index 0000000..2dd0f53 --- /dev/null +++ b/lib/forward/devclass/s5700.py @@ -0,0 +1,225 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +-----Introduction----- +[Core][forward] Device class for s5700. +""" +from forward.devclass.baseFenghuo import BASEFENGHUO +from forward.utils.forwardError import ForwardError +import re + + +class S5700(BASEFENGHUO): + """This is a manufacturer of fenghuo, so it is integrated with BASEFENGHUO library. + """ + + def isVlanInPort(self, vlan=None, port=None): + """Check that the Vlan exists in the port. + """ + info = {"status": False, + "content": "", + "errLog": ""} + # Parameters check. + if (vlan is None) or (port is None): + raise ForwardError('Specify the `vlan` and `port` parameters') + # Execute command. + info = self.execute("show run") + if not info["status"]: + raise ForwardError(info["errLog"]) + try: + # Keyword search + tmp = re.search("\![\r\n]+interface gigaethernet {port}[\s\S]*por\ + t link-type (access|trunk)[\s\S]*port .* vlan .*{vlan}".format(vlan=vlan, port=port), info["content"]) + if tmp: + # Vlan in the port, case 1 + if tmp.group(1) == "access": + raise ForwardError("Configuration found, but port link - type is 'access', Not a trunk") + info["content"] = tmp.group().split("ABCDEFG") + info["status"] = True + else: + # No exists' + raise ForwardError('No exists') + except Exception as e: + info["errLog"] = str(e) + info["status"] = False + return info + + def createVlanInPort(self, port=None, vlan=None): + """Create a vlan on the port. + """ + # Prameters check. + if (port is None) or (vlan is None): + raise ForwardError('Specify the `port` parameter') + info = {"status": False, + "content": "", + "errLog": ""} + try: + # switch to enable mode + tmp = self.privilegeMode() + if not tmp["status"]: + raise ForwardError(tmp['errLog']) + # else ,successed + # switch to config mode + tmp = self._configMode() + if not tmp["status"]: + raise ForwardError(tmp['errLog']) + # else ,successed + # switch to port mode + info["content"] = "" + self.shell.send("interface gigaethernet {port}\n".format(port=port)) + # Host prompt is modified + while not re.search(self.basePrompt, info['content'].split('\n')[-1]): + info['content'] += self.shell.recv(1024).decode() + # release host prompt + self.getPrompt() + # Check the port mode + if not re.search('config.*-ge', self.prompt): + raise ForwardError('Switch to port mode is failed [%s]' % info["content"]) + # else successed. + tmp = self.execute("port link-type trunk") + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + tmp = self.execute("port trunk allow-pass vlan {vlan}".format(vlan=vlan)) + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + else: + # Check the returned 'tmp['content']', which indicates failure if it contains' Failed ' + if re.search('%Failed', tmp["content"]): + raise ForwardError('Execute the command "port trunk allow-pass vlan" is failed ,\ + result is [%s] ' % tmp["content"]) + # else successed + tmp = self.execute("no shutdown") + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + # quit port mode + self.shell.send("quit\n") + info["content"] = "" + while not re.search(self.basePrompt, info['content'].split('\n')[-1]): + info['content'] += self.shell.recv(1024).decode() + self.getPrompt() + # save configuration + tmp = self._commit() + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + # Verify that it is correct + tmp = self.isVlanInPort(port=port, vlan=vlan) + if not tmp["status"]: + raise ForwardError("The configuration command has been executed,\ + but the check configuration does not exist! [%s]" % tmp["errLog"]) + else: + # successed + info["content"] = "successed" + info["status"] = True + except Exception as e: + info["errLog"] = str(e) + info["status"] = False + return info + + def isTrunkInInterface(self, port=None, vlan=None): + """Check the relationship between interface and turnk. + """ + info = {"status": False, + "content": "", + "errLog": ""} + # Prameters check. + if (vlan is None) or (port is None): + raise ForwardError('Specify the `vlan` and `port` parameters') + while True: + # Execute command. + info = self.execute("show run") + if not info["status"]: + raise ForwardError(info["errLog"]) + try: + # Keyword search. + tmp = re.search("interface eth-trunk {port}[\r\n]+ mode .*[\r\n]+ por\ + t .*[\r\n]+ port .* vlan .*{vlan}".format(port=port, vlan=vlan), info['content']) + if tmp: + # Exists. + info["status"] = True + break + elif re.search('Command is in use by', info["content"]): + # Rechecking... + continue + else: + info["errLog"] = info['errLog'] + break + except Exception as e: + info["errLog"] = str(e) + info["status"] = False + break + return info + + def trunkOpenVlan(self, port=None, vlan=None): + """Create a vlan on turnk. + """ + info = {"status": False, + "content": "", + "errLog": ""} + # Parameters check. + if (vlan is None) or (port is None): + raise ForwardError('Specify the `vlan` and `port` parameters') + try: + # switch to enable mode + tmp = self.privilegeMode() + if not tmp["status"]: + raise ForwardError(tmp['errLog']) + # else ,successed + # switch to config mode + tmp = self._configMode() + if not tmp["status"]: + raise ForwardError(tmp['errLog']) + # else ,successed + # switch to port mode + self.shell.send("interface eth-trunk {port}\n".format(port=port)) + # Host prompt is modified + while not re.search(self.basePrompt, info['content'].split('\n')[-1]): + info['content'] += self.shell.recv(1024).decode() + # release host prompt + self.getPrompt() + # Keyword search. + if not re.search("config.*-eth.*-trunk.*-{port}".format(port=port), self.prompt): + raise ForwardError('[trunkOpenVlan] Switch to port mode is failed [%s]' % info["content"]) + # Execute command. + tmp = self.execute("port trunk allow-pass vlan {vlan}".format(vlan=vlan)) + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + else: + # Check the returned 'tmp['content']', which indicates failure if it contains' Failed ' + if re.search('%Failed', tmp["content"]): + raise ForwardError('Execute the command "port trunk allow-pass vlan" is failed ,\ + result is [%s] ' % tmp["content"]) + # quit port mode + self.shell.send("quit\n") + info["content"] = "" + while not re.search(self.basePrompt, info['content'].split('\n')[-1]): + info['content'] += self.shell.recv(1024).decode() + # save configuration + self.getPrompt() + # Save the configuration. + tmp = self._commit() + if not tmp["status"]: + raise ForwardError(tmp["errLog"]) + # Verify that it is correct + tmp = self.isTrunkInInterface(port=port, vlan=vlan) + if not tmp["status"]: + raise ForwardError("The configuration command has been executed,\ + but the check configuration does not exist! [%s]" % tmp['errLog']) + info["status"] = True + except Exception as e: + info["errLog"] = str(e) + info["status"] = False + return info diff --git a/lib/forward/devclass/s5800.py b/lib/forward/devclass/s5800.py index ac36148..4464c6f 100644 --- a/lib/forward/devclass/s5800.py +++ b/lib/forward/devclass/s5800.py @@ -43,7 +43,7 @@ def isVlanInPort(self, vlan=None, port=None): try: # Keyword search tmp = re.search("\![\r\n]+interface gigaethernet {port}[\s\S]*por\ -t link-type (access|trunk)[\s\S]*port .* vlan .*{vlan}".format(vlan=vlan, port=port), info["content"]) + t link-type (access|trunk)[\s\S]*port .* vlan .*{vlan}".format(vlan=vlan, port=port), info["content"]) if tmp: # Vlan in the port, case 1 if tmp.group(1) == "access": @@ -146,7 +146,7 @@ def isTrunkInInterface(self, port=None, vlan=None): try: # Keyword search. tmp = re.search("interface eth-trunk {port}[\r\n]+ mode .*[\r\n]+ por\ - t .*[\r\n]+ port .* vlan .*{vlan}".format(port=port, vlan=vlan), info['content']) + t .*[\r\n]+ port .* vlan .*{vlan}".format(port=port, vlan=vlan), info['content']) if tmp: # Exists. info["status"] = True diff --git a/lib/forward/devclass/s6900.py b/lib/forward/devclass/s6900.py new file mode 100644 index 0000000..9c9323d --- /dev/null +++ b/lib/forward/devclass/s6900.py @@ -0,0 +1,30 @@ +# coding:utf-8 +# +# This file is part of Forward. +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +-----Introduction----- +[Core][forward] Device class for s6900. +""" +from forward.devclass.baseH3C import BASEH3C +# import re +# import string + + +class S6900(BASEH3C): + """This is a manufacturer of h3c, it is integrated with BASEH3C library. + """ + pass diff --git a/lib/forward/devclass/s9312.py b/lib/forward/devclass/s9312.py index d86a36a..044be0b 100644 --- a/lib/forward/devclass/s9312.py +++ b/lib/forward/devclass/s9312.py @@ -184,7 +184,7 @@ def trunkOpenVlan(self, port=None, vlan=None): # Keyword search. if not re.search('Trunk{port}'.format(port=port), self.prompt): raise ForwardError("Failed to enter port mode,command:interface \ -Eth-Trunk {port} [{info}]".format(port=port, info=info["content"])) + Eth-Trunk {port} [{info}]".format(port=port, info=info["content"])) # set vlan info["content"] = "" self.shell.send("{cmd}\n".format(cmd=cmd)) diff --git a/lib/forward/devclass/vyoslinux.py b/lib/forward/devclass/vyoslinux.py index d441afc..29201d2 100644 --- a/lib/forward/devclass/vyoslinux.py +++ b/lib/forward/devclass/vyoslinux.py @@ -51,7 +51,7 @@ def execute(self, cmd): # resultPattern = '[\r\n]+([\s\S]*)[\r\n]+' + self.prompt resultPatternOld = '[\r\n]+([\s\S]*)[\r\n]+' + self.prompt resultPattern = "[\r\n]+([\s\S]*)({character1_1}|{character1_2}|{character1_\ -3}|{character1_4}){character2}".format( + 3}|{character1_4}){character2}".format( character1_1=re.escape("\x1b[m\r\n\x1b[m\r\n\r\x1b[K\x1b[?1l\x1b>"), character1_2=re.escape('\x1b[m\r\n\r\x1b[K\x1b[?1l\x1b>'), character1_3=re.escape('\x1b[?1h\x1b=\r\r\x1b[K\x1b[?1l\x1b>'), diff --git a/lib/forward/release.py b/lib/forward/release.py index 14dab58..6f5be8e 100755 --- a/lib/forward/release.py +++ b/lib/forward/release.py @@ -14,5 +14,5 @@ # along with this program. If not, see . -__version__ = '3.2.0' -__author__ = 'Wang Zhe, Zhang Qi Chuan' +__version__ = '3.3.0' +__author__ = 'Wang Zhe, Zhang Qi Chuan, Lin Zhigeng' From fafbaac9929d7d836737654f1e692ca7383a0591 Mon Sep 17 00:00:00 2001 From: linzhigeng Date: Thu, 12 Mar 2020 15:00:44 +0800 Subject: [PATCH 3/5] pep8 check --- lib/forward/devclass/baer7850.py | 14 +- lib/forward/devclass/baseH3C.py | 239 ++++++++---- lib/forward/devclass/baseJuniper.py | 32 +- lib/forward/devclass/baseRuijieV1.py | 2 +- lib/forward/devclass/baseVenustech.py | 20 +- lib/forward/devclass/ce16808.py | 50 ++- lib/forward/devclass/ce16816.py | 50 ++- lib/forward/devclass/ce6881.py | 50 ++- lib/forward/devclass/e8000e.py | 2 +- lib/forward/devclass/fg3800.py | 223 ++++++++++- lib/forward/devclass/n5548.py | 2 +- lib/forward/devclass/n5596.py | 2 +- lib/forward/devclass/n7010.py | 6 +- lib/forward/devclass/n7018.py | 2 +- lib/forward/devclass/ne40ex8.py | 2 +- lib/forward/devclass/r3048g.py | 4 +- lib/forward/devclass/s9312.py | 349 ++++++++++-------- lib/forward/devclass/s9312e.py | 3 +- lib/forward/devclass/sr7750.py | 10 +- lib/forward/devclass/sr7950.py | 34 +- .../devclass/unusable_command_interface.py | 188 +++++----- lib/forward/utils/sshv1.py | 8 +- lib/forward/utils/telnet.py | 2 +- protocol/flake8 | 6 +- 24 files changed, 890 insertions(+), 410 deletions(-) diff --git a/lib/forward/devclass/baer7850.py b/lib/forward/devclass/baer7850.py index 17ff2cf..d5d9d1b 100644 --- a/lib/forward/devclass/baer7850.py +++ b/lib/forward/devclass/baer7850.py @@ -98,7 +98,7 @@ def showSyslog(self): if not result['status'] or result['state'] != 'success': njInfo['errLog'] = result['errLog'] return njInfo - syslogList= re.findall('(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\w+)', result['content']) + syslogList = re.findall('(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\w+)', result['content']) logInfo['content']['syslog_server'] = {} for serinfo in syslogList: logInfo['content']['syslog_server'][serinfo[0]] = serinfo[1] @@ -116,15 +116,11 @@ def showHostname(self): 'errLog': '' } cmd = "show system information" - prompt = { - "success": "[\r\n]+\S+(>|\]) ?$", - "error": "Unrecognized command[\s\S]+", - } - result = self.command(cmd=cmd, prompt=prompt) - if result["state"] == "success": - tmp = result["content"].split() + result = self.execute(cmd=cmd) + if result["status"] is True: + tmp = re.search("System Name.*:(.*)", result["content"], flags=re.IGNORECASE) if tmp: - njInfo["content"] = tmp[1] + njInfo["content"] = tmp.group(1).strip() njInfo["status"] = True else: njInfo["errLog"] = result["errLog"] diff --git a/lib/forward/devclass/baseH3C.py b/lib/forward/devclass/baseH3C.py index f3f3aab..cc0f71e 100644 --- a/lib/forward/devclass/baseH3C.py +++ b/lib/forward/devclass/baseH3C.py @@ -34,6 +34,7 @@ class BASEH3C(BASESSHV2): """This is a manufacturer of h3c, using the SSHV2 version of the protocol, so it is integrated with BASESSHV2 library. """ + def commit(self): result = { "status": False, @@ -50,21 +51,27 @@ def commit(self): prompt={"success": "Are you sure\? \[Y/N\]: ?$", "error": "Error:Incomplete command[\s\S]+"}) if tmp["state"] == "success": - tmp = self.command("Y", prompt={"success": "press the enter key\): ?$"}) + tmp = self.command( + "Y", prompt={"success": "press the enter key\): ?$"}) if tmp["state"] == "success": - tmp = self.command("", prompt={"success": "overwrite\? \[Y/N\]: ?$"}) + tmp = self.command( + "", prompt={"success": "overwrite\? \[Y/N\]: ?$"}) if tmp["state"] == "success": - tmp = self.command("Y", prompt={"success": "successfully\.[\r\n]+<\S+>?$"}) + tmp = self.command( + "Y", prompt={"success": "successfully\.[\r\n]+<\S+>?$"}) if tmp["state"] == "success": result["status"] = True result["content"] = tmp["content"] else: - result["errLog"] = "That save configuration is failed.related information: [{content}]".format(content=tmp["content"]) + result["errLog"] = "That save configuration is failed.related information: [{content}]" \ + .format(content=tmp["content"]) else: - result["errLog"] = "That save configuration is failed.related information: [{content}]".format(content=tmp["content"]) + result["errLog"] = "That save configuration is failed.related information: [{content}]" \ + .format(content=tmp["content"]) else: - result["errLog"] = "Failed save configuration,related information: [{content}]".format(content=tmp["content"]) + result["errLog"] = "Failed save configuration,related information: [{content}]" \ + .format(content=tmp["content"]) else: result["errLog"] = "Failed save configuration, \ Info: [{content}] , [{errLog}]".format(content=tmp["content"], errLog=tmp["errLog"]) @@ -158,7 +165,8 @@ def showVersion(self): } result = self.command(cmd=cmd, prompt=prompt) if result["state"] == "success": - tmp = re.search("software.*version(.*)", result["content"], flags=re.IGNORECASE) + tmp = re.search("software.*version(.*)", + result["content"], flags=re.IGNORECASE) if tmp: njInfo["content"] = tmp.group(1).strip() njInfo["status"] = True @@ -203,7 +211,8 @@ def showSnmp(self): } result = self.command(cmd=cmd, prompt=prompt) if result["state"] == "success": - tmp = re.findall("udp-domain ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", result["content"]) + tmp = re.findall( + "udp-domain ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", result["content"]) if tmp: njInfo["content"] = tmp njInfo["status"] = True @@ -353,15 +362,20 @@ def showInterface(self): "mac": "", "ip": ""} # Get name of the interface. - lineInfo['interfaceName'] = re.search("(.*)current state", _interfaceInfo).group(1).strip() + lineInfo['interfaceName'] = re.search( + "(.*)current state", _interfaceInfo).group(1).strip() # Get state of the interface and remove extra character. - lineInfo['interfaceState'] = re.search("current state :(.*)", _interfaceInfo).group(1).strip() + lineInfo['interfaceState'] = re.search( + "current state :(.*)", _interfaceInfo).group(1).strip() # Get state of line protocol of the interface and remove extra character. - lineInfo['lineState'] = re.search("Line protocol current state :(.*)", _interfaceInfo).group(1).strip() + lineInfo['lineState'] = re.search( + "Line protocol current state :(.*)", _interfaceInfo).group(1).strip() # Get description of the interface. - lineInfo['description'] = re.search("Description:(.*)", _interfaceInfo).group(1).strip() + lineInfo['description'] = re.search( + "Description:(.*)", _interfaceInfo).group(1).strip() # Get MUT of the interface. - tmpMTU = re.search("The Maximum Transmit Unit is ([0-9]+)", _interfaceInfo) + tmpMTU = re.search( + "The Maximum Transmit Unit is ([0-9]+)", _interfaceInfo) if tmpMTU: lineInfo["mtu"] = tmpMTU.group(1) else: @@ -373,13 +387,15 @@ def showInterface(self): else: lineInfo["speed"] = "" # Get duplex of the interface. - tmp = re.search("([a-z]+)\-duplex", _interfaceInfo, flags=re.IGNORECASE) + tmp = re.search("([a-z]+)\-duplex", + _interfaceInfo, flags=re.IGNORECASE) if tmp: lineInfo["duplex"] = tmp.group(1) else: lineInfo["duplex"] = "" # Get duplex of the interface for s9312 - tmp = re.search("Duplex: ([a-z]+)", _interfaceInfo, flags=re.IGNORECASE) + tmp = re.search("Duplex: ([a-z]+)", + _interfaceInfo, flags=re.IGNORECASE) if tmp: lineInfo["duplex"] = tmp.group(1) # Get ip of the interface. @@ -401,12 +417,14 @@ def showInterface(self): else: lineInfo["type"] = "" # Last 300 seconds input rate - tmp = re.search("Last 300 seconds input rate (.*)", _interfaceInfo) + tmp = re.search( + "Last 300 seconds input rate (.*)", _interfaceInfo) if tmp: lineInfo["inputRate"] = tmp.group(1).strip() else: lineInfo["inputRate"] = "" - tmp = re.search("Last 300 seconds output rate (.*)", _interfaceInfo) + tmp = re.search( + "Last 300 seconds output rate (.*)", _interfaceInfo) if tmp: lineInfo["outputRate"] = tmp.group(1).strip() else: @@ -439,7 +457,8 @@ def vlanExist(self, vlan_id): if vlan_id == line["id"]: result["status"] = True return result - result["errLog"] = "Vlan {vlan_id} does not exist.".format(vlan_id=vlan_id) + result["errLog"] = "Vlan {vlan_id} does not exist.".format( + vlan_id=vlan_id) return result def createVlan(self, vlan_id, name=None): @@ -463,7 +482,8 @@ def createVlan(self, vlan_id, name=None): if name is None: cmd = "vlan {vlan_id}".format(vlan_id=vlan_id) else: - cmd = "vlan {vlan_id}\rname {name}".format(vlan_id=vlan_id, name=name) + cmd = "vlan {vlan_id}\rname {name}".format( + vlan_id=vlan_id, name=name) prompt = { "success": "[\r\n]+\S+vlan{vlan_id}\] ?$".format(vlan_id=vlan_id), "error": "Error:[\s\S]+", @@ -472,7 +492,8 @@ def createVlan(self, vlan_id, name=None): tmp = self.command(cmd, prompt=prompt) if tmp["state"] == "success" and not re.search(prompt["error"], tmp["content"]): # The vlan was created successfuly, then to save configration if save is True. - result["content"] = "The vlan {vlan_id} was created.".format(vlan_id=vlan_id) + result["content"] = "The vlan {vlan_id} was created.".format( + vlan_id=vlan_id) result["status"] = True return result else: @@ -501,7 +522,8 @@ def deleteVlan(self, vlan_id): logging.debug("runing command result:" + str(tmp)) if tmp["state"] == "success": # The vlan was deleted successfuly, then to save configration if save is True. - result["content"] = "The vlan {vlan_id} was deleted.".format(vlan_id=vlan_id) + result["content"] = "The vlan {vlan_id} was deleted.".format( + vlan_id=vlan_id) result["status"] = True return result else: @@ -525,7 +547,8 @@ def interfaceVlanExist(self, vlan_id): if vlan_id == line["interfaceName"]: result["status"] = True return result - result["errLog"] = "The interface-vlan {vlan_id} does not exist.".format(vlan_id=vlan_id) + result["errLog"] = "The interface-vlan {vlan_id} does not exist.".format( + vlan_id=vlan_id) return result def deleteInterfaceVlan(self, vlan_id): @@ -547,11 +570,13 @@ def deleteInterfaceVlan(self, vlan_id): tmp = self.command(cmd, prompt=prompt) if not self.interfaceVlanExist(vlan_id)["status"]: # The interface-vlan was deleted successfuly. - result["content"] = "The interface-vlan {vlan_id} was deleted.".format(vlan_id=vlan_id) + result["content"] = "The interface-vlan {vlan_id} was deleted.".format( + vlan_id=vlan_id) result["status"] = True return result else: - result["errLog"] = "The interface-vlan {vlan_id} was not deleted.".format(vlan_id=vlan_id) + result["errLog"] = "The interface-vlan {vlan_id} was not deleted.".format( + vlan_id=vlan_id) return result def createInterfaceVlan(self, vlan_id, ip=None, mask=None, description="None"): @@ -645,7 +670,8 @@ def basicInfo(self, cmd="display version"): if tmp["status"]: result = self.command(cmd=cmd, prompt=prompt) if result["state"] == "success": - dataLine = re.search(" uptime:? .+(day|year|week).*", result["content"]) + dataLine = re.search( + " uptime:? .+(day|year|week).*", result["content"]) if dataLine is not None: tmp = re.search("([0-9]+) years?", dataLine.group()) if tmp: @@ -726,8 +752,10 @@ def createObjectGroupIPAddress(self, host=[]): tmp = self.privilegeMode() if tmp["status"] is False: raise IOError(tmp["errLog"]) - objectGroupName = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) + "." + str(random.randint(100000, 999999)) - cmd = "object-group ip address {objectGroupName}".format(objectGroupName=objectGroupName) + objectGroupName = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) + \ + "." + str(random.randint(100000, 999999)) + cmd = "object-group ip address {objectGroupName}".format( + objectGroupName=objectGroupName) prompt = { "success": "[\r\n]+\S+{objectGroup}\] ?$".format(objectGroup="-obj-grp-ip-" + objectGroupName) } @@ -740,12 +768,14 @@ def createObjectGroupIPAddress(self, host=[]): for ip in host: if re.search("\-", ip): ipA, ipB = ip.split("-") - cmd = "{i} network host address {ipA} {ipB}".format(i=i, ipA=ipA, ipB=ipB) + cmd = "{i} network host address {ipA} {ipB}".format( + i=i, ipA=ipA, ipB=ipB) else: cmd = "{i} network host address {ip}".format(i=i, ip=ip) i += 1 result = self.command(cmd, prompt) - errLine = "(Invalid Input|Bad command|[Uu]nknown command|Unrecognized command|Invalid command|Wrong|Too many)" + errLine = "(Invalid Input|Bad command|[Uu]nknown command| \ + Unrecognized command|Invalid command|Wrong|Too many)" if not result["state"] == "success" or re.search(errLine, result["content"], flags=re.IGNORECASE): raise IOError(result["content"]) njInfo = {"status": True, "content": objectGroupName} @@ -753,7 +783,8 @@ def createObjectGroupIPAddress(self, host=[]): def createObjectGroupService(self, configuration, serviceName): """ - @ parame configuration: 'service udp source gt 0 destination eq 30002' or 'service udp source gt 0 destination eq 30002' + @ parame configuration: 'service udp source gt 0 destination eq 30002' or \ + 'service udp source gt 0 destination eq 30002' @ parame serviceName: name of object-group-service. """ njInfo = { @@ -761,7 +792,8 @@ def createObjectGroupService(self, configuration, serviceName): "content": "", "errLog": "" } - cmdA = "object-group service {serviceName}".format(serviceName=serviceName) + cmdA = "object-group service {serviceName}".format( + serviceName=serviceName) promptA = { "success": "[\r\n]+\S+{serviceName}\] ?$".format(serviceName="-obj-grp-service-" + serviceName) } @@ -783,7 +815,8 @@ def createObjectGroupService(self, configuration, serviceName): def isExistObjectGroupService(self, configuration): """ - @ parame configuration: 'service udp source gt 0 destination eq 30002' or 'service udp source gt 0 destination eq 30002' + @ parame configuration: 'service udp source gt 0 destination eq 30002' or \ + 'service udp source gt 0 destination eq 30002' """ njInfo = { "status": False, @@ -859,7 +892,8 @@ def isExistObjectGroupIPAddress(self, hostList=[]): njInfo = {"status":True,"content":"object-group-name"} """ if not isinstance(hostList, list): - raise IOError("The parameter's formate is incorrect.Its formate should is ['10.,0.0.1','192.168.1.1','192.168.2.100-192.168.2.200']") + raise IOError("The parameter's formate is incorrect.Its formate should \ + is ['10.,0.0.1','192.168.1.1','192.168.2.100-192.168.2.200']") hostList = DEVICELIST(hostList).getIpList() hostList = sorted(hostList) njInfo = { @@ -888,7 +922,8 @@ def isExistObjectGroupIPAddress(self, hostList=[]): # example: {"object-group-a":["10.0.0.1","10.0.0.2"]} allObjectIP = {} for group in allGroups: - cmdA = "object-group ip address {objectGroup}".format(objectGroup=group) + cmdA = "object-group ip address {objectGroup}".format( + objectGroup=group) prompt = { "success": "[\r\n]+\S+{objectGroup}\] ?$".format(objectGroup="-obj-grp-ip-" + group) } @@ -904,12 +939,14 @@ def isExistObjectGroupIPAddress(self, hostList=[]): hosts = [] for line in tmp["content"].split("\r\n"): # Get single ip. - info = re.search("[0-9]+ network host address ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", line) + info = re.search( + "[0-9]+ network host address ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", line) if info: hosts.append(info.group(1)) continue # Get ip range. - info = re.search("[0-9]+ network range ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", line) + info = re.search("[0-9]+ network range ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,34}\.[0-9]{1,3}) \ + ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", line) if info: iplist = [info.group(1) + "-" + info.group(2)] hosts.append(DEVICELIST(iplist).getIpList()) @@ -979,81 +1016,122 @@ def createSecurityPolicy(self, """ # Check whether parameters meet thee requirements. if not isinstance(comment, str): - raise IOError("comment's formate should be a string and not be empty.") + raise IOError( + "comment's formate should be a string and not be empty.") else: if re.search("^ *$", comment): raise IOError("comment's format should not be empty") if not isinstance(policyName, str): - raise IOError("policyName's format should be a string and not be empty") + raise IOError( + "policyName's format should be a string and not be empty") else: if re.search("^ *$", policyName): raise IOError("policyName's format should not be empty") if not isinstance(sourceHost, list): - raise IOError("sourceHost's formate should is a list,ex: ['10.0.0.1','10.0.0.1-10.0.0.3']") + raise IOError( + "sourceHost's formate should is a list,ex: ['10.0.0.1','10.0.0.1-10.0.0.3']") elif not isinstance(destinationHost, list): - raise IOError("destinationHost's formate should is a list,ex: ['10.0.0.1','10.0.0.1-10.0.0.3']") + raise IOError("destinationHost's formate should is a list, \ + ex: ['10.0.0.1','10.0.0.1-10.0.0.3']") elif not isinstance(serviceParam, dict): - raise IOError("serviceParam's formate should is a dict.plase use help(createSecurityPolicy) to see details.") + raise IOError("serviceParam's formate should is a dict.plase use help(createSecurityPolicy) \ + to see details.") else: - if serviceParam.has_key("protocol"): + # if serviceParam.has_key("protocol"): + if "protocol" in serviceParam: if (not serviceParam["protocol"] == "tcp") and (not serviceParam["protocol"] == "udp"): - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - raise IOError("serviceParam's formate should is a dict and incloude key of protocol.plase use help(createSecurityPolicy) to see details.") - if serviceParam.has_key("sourcePort"): + raise IOError( + "serviceParam's formate should is a dict and incloude key of protocol. \ + plase use help(createSecurityPolicy) to see details.") + # if serviceParam.has_key("sourcePort"): + if "sourcePort" in serviceParam: if (not isinstance(serviceParam["sourcePort"], str)) and (not serviceParam["sourcePort"] is None): - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") if serviceParam["sourcePort"] is not None: - if serviceParam.has_key("sourcePortType"): - if (not serviceParam["sourcePortType"] == "eq") and (not serviceParam["sourcePortType"] == "gt") and (not serviceParam["sourcePortType"] == "lt") and (not serviceParam["sourcePortType"] == "range"): - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + # if serviceParam.has_key("sourcePortType"): + if "sourcePortType" in serviceParam: + if (not serviceParam["sourcePortType"] == "eq") and \ + (not serviceParam["sourcePortType"] == "gt") and \ + (not serviceParam["sourcePortType"] == "lt") and \ + (not serviceParam["sourcePortType"] == "range"): + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - if serviceParam.has_key("sourcePortType"): - raise IOError("Since serviceParame['sourcePort'] is None,serviceParam['sourcePortType'] should not be exist.") - if serviceParam.has_key("destinationPort"): - if (not isinstance(serviceParam["destinationPort"], str)) and (not serviceParam["destinationPort"] is None): - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + # if serviceParam.has_key("sourcePortType"): + if "sourcePortType" in serviceParam: + raise IOError("Since serviceParame['sourcePort'] is None, \ + serviceParam['sourcePortType'] should not be exist.") + # if serviceParam.has_key("destinationPort"): + if "destinationPort" in serviceParam: + if (not isinstance(serviceParam["destinationPort"], str)) and \ + (not serviceParam["destinationPort"] is None): + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") if not serviceParam["destinationPort"] is None: - if serviceParam.has_key("destinationPortType"): - if (not serviceParam["destinationPortType"] == "eq") and (not serviceParam["destinationPortType"] == "gt") and (not serviceParam["destinationPortType"] == "lt") and (not serviceParam["destinationPortType"] == "range"): - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + # if serviceParam.has_key("destinationPortType"): + if "destinationPortType" in serviceParam: + if (not serviceParam["destinationPortType"] == "eq") and \ + (not serviceParam["destinationPortType"] == "gt") and \ + (not serviceParam["destinationPortType"] == "lt") and \ + (not serviceParam["destinationPortType"] == "range"): + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - raise IOError("serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") + raise IOError( + "serviceParam's formate is incorrect.plase use help(createSecurityPolicy) to see details.") else: - if serviceParam.has_key("destinationPortType"): - raise IOError("Since serviceParame['destinationPort'] is None,serviceParam['destinationPortType'] should not be exist.") + # if serviceParam.has_key("destinationPortType"): + if "destinationPortType" in serviceParam: + raise IOError("Since serviceParame['destinationPort'] is None, \ + serviceParam['destinationPortType'] should not be exist.") # Check the service section. if serviceParam["sourcePort"] is None: sourceSection = "" else: if serviceParam["sourcePortType"] == "range": if not re.search("^[0-9]+\-[0-9]+$", serviceParam["sourcePort"]): - raise IOError("sourcePort's format of serviceParam is incorrect.") + raise IOError( + "sourcePort's format of serviceParam is incorrect.") portA, portB = serviceParam["sourcePort"].split("-") - sourceSection = "source range {portA} {portB}".format(portA=portA, portB=portB) + sourceSection = "source range {portA} {portB}".format( + portA=portA, portB=portB) else: if not re.search("^[0-9]+$", serviceParam["sourcePort"]): - raise IOError("sourcePort's format of serviceParam is incorrect.") - sourceSection = "source {sourcePortType} {port}".format(sourcePortType=serviceParam["sourcePortType"], port=serviceParam["sourcePort"]) + raise IOError( + "sourcePort's format of serviceParam is incorrect.") + sourceSection = "source {sourcePortType} {port}".format( + sourcePortType=serviceParam["sourcePortType"], port=serviceParam["sourcePort"]) if serviceParam["destinationPort"] is None: destinationSection = "" else: if serviceParam["destinationPortType"] == "range": if not re.search("^[0-9]+\-[0-9]+$", serviceParam["destinationPort"]): - raise IOError("destinationPort's format of serviceParam is incorrect.") + raise IOError( + "destinationPort's format of serviceParam is incorrect.") portA, portB = serviceParam["destinationPort"].split("-") - destinationSection = "destination range {portA} {portB}".format(portA=portA, portB=portB) + destinationSection = "destination range {portA} {portB}".format( + portA=portA, portB=portB) else: if not re.search("^[0-9]+$", serviceParam["destinationPort"]): - raise IOError("destinationPort's format of serviceParam is incorrect.") - destinationSection = "destination {destinationPortType} {port}".format(destinationPortType=serviceParam["destinationPortType"], port=serviceParam["destinationPort"]) - configuration = "0 service {protocol} {sourceSection} {destinationSection}".format(protocol=serviceParam["protocol"], sourceSection=sourceSection, destinationSection=destinationSection) + raise IOError( + "destinationPort's format of serviceParam is incorrect.") + destinationSection = "destination {destinationPortType} {port}".format( + destinationPortType=serviceParam["destinationPortType"], port=serviceParam["destinationPort"]) + configuration = "0 service {protocol} {sourceSection} {destinationSection}".format( + protocol=serviceParam["protocol"], sourceSection=sourceSection, destinationSection=destinationSection) # Check whether the object-policy is exist. tmp = self.isExistObjectPolicyIP(policyName) if not tmp["status"]: @@ -1078,14 +1156,22 @@ def createSecurityPolicy(self, return tmp destinationObjectGroupIPName = tmp["content"] tmp = self.isExistObjectGroupService(configuration) - serviceName = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime()) + "." + str(random.randint(100000, 999999)) + serviceName = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime( + )) + "." + str(random.randint(100000, 999999)) if not tmp["status"]: # Create object-group-service if that is not exist. tmp = self.createObjectGroupService(configuration, serviceName) if not tmp["status"]: return tmp - configurationB = "rule {ruleID} pass source-ip {sourceObjectGroupIPName} destination-ip {destinationObjectGroupIPName} service {serviceName} counting ".format(ruleID=ruleID, sourceObjectGroupIPName=sourceObjectGroupIPName, destinationObjectGroupIPName=destinationObjectGroupIPName, serviceName=serviceName) - comment = "rule {ruleID} comment {comment}".format(comment=comment, ruleID=ruleID) + configurationB = "rule {ruleID} pass source-ip {sourceObjectGroupIPName} \ + destination-ip {destinationObjectGroupIPName} service {serviceName} counting " \ + .format( + ruleID=ruleID, + sourceObjectGroupIPName=sourceObjectGroupIPName, + destinationObjectGroupIPName=destinationObjectGroupIPName, + serviceName=serviceName) + comment = "rule {ruleID} comment {comment}".format( + comment=comment, ruleID=ruleID) tmp = self.addObjectPolicyIP(policyName, configurationB, comment) if tmp["status"] is True: tmp = self.commit() @@ -1101,7 +1187,8 @@ def showRun(self): if not njInfo["state"] == "success": njInfo["status"] = False else: - njInfo["content"] = "\r\r\n".join(njInfo["content"].split("\r\r\n")[1:-1]) + njInfo["content"] = "\r\r\n".join( + njInfo["content"].split("\r\r\n")[1:-1]) return njInfo def showHostname(self): diff --git a/lib/forward/devclass/baseJuniper.py b/lib/forward/devclass/baseJuniper.py index 76323d9..ae67f6f 100644 --- a/lib/forward/devclass/baseJuniper.py +++ b/lib/forward/devclass/baseJuniper.py @@ -681,21 +681,23 @@ def showVRRP(self, cmd="show vrrp"): njInfo["content"][-1]["type"] += "/" + dataLine[0] njInfo["content"][-1]["address"] += "/" + dataLine[1] continue - njInfo["content"].append({ - "vr-state": dataLine[3], - "vr-mode": dataLine[4], - "timer": dataLine[5] + dataLine[6], - "type": dataLine[7], - "interface": dataLine[0], - "group": dataLine[2], - "prio": "", - "p": "", - "state": dataLine[1], - "active": "", - "standby-addr": "", - "group-addr": "", - "address": dataLine[8]} - ) + njInfo["content"].append( + { + "vr-state": dataLine[3], + "vr-mode": dataLine[4], + "timer": dataLine[5] + dataLine[6], + "type": dataLine[7], + "interface": dataLine[0], + "group": dataLine[2], + "prio": "", + "p": "", + "state": dataLine[1], + "active": "", + "standby-addr": "", + "group-addr": "", + "address": dataLine[8] + } + ) except Exception: pass diff --git a/lib/forward/devclass/baseRuijieV1.py b/lib/forward/devclass/baseRuijieV1.py index b703242..c6b4679 100644 --- a/lib/forward/devclass/baseRuijieV1.py +++ b/lib/forward/devclass/baseRuijieV1.py @@ -22,7 +22,7 @@ import re import pexpect from forward.devclass.baseSSHV1 import BASESSHV1 -from forward.utils.forwardError import ForwardError +# from forward.utils.forwardError import ForwardError class BASERUIJIE(BASESSHV1): diff --git a/lib/forward/devclass/baseVenustech.py b/lib/forward/devclass/baseVenustech.py index 59deb11..804246e 100644 --- a/lib/forward/devclass/baseVenustech.py +++ b/lib/forward/devclass/baseVenustech.py @@ -448,15 +448,17 @@ def showOSPF(self, cmd="show ip ospf neighbor"): for line in dataLine: line = line.split() if len(line) == 8: - njInfo["content"].append({ - "neighbor-id": line[0], - "pri": line[1], - "state": line[2] + line[3], - "uptime": "", - "address": line[5], - "interface": line[6], - "deadTime": line[4]} - ) + njInfo["content"].append( + { + "neighbor-id": line[0], + "pri": line[1], + "state": line[2] + line[3], + "uptime": "", + "address": line[5], + "interface": line[6], + "deadTime": line[4] + } + ) else: # The line does not matched data of expection. continue diff --git a/lib/forward/devclass/ce16808.py b/lib/forward/devclass/ce16808.py index cd67ff6..bd03a9c 100644 --- a/lib/forward/devclass/ce16808.py +++ b/lib/forward/devclass/ce16808.py @@ -20,9 +20,57 @@ [Core][forward] Device class for ce16808. """ from forward.devclass.baseHuawei import BASEHUAWEI +import re class CE16808(BASEHUAWEI): """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. """ - pass + def showHostname(self): + '''show hostname + Return: + device hostname + ''' + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'display current-configuration | include sysname' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['content'] = re.findall('sysname (\S+)', result['content'])[0] + njInfo['status'] = True + return njInfo + njInfo['errLog'] = result['errLog'] + return njInfo + + def showNtp(self): + # Gets the NTP server address of the device + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + cmd = "dis current-configuration | i ntp" + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Unrecognized command[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = re.findall("ntp unicast-server ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", + result["content"]) + if tmp: + njInfo["content"] = tmp + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo diff --git a/lib/forward/devclass/ce16816.py b/lib/forward/devclass/ce16816.py index 9772ded..b32691a 100644 --- a/lib/forward/devclass/ce16816.py +++ b/lib/forward/devclass/ce16816.py @@ -20,9 +20,57 @@ [Core][forward] Device class for ce16816. """ from forward.devclass.baseHuawei import BASEHUAWEI +import re class CE16816(BASEHUAWEI): """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. """ - pass + def showHostname(self): + '''show hostname + Return: + device hostname + ''' + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'display current-configuration | include sysname' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['content'] = re.findall('sysname (\S+)', result['content'])[0] + njInfo['status'] = True + return njInfo + njInfo['errLog'] = result['errLog'] + return njInfo + + def showNtp(self): + # Gets the NTP server address of the device + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + cmd = "dis current-configuration | i ntp" + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Unrecognized command[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = re.findall("ntp unicast-server ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", + result["content"]) + if tmp: + njInfo["content"] = tmp + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo diff --git a/lib/forward/devclass/ce6881.py b/lib/forward/devclass/ce6881.py index f4dd3f5..45b4377 100644 --- a/lib/forward/devclass/ce6881.py +++ b/lib/forward/devclass/ce6881.py @@ -20,9 +20,57 @@ [Core][forward] Device class for ce6881. """ from forward.devclass.baseHuawei import BASEHUAWEI +import re class CE6881(BASEHUAWEI): """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. """ - pass + def showHostname(self): + '''show hostname + Return: + device hostname + ''' + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Invalid command[\s\S]+", + } + cmd = 'display current-configuration | include sysname' + result = self.command(cmd=cmd, prompt=prompt) + if not result['status']: + njInfo['errLog'] = result['errLog'] + return njInfo + if result['state'] == 'success': + njInfo['content'] = re.findall('sysname (\S+)', result['content'])[0] + njInfo['status'] = True + return njInfo + njInfo['errLog'] = result['errLog'] + return njInfo + + def showNtp(self): + # Gets the NTP server address of the device + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + cmd = "dis current-configuration | i ntp" + prompt = { + "success": "[\r\n]+\S+(>|\]) ?$", + "error": "Unrecognized command[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = re.findall("ntp unicast-server ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", + result["content"]) + if tmp: + njInfo["content"] = tmp + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo diff --git a/lib/forward/devclass/e8000e.py b/lib/forward/devclass/e8000e.py index c7a5b11..302d55d 100644 --- a/lib/forward/devclass/e8000e.py +++ b/lib/forward/devclass/e8000e.py @@ -21,7 +21,7 @@ """ from forward.devclass.baseHuawei import BASEHUAWEI import re -import string +# import string class E8000E(BASEHUAWEI): diff --git a/lib/forward/devclass/fg3800.py b/lib/forward/devclass/fg3800.py index 94671ed..2ed37b8 100644 --- a/lib/forward/devclass/fg3800.py +++ b/lib/forward/devclass/fg3800.py @@ -20,9 +20,230 @@ [Core][forward] Device class for fg3800. """ from forward.devclass.baseFortinet import BASEFORTINET +import re class FG3800(BASEFORTINET): """This is a manufacturer of fortinet, so it is integrated with BASEFORTINET library. """ - pass + def configMode(self): + njInfo = { + 'status': False, + 'content': "", + 'errLog': '' + } + cmd = 'config global' + prompt = { + "success": "", + "normal": "Unknown action[\s\S]+" + } + result = self.command(cmd, prompt=prompt) + if not result["state"] is None: + njInfo["status"] = True + self.mode = 3 + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showVersion(self): + njInfo = { + 'status': False, + 'content': "", + 'errLog': '' + } + cmd = "get system status" + result = self.execute(cmd=cmd) + if result["status"] is True: + tmp = re.search("Version:.*v(.*)", result["content"], flags=re.IGNORECASE) + if tmp: + njInfo["content"] = tmp.group(1).strip() + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showHostname(self): + njInfo = { + 'status': False, + 'content': "", + 'errLog': '' + } + cmd = "get system status" + result = self.execute(cmd=cmd) + if result["status"] is True: + tmp = re.search("Hostname:(.*)", result["content"], flags=re.IGNORECASE) + if tmp: + njInfo["content"] = tmp.group(1).strip() + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showNtp(self): + if self.mode != 3: + self.configMode() + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + cmd = 'diagnose sys ntp status' + prompt = { + "success": "HA master[\s\S]+", + "error": "Unknown action[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + p1 = re.compile(r'ipv4 server[(](.*?)[)]', re.S) + tmp = re.findall(p1, result["content"]) + if tmp: + njInfo["content"] = tmp + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showInterface(self): + if self.mode != 3: + self.configMode() + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + cmd = "show full-configuration system interface" + prompt = { + "success": "[\r\n]+\S+(#|>) ?$", + "error": "Unknown action[\s\S]+", + } + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + interfacesFullInfo = re.split("next", result["content"]) + for _interfaceInfo in interfacesFullInfo: + lineInfo = {"members": [], + "interfaceState": "", + "interfaceName": "", + "speed": "", + "type": "", + "inputRate": "", + "outputRate": "", + "ip": "", + "lineState": "", + "adminState": "", + "mtu": "", + "duplex": "", + "description": "", + "crc": ""} + # Get name of the interface. + tmp = re.search('edit "(.+)"', _interfaceInfo) + if tmp: + lineInfo['interfaceName'] = tmp.group(1) + else: + continue + # Only interface information is obtained here, not vlan information + if re.search("vlan", lineInfo['interfaceName']): + continue + tmp = re.search("set description(.*)", _interfaceInfo) + if tmp: + lineInfo["description"] = tmp.group(1).strip().strip('"\'') + njInfo["content"].append(lineInfo) + # Get the details through the physical interface name + detail = self.command(cmd="get system interface physical", prompt=prompt) + """ + ==[npu1-vlink0] + mode: static + ip: 0.0.0.0 0.0.0.0 + ipv6: ::/0 + status: down + speed: n/a + ==[npu1-vlink1] + mode: static + ip: 0.0.0.0 0.0.0.0 + ipv6: ::/0 + status: down + speed: n/a + """ + if detail["state"] == "success": + interfacesFullInfo = re.split("==", detail["content"]) + for _interfaceInfo in interfacesFullInfo: + data = {"ip": "", + "type": "", + "interfaceState": "", + "speed": "", + "duplex": ""} + tmp = re.search("(\[\S+\])", _interfaceInfo) + if tmp: + _interfaceName = tmp.group(1).strip("[]") + # Get ip + tmp = re.search("ip: (\S*)", _interfaceInfo) + if tmp: + data["ip"] = tmp.group(1) + # Get type + tmp = re.search("mode: (\S*)", _interfaceInfo) + if tmp: + data["type"] = tmp.group(1) + # Get status + tmp = re.search("status: (\S*)", _interfaceInfo) + if tmp: + data["interfaceState"] = tmp.group(1) + # Get speed + tmp = re.search("speed: (\S*)", _interfaceInfo) + if tmp: + data["speed"] = tmp.group(1) + # Get duplex + tmp = re.search("Duplex: ([A-Za-z]+)", _interfaceInfo) + if tmp: + data["duplex"] = tmp.group(1) + # Update data + index = 0 + for _line in njInfo["content"]: + if _interfaceName == _line["interfaceName"]: + njInfo["content"][index].update(**data) + index += 1 + else: + continue + njInfo["status"] = True + else: + njInfo["errLog"] = result["errLog"] + return njInfo + + def showLog(self): + if self.mode != 3: + self.configMode() + njInfo = { + 'status': False, + 'content': [], + 'errLog': '' + } + """ + Since the syslog information needs to be obtained according to the + configuration name of the syslog on the device of this model, + the name of the syslog needs to be trained until the configuration does not exist. + For example: + syslog + syslog2 + syslog3 + """ + prompt = { + "success": "end[\r\n]+\S+(#|>) ?$", + "error": "Return code \-61[\s\S]+", + } + i = 0 + while True: + i += 1 + if i == 1: + cmd = "show full-configuration log syslogd setting" + else: + cmd = "show full-configuration log syslogd{i} setting".format(i=i) + result = self.command(cmd=cmd, prompt=prompt) + if result["state"] == "success": + tmp = re.search('set server "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})"', + result["content"]) + if tmp: + njInfo["content"].append(tmp.group(1)) + njInfo["status"] = True + else: + # Exit if the configuration does not exist + njInfo["errLog"] = result["errLog"] + break + return njInfo diff --git a/lib/forward/devclass/n5548.py b/lib/forward/devclass/n5548.py index 0a5e52a..8eb6897 100644 --- a/lib/forward/devclass/n5548.py +++ b/lib/forward/devclass/n5548.py @@ -19,7 +19,7 @@ -----Introduction----- [Core][forward] Device class for n5548. """ -import re +# import re from forward.devclass.baseCisco import BASECISCO diff --git a/lib/forward/devclass/n5596.py b/lib/forward/devclass/n5596.py index 605056c..3a75025 100644 --- a/lib/forward/devclass/n5596.py +++ b/lib/forward/devclass/n5596.py @@ -19,7 +19,7 @@ -----Introduction----- [Core][forward] Device class for n5596. """ -import re +# import re from forward.devclass.baseCisco import BASECISCO diff --git a/lib/forward/devclass/n7010.py b/lib/forward/devclass/n7010.py index 516c915..91068e1 100644 --- a/lib/forward/devclass/n7010.py +++ b/lib/forward/devclass/n7010.py @@ -19,9 +19,9 @@ -----Introduction----- [Core][forward] Device class for n7010. """ -import datetime -import time -import re +# import datetime +# import time +# import re from forward.devclass.baseCisco import BASECISCO diff --git a/lib/forward/devclass/n7018.py b/lib/forward/devclass/n7018.py index 5a4a74a..71eb4b2 100644 --- a/lib/forward/devclass/n7018.py +++ b/lib/forward/devclass/n7018.py @@ -19,7 +19,7 @@ -----Introduction----- [Core][forward] Device class for n7018. """ -import re +# import re from forward.devclass.baseCisco import BASECISCO diff --git a/lib/forward/devclass/ne40ex8.py b/lib/forward/devclass/ne40ex8.py index 7d809a6..211aa8e 100644 --- a/lib/forward/devclass/ne40ex8.py +++ b/lib/forward/devclass/ne40ex8.py @@ -20,7 +20,7 @@ """ import re from forward.devclass.baseHuawei import BASEHUAWEI -from forward.utils.sshv2 import sshv2 +# from forward.utils.sshv2 import sshv2 class NE40EX8(BASEHUAWEI): diff --git a/lib/forward/devclass/r3048g.py b/lib/forward/devclass/r3048g.py index f733ced..d828595 100644 --- a/lib/forward/devclass/r3048g.py +++ b/lib/forward/devclass/r3048g.py @@ -19,8 +19,8 @@ [Core][forward] Device class for n7018. """ from forward.devclass.baseRaisecom import BASERAISECOM -from forward.utils.forwardError import ForwardError -import re +# from forward.utils.forwardError import ForwardError +# import re class R3048G(BASERAISECOM): diff --git a/lib/forward/devclass/s9312.py b/lib/forward/devclass/s9312.py index 044be0b..f0ef933 100644 --- a/lib/forward/devclass/s9312.py +++ b/lib/forward/devclass/s9312.py @@ -22,11 +22,13 @@ from forward.devclass.baseHuawei import BASEHUAWEI from forward.utils.forwardError import ForwardError import re +import string class S9312(BASEHUAWEI): """This is a manufacturer of huawei, so it is integrated with BASEHUAWEI library. """ + def isVlan(self, vlan): """Check if the Vlan exists. """ @@ -60,7 +62,8 @@ def createVlan(self, vlan=None, ascription=None): "content": "", "errLog": ""} if (vlan is None) or (ascription is None): - raise ForwardError("You must specify the `vlan` and `ascription` parameters") + raise ForwardError( + "You must specify the `vlan` and `ascription` parameters") """Warning: that vlan should be checked by the 'self.isvlan(vlan) method before setting up the vlan""" @@ -77,11 +80,13 @@ def createVlan(self, vlan=None, ascription=None): # Get host prompt self.getPrompt() if not re.search('.*-vlan', self.prompt): - raise ForwardError("Failed to enter vlan mode,command:vlan {vlan}".format(vlan=vlan)) + raise ForwardError( + "Failed to enter vlan mode,command:vlan {vlan}".format(vlan=vlan)) # set host's ascription info["content"] = "" # Send command. - self.shell.send("name {ascription}\n".format(ascription=ascription)) + self.shell.send("name {ascription}\n".format( + ascription=ascription)) while not re.search(self.basePrompt, info['content'].split('\n')[-1]): info['content'] += self.shell.recv(1024).decode() # Get host prompt. @@ -118,17 +123,20 @@ def isTrunkInInterface(self, port=None, vlan=None): raise ForwardError(tmp['errLog']) # else ,successed while True: - tmp = self.execute("display current-configuration interface Eth-Trunk") + tmp = self.execute( + "display current-configuration interface Eth-Trunk") if not tmp["status"]: raise ForwardError(tmp["errLog"]) if re.search("Command is in use by", tmp["content"]): # Recheck continue # Keyword search. - data = re.search("#[\r\n]+(interface Eth-Trunk{port}[\r\n]+[\s\S]*?)#".format(port=port), tmp["content"]) + data = re.search( + "#[\r\n]+(interface Eth-Trunk{port}[\r\n]+[\s\S]*?)#".format(port=port), tmp["content"]) if not data: # No configuration found - raise ForwardError("Not found port(port) info".format(port=port)) + raise ForwardError( + "Not found port(port) info".format(port=port)) try: if re.search("port trunk allow-pass vlan .*{vlan}".format(vlan=vlan), data.group(1)): # found it. @@ -153,21 +161,26 @@ def trunkOpenVlan(self, port=None, vlan=None): if (vlan is None) or (port is None): raise ForwardError('Specify the `vlan` and `port` parameters') # get parameter - tmp = self.execute("display cur interface Eth-Trunk {port}".format(port=port)) + tmp = self.execute( + "display cur interface Eth-Trunk {port}".format(port=port)) if not tmp["status"]: raise ForwardError(tmp["errLog"]) # search parameter - data = re.search("#[\r\n]+(interface Eth-Trunk{port}[\r\n]+[\s\S]*?)#".format(port=port), tmp["content"]) + data = re.search( + "#[\r\n]+(interface Eth-Trunk{port}[\r\n]+[\s\S]*?)#".format(port=port), tmp["content"]) if not data: - raise ForwardError("Not found port(port) [{info}]".format(port=port, info=tmp["content"])) + raise ForwardError("Not found port(port) [{info}]".format( + port=port, info=tmp["content"])) else: # Keyword search. data = re.search("(port trunk allow-pass vlan.*)", data.group(1)) if not data: - raise ForwardError("`Port turnk allow-pass vlan ...` is not found") + raise ForwardError( + "`Port turnk allow-pass vlan ...` is not found") else: # remove the end '\n' and '\r' - cmd = "{parameter} {vlan}".format(parameter=data.group(1).strip("\r\n"), vlan=vlan) + cmd = "{parameter} {vlan}".format( + parameter=data.group(1).strip("\r\n"), vlan=vlan) # switch to config mode tmp = self._configMode() if not tmp["status"]: @@ -220,7 +233,8 @@ def isGateway(self, vlan): if not tmp: raise ForwardError(tmp["errLog"]) # Execute command. - tmp = self.execute("display current-configuration interface Vlanif {vlan}".format(vlan=vlan)) + tmp = self.execute( + "display current-configuration interface Vlanif {vlan}".format(vlan=vlan)) if not tmp["status"]: raise ForwardError(tmp["errLog"]) # If the above fails, exit immediately @@ -242,7 +256,8 @@ def setGateway(self, vlan=None, ascription=None, ip=None): "errLog": ""} # Parameters check. if (vlan is None) or (ascription is None) or (ip is None): - raise ForwardError("You must specify `vlan` and `ascription` and `ip` parameters") + raise ForwardError( + "You must specify `vlan` and `ascription` and `ip` parameters") # Reset gateway ip address ip = re.sub('[0-9]+$', '254', ip) # switch to config mode @@ -259,10 +274,12 @@ def setGateway(self, vlan=None, ascription=None, ip=None): # Get new host prompt. self.getPrompt() if not re.search('Vlanif', self.prompt): - raise ForwardError("Failed to enter Vlanif mode,command:port Vlanif {vlan}".format(vlan=vlan)) + raise ForwardError( + "Failed to enter Vlanif mode,command:port Vlanif {vlan}".format(vlan=vlan)) # set ascription info["content"] = "" - self.shell.send("description {ascription}\n".format(ascription=ascription)) + self.shell.send("description {ascription}\n".format( + ascription=ascription)) while not re.search(self.basePrompt, info['content'].split('\n')[-1]): info['content'] += self.shell.recv(1024).decode # Get new host prompt. @@ -275,7 +292,8 @@ def setGateway(self, vlan=None, ascription=None, ip=None): info['content'] += self.shell.recv(1024).decode # Check if re.search("Error: The specified IP address is invalid", info["content"]): - raise ForwardError("Error: The specified IP address is invalid,IP should be a network segment") + raise ForwardError( + "Error: The specified IP address is invalid,IP should be a network segment") # Get new host prompt. self.getPrompt() # save the configuration @@ -311,7 +329,7 @@ def showInterfacePower(self, port): port = re.findall('\d+\S+', port)[0] cmd = 'display transceiver interface XGigabitEthernet ' + port + ' verbose ' elif port.startswith('Gi'): - port = re.findall('\d+\S+',port)[0] + port = re.findall('\d+\S+', port)[0] cmd = 'display transceiver interface GigabitEthernet ' + port + ' verbose ' _result = self.command(cmd=cmd, prompt=prompt) if not _result['status'] or _result['state'] != 'success': @@ -351,7 +369,7 @@ def aclGet(self, acl_name='LOGIN', acl_ip='1.1.1.5'): "success": "[\r\n]+\S+(>|\]) ?$", "error": "Invalid command[\s\S]+", } - acl = {} + # acl = {} acl_name = re.sub(' *', '', acl_name) cmd = "display current-configuration | begin user-interface" result = self.command(cmd=cmd, prompt=prompt) @@ -388,14 +406,15 @@ def showSystemUptime(self): result = self.command(cmd=cmd, prompt=prompt) if not result['status'] or result['state'] != 'success': njInfo['status'] = result['errLog'] - uptime=re.search('Switch uptime is\s+(\d+)\s+weeks, (\d+)\s+days',result['content']) + uptime = re.search( + 'Switch uptime is\s+(\d+)\s+weeks, (\d+)\s+days', result['content']) weeksUptime = uptime.groups()[0] - daysUptime= uptime.groups()[1] + daysUptime = uptime.groups()[1] njInfo['status'] = True - njInfo['content'] = weeksUptime,daysUptime + njInfo['content'] = weeksUptime, daysUptime return njInfo - def usefulContent(self,mystr,matchContent): + def usefulContent(self, mystr, matchContent): ''' Args: matchContent @@ -416,30 +435,30 @@ def usefulContent(self,mystr,matchContent): 3 173 77 44% 85% ''' - dash_count=3 - content_match=False - usefulList=[] + dash_count = 3 + content_match = False + usefulList = [] mystr = mystr.split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall(matchContent, line): - content_match=True - continue - if content_match==False : - continue - if re.findall('----------',line): - dash_count=dash_count-1 - continue - if dash_count==1: - usefulList.append(line) #print line - continue - elif dash_count == 0 : - content_match=False - dash_count=3 + if re.findall(matchContent, line): + content_match = True + continue + if content_match is False: + continue + if re.findall('----------', line): + dash_count = dash_count - 1 + continue + if dash_count == 1: + usefulList.append(line) # print line + continue + elif dash_count == 0: + content_match = False + dash_count = 3 return usefulList - def usefulContent2(self,mystr,matchContent): + def usefulContent2(self, mystr, matchContent): ''' Args: matchContent @@ -456,27 +475,27 @@ def usefulContent2(self,mystr,matchContent): PWR2 Present AC Supply 5.66 53.53 302.98 ''' - dash_count=2 - content_match=False - usefulList=[] + dash_count = 2 + content_match = False + usefulList = [] mystr = mystr.split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall(matchContent, line): - content_match=True - continue - if content_match==False : - continue - if re.findall('----------',line) or re.findall('System Memory Usage Information:',line): - dash_count=dash_count-1 - continue - if dash_count==1: - usefulList.append(line) #print line - continue - elif dash_count == 0 : - content_match=False - dash_count=2 + if re.findall(matchContent, line): + content_match = True + continue + if content_match is False: + continue + if re.findall('----------', line) or re.findall('System Memory Usage Information:', line): + dash_count = dash_count - 1 + continue + if dash_count == 1: + usefulList.append(line) # print line + continue + elif dash_count == 0: + content_match = False + dash_count = 2 return usefulList def showHardware(self): @@ -494,125 +513,128 @@ def showHardware(self): "success": "[\r\n]+\S+.+(>|\]) ?$", "error": "Invalid command[\s\S]+", } - cmd='display health' + cmd = 'display health' result = self.command(cmd=cmd, prompt=prompt) if not result['status'] or result['state'] != 'success': njInfo['errLog'] = result['errLog'] return njInfo - dashCount=2 - contentMatch=False - usefulList=[] + dashCount = 2 + contentMatch = False + usefulList = [] mystr = result['content'].split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall('Slot Card Sensor SensorName Status', line): - contentMatch=True - continue - if contentMatch==False : - continue - if re.findall('----------',line) or re.findall('System Memory Usage Information:',line): - dashCount=dashCount-1 - continue - if dashCount==1: - usefulList.append(line) #print line - continue - elif dashCount == 0 : - contentMatch=False - dashCount=2 + if re.findall('Slot Card Sensor SensorName Status', line): + contentMatch = True + continue + if contentMatch is False: + continue + if re.findall('----------', line) or re.findall('System Memory Usage Information:', line): + dashCount = dashCount - 1 + continue + if dashCount == 1: + usefulList.append(line) # print line + continue + elif dashCount == 0: + contentMatch = False + dashCount = 2 resultSensor = usefulList - dashCount=2 - contentMatch=False - usefulList=[] + dashCount = 2 + contentMatch = False + usefulList = [] mystr = result['content'].split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall('PowerID Online Mode State Current', line): - contentMatch=True - continue - if contentMatch==False : - continue - if re.findall('----------',line) or re.findall('System Memory Usage Information:',line): - dashCount=dashCount-1 - continue - if dashCount==1: - usefulList.append(line) #print line - continue - elif dashCount == 0 : - contentMatch=False - dashCount=2 + if re.findall('PowerID Online Mode State Current', line): + contentMatch = True + continue + if contentMatch is False: + continue + if re.findall('----------', line) or re.findall('System Memory Usage Information:', line): + dashCount = dashCount - 1 + continue + if dashCount == 1: + usefulList.append(line) # print line + continue + elif dashCount == 0: + contentMatch = False + dashCount = 2 reultTemperature = usefulList - dashCount=2 - contentMatch=False - usefulList=[] + dashCount = 2 + contentMatch = False + usefulList = [] mystr = result['content'].split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall('PowerID Online Mode State Current', line): - contentMatch=True - continue - if contentMatch==False : - continue - if re.findall('----------',line) or re.findall('System Memory Usage Information:',line): - dashCount=dashCount-1 - continue - if dashCount==1: - usefulList.append(line) #print line - continue - elif dashCount == 0 : - contentMatch=False - dashCount=2 + if re.findall('PowerID Online Mode State Current', line): + contentMatch = True + continue + if contentMatch is False: + continue + if re.findall('----------', line) or re.findall('System Memory Usage Information:', line): + dashCount = dashCount - 1 + continue + if dashCount == 1: + usefulList.append(line) # print line + continue + elif dashCount == 0: + contentMatch = False + dashCount = 2 resultPower = usefulList - dashCount=2 - contentMatch=False - usefulList=[] + dashCount = 2 + contentMatch = False + usefulList = [] mystr = result['content'].split('\n') mystr.pop(0) mystr.pop(-1) for line in mystr: - if re.findall('FanID FanNum Online Register', line): - contentMatch=True - continue - if contentMatch==False : - continue - if re.findall('----------',line) or re.findall('System Memory Usage Information:',line): - dashCount=dashCount-1 - continue - if dashCount==1: - usefulList.append(line) #print line - continue - elif dashCount == 0 : - contentMatch=False - dashCount=2 - result_fan = usefulList + if re.findall('FanID FanNum Online Register', line): + contentMatch = True + continue + if contentMatch is False: + continue + if re.findall('----------', line) or re.findall('System Memory Usage Information:', line): + dashCount = dashCount - 1 + continue + if dashCount == 1: + usefulList.append(line) # print line + continue + elif dashCount == 0: + contentMatch = False + dashCount = 2 + # result_fan = usefulList - sensorNormal=True - temperatureNormal=True - powerNormal=True - fanNormal=True + # sensorNormal = True + # temperatureNormal = True + # powerNormal = True + # fanNormal = True errorDevice = [] for line in resultSensor: - if not re.findall('Normal', line): #health output for sensor: If a line include 'Normal', it is normal - sensorNormal=False - errorDevice.append(line) + # health output for sensor: If a line include 'Normal', it is normal + if not re.findall('Normal', line): + # sensorNormal = False + errorDevice.append(line) for line in reultTemperature: - if not re.findall('Normal', line): #health output for temperature: If a line include 'Normal', it is normal - temperatureNormal=False - errorDevice.append(line) - for line in resultPower:#health output for power: If a line include 'Present' and 'Supply' together, it is normal + # health output for temperature: If a line include 'Normal', it is normal + if not re.findall('Normal', line): + # temperatureNormal = False + errorDevice.append(line) + for line in resultPower: + # health output for power: If a line include 'Present' and 'Supply' together, it is normal if re.findall('Present', line): - if not re.findall('Supply',line): - temperatureNormal=False + if not re.findall('Supply', line): + # temperatureNormal = False errorDevice.append(line) if re.findall('FAN', line): if not (re.findall('Registered', line)): - fanNormal = False + # fanNormal = False errorDevice.append(line) if not errorDevice: njInfo['content'] = 'check pass' @@ -649,25 +671,25 @@ def showMemory(self): mystr.pop(-1) for line in mystr: if re.findall('System memory usage at', line): - contentMatch=True + contentMatch = True continue - if contentMatch==False : + if contentMatch is False: continue - if re.findall('----------',line): - dashCount = dashCount-1 + if re.findall('----------', line): + dashCount = dashCount - 1 continue if dashCount == 1: - usefulList.append(line) - continue - elif dashCount == 0 : - contentMatch = False - dashCount = 3 + usefulList.append(line) + continue + elif dashCount == 0: + contentMatch = False + dashCount = 3 resultMemory = usefulList # resultMemory=self.usefulContent(result['content'],'System memory usage at') #strip off unuseful line for line in resultMemory: - value = re.findall('(\d+)%', line) - if float(value[0]) >= float(value[1]): - memoryEnough = False + value = re.findall('(\d+)%', line) + if float(value[0]) >= float(value[1]): + memoryEnough = False njInfo['status'] = True njInfo['content'] = memoryEnough return njInfo @@ -700,27 +722,28 @@ def showCpu(self): mystr.pop(-1) for line in mystr: if re.findall('System memory usage at', line): - contentMatch=True + contentMatch = True continue - if contentMatch==False : + if contentMatch is False: continue - if re.findall('----------',line): - dashCount = dashCount-1 + if re.findall('----------', line): + dashCount = dashCount - 1 continue if dashCount == 1: usefulList.append(line) continue - elif dashCount == 0 : + elif dashCount == 0: contentMatch = False dashCount = 3 - resultMemory = usefulList + # resultMemory = usefulList # result_cpu=self.usefulContent(result['content'],'System cpu usage at') #strip off unuseful line + resultCPU = usefulList for line in resultCPU: - value = re.findall('(\d+)%', line) - if float(value[0]) >= float(value[1]): - cpu_enough = False + value = re.findall('(\d+)%', line) + if float(value[0]) >= float(value[1]): + cpu_enough = False njInfo['status'] = True - njInfo['content'] = cpu_enough,resultCPU + njInfo['content'] = cpu_enough, resultCPU return njInfo def showSpanningTreeStatus(self): diff --git a/lib/forward/devclass/s9312e.py b/lib/forward/devclass/s9312e.py index 30eb5f0..4b814d2 100644 --- a/lib/forward/devclass/s9312e.py +++ b/lib/forward/devclass/s9312e.py @@ -19,8 +19,7 @@ -----Introduction----- [Core][forward] Device class for s9312e. """ -import re - +# import re from forward.devclass.baseHuawei import BASEHUAWEI diff --git a/lib/forward/devclass/sr7750.py b/lib/forward/devclass/sr7750.py index 166edb2..a6c55b5 100644 --- a/lib/forward/devclass/sr7750.py +++ b/lib/forward/devclass/sr7750.py @@ -26,6 +26,7 @@ class SR7750(BASEBAER): """This is a manufacturer of baer, so it is integrated with BASEBAER library.""" + def showInterfacePower(self, port): njInfo = { 'status': False, @@ -89,16 +90,17 @@ def showSyslog(self): "error": "Unknown command[\s\S]+", } logInfo = { - 'status':True, - 'errLog':'', - 'content':{} + 'status': True, + 'errLog': '', + 'content': {} } cmd = 'show log syslog' result = self.command(cmd=cmd, prompt=prompt) if not result['status'] or result['state'] != 'success': njInfo['errLog'] = result['errLog'] return njInfo - syslogList= re.findall('(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\w+)', result['content']) + syslogList = re.findall( + '(\d+\.\d+\.\d+\.\d+)\s+\d+\s+(\w+)', result['content']) logInfo['content']['syslog_server'] = {} for serinfo in syslogList: logInfo['content']['syslog_server'][serinfo[0]] = serinfo[1] diff --git a/lib/forward/devclass/sr7950.py b/lib/forward/devclass/sr7950.py index 1ac8351..29327ef 100644 --- a/lib/forward/devclass/sr7950.py +++ b/lib/forward/devclass/sr7950.py @@ -26,6 +26,7 @@ class SR7950(BASEBAER): """This is a manufacturer of baer, so it is integrated with BASEBAER library. """ + def showInterfacePower(self, port): njInfo = { 'status': False, @@ -48,29 +49,34 @@ def showInterfacePower(self, port): resultPower = resultPower['content'].split('\r\n') resultPower.pop(0) resultPower.pop(-1) - for line in resultPower: + result = {} + for line in resultPower: power = line.strip().split() if power[0] == '1': - result['TX_1'] = power[3] - result['RX_1'] = power[4] + result['TX_1'] = power[3] + result['RX_1'] = power[4] elif power[0] == '2': - result['TX_2'] = power[3] - result['RX_2'] = power[4] + result['TX_2'] = power[3] + result['RX_2'] = power[4] elif power[0] == '3': - result['TX_3'] = power[3] - result['RX_3'] = power[4] + result['TX_3'] = power[3] + result['RX_3'] = power[4] elif power[0] == '4': - result['TX_4'] = power[3] - result['RX_4'] = power[4] - if result['TX_1'] < '-4.80' or result['TX_2'] < '-4.80' or result['TX_3'] < '-4.80' or result['TX_4'] < '-4.80': + result['TX_4'] = power[3] + result['RX_4'] = power[4] + if result['TX_1'] < '-4.80' or result['TX_2'] < '-4.80' or \ + result['TX_3'] < '-4.80' or result['TX_4'] < '-4.80': powerLevel['TX'] = 'LOW' - elif result['TX_1'] > '5.00' or result['TX_2'] > '5.00' or result['TX_3'] > '5.00' or result['TX_4'] > '5.00': + elif result['TX_1'] > '5.00' or result['TX_2'] > '5.00' or \ + result['TX_3'] > '5.00' or result['TX_4'] > '5.00': powerLevel['TX'] = 'HIGH' else: powerLevel['TX'] = 'normal' - if result['RX_1'] < '-12.10' or result['RX_2'] < '-12.10' or result['RX_3'] < '-12.10' or result['RX_4'] < '-12.10': + if result['RX_1'] < '-12.10' or result['RX_2'] < '-12.10' or \ + result['RX_3'] < '-12.10' or result['RX_4'] < '-12.10': powerLevel['RX'] = 'LOW' - elif result['RX_1'] > '5.00' or result['RX_2'] > '5.00' or result['RX_3'] > '5.00' or result['RX_4'] > '5.00': + elif result['RX_1'] > '5.00' or result['RX_2'] > '5.00' or \ + result['RX_3'] > '5.00' or result['RX_4'] > '5.00': powerLevel['RX'] = 'HIGH' else: powerLevel['RX'] = 'normal' @@ -112,4 +118,4 @@ def showInterfacePower(self, port): result['RX'] = 'normal' njInfo['status'] = True njInfo['content'] = result - return njInfo + return njInfo diff --git a/lib/forward/devclass/unusable_command_interface.py b/lib/forward/devclass/unusable_command_interface.py index 9a189c8..3a32c17 100644 --- a/lib/forward/devclass/unusable_command_interface.py +++ b/lib/forward/devclass/unusable_command_interface.py @@ -1,105 +1,103 @@ - - - - - - """def auto_execute(self): - # regx compile - _promptKey = prompt.keys() - for key in _promptKey: - prompt[key] = re.compile(prompt[key]) - result = { - 'status': False, - 'content': '', - 'errLog': '', - "state": None - } - if self.isLogin is False: - result['errLog'] = '[Execute Error]: device not login.' - return result - # Setting timeout. - self.shell.settimeout(timeout) - # Parameters check - parameterFormat = { - "success": "regular-expression-success", - "error": "regular-expression-error" - } - if (cmd is None) or (not isinstance(prompt, dict)) or (not isinstance(timeout, int)): - raise ForwardError("You should given a parameter for prompt such as: %s" % (str(parameterFormat))) - # Clean buffer data. - while self.shell.recv_ready(): - self.shell.recv(1024) +""" +def auto_execute(self): + # regx compile + _promptKey = prompt.keys() + for key in _promptKey: + prompt[key] = re.compile(prompt[key]) + result = { + 'status': False, + 'content': '', + 'errLog': '', + "state": None + } + if self.isLogin is False: + result['errLog'] = '[Execute Error]: device not login.' + return result + # Setting timeout. + self.shell.settimeout(timeout) + # Parameters check + parameterFormat = { + "success": "regular-expression-success", + "error": "regular-expression-error" + } + if (cmd is None) or (not isinstance(prompt, dict)) or (not isinstance(timeout, int)): + raise ForwardError("You should given a parameter for prompt such as: %s" % (str(parameterFormat))) + # Clean buffer data. + while self.shell.recv_ready(): + self.shell.recv(1024) + try: + # send a command + self.shell.send("{cmd}\r".format(cmd=cmd)) + except Exception: + # break, if faild + result["errLog"] = "That forwarder has sent a command is failed." + return result + isBreak = False + while True: + # Remove special characters. + result["content"] = re.sub("", "", result["content"]) + self.getMore(result["content"]) try: - # send a command - self.shell.send("{cmd}\r".format(cmd=cmd)) + result["content"] += self.shell.recv(204800) except Exception: - # break, if faild - result["errLog"] = "That forwarder has sent a command is failed." + result["errLog"] = "Forward had recived data timeout. [%s]" % result["content"] return result - isBreak = False - while True: - # Remove special characters. - result["content"] = re.sub("", "", result["content"]) - self.getMore(result["content"]) - try: - result["content"] += self.shell.recv(204800) - except Exception: - result["errLog"] = "Forward had recived data timeout. [%s]" % result["content"] - return result - # Check if all the command results have been returned - xPrompt = re.search(self.basePrompt, re.sub(self.moreFlag, "", result["content"].split("\r\n")[-1])) - if xPrompt: - xPrompt = xPrompt.group().strip(" ") - # The all command results may have been returned. - # Send a key of enter to reconfirm. - self.shell.send("\r") - tmp = self.shell.recv(512) - yPrompt = re.search(self.basePrompt, re.sub(self.moreFlag, "", tmp.split("\r\n")[-1])) - if yPrompt: - # Formate prompt. - yPrompt = yPrompt.group().strip(" ") - # Compare two host prompts for consistency - if xPrompt == yPrompt: - # Confirmed. - # [ex] GD-N7010-S2 # - # [ex] GD-N7010-S2 # - break - else: - # The all command results have been not returned yet,so continue - result["content"] += tmp - continue + # Check if all the command results have been returned + xPrompt = re.search(self.basePrompt, re.sub(self.moreFlag, "", result["content"].split("\r\n")[-1])) + if xPrompt: + xPrompt = xPrompt.group().strip(" ") + # The all command results may have been returned. + # Send a key of enter to reconfirm. + self.shell.send("\r") + tmp = self.shell.recv(512) + yPrompt = re.search(self.basePrompt, re.sub(self.moreFlag, "", tmp.split("\r\n")[-1])) + if yPrompt: + # Formate prompt. + yPrompt = yPrompt.group().strip(" ") + # Compare two host prompts for consistency + if xPrompt == yPrompt: + # Confirmed. + # [ex] GD-N7010-S2 # + # [ex] GD-N7010-S2 # + break else: # The all command results have been not returned yet,so continue result["content"] += tmp continue else: - # The all command results have been not returned yet,so continue + # The all command results have been not returned yet,so continue + result["content"] += tmp continue - # Mathing specify key - for key in prompt: - if re.search(prompt[key], re.sub(self.moreFlag, "", result["content"])): - # Found it - result["state"] = key - isBreak = True - break - # Delete page break - result["content"] = re.sub("\r\n.*?\r *?\r", "\r\n", result["content"]) - # Clearing special characters - result["content"] = re.sub(" *---- More ----\x1b\[42D \x1b\[42D", - "", - result["content"]) - result["content"] = re.sub("<--- More --->\\r +\\r", "", result["content"]) - # remove the More charactor - result["content"] = re.sub(' \-\-More\(CTRL\+C break\)\-\- (\x00|\x08){0,} +(\x00|\x08){0,}', "", - result["content"]) - # remove the space key - result["content"] = re.sub("(\x08)+ +", "", result["content"]) - result["status"] = True - return result""" + else: + # The all command results have been not returned yet,so continue + continue + # Mathing specify key + for key in prompt: + if re.search(prompt[key], re.sub(self.moreFlag, "", result["content"])): + # Found it + result["state"] = key + isBreak = True + break + # Delete page break + result["content"] = re.sub("\r\n.*?\r *?\r", "\r\n", result["content"]) + # Clearing special characters + result["content"] = re.sub(" *---- More ----\x1b\[42D \x1b\[42D", + "", + result["content"]) + result["content"] = re.sub("<--- More --->\\r +\\r", "", result["content"]) + # remove the More charactor + result["content"] = re.sub(' \-\-More\(CTRL\+C break\)\-\- (\x00|\x08){0,} +(\x00|\x08){0,}', "", + result["content"]) + # remove the space key + result["content"] = re.sub("(\x08)+ +", "", result["content"]) + result["status"] = True + return result +""" + - def command(self, cmd=None, prompt={}, timeout=30): - """execute a command line, powerful and suitable for any scene, - but need to define whole prompt dict list - """ - # regx compile - _promptKey = prompt.keys() +def command(self, cmd=None, prompt={}, timeout=30): + """execute a command line, powerful and suitable for any scene, + but need to define whole prompt dict list + """ + # regx compile + # _promptKey = prompt.keys() diff --git a/lib/forward/utils/sshv1.py b/lib/forward/utils/sshv1.py index 8f26f62..35084a0 100644 --- a/lib/forward/utils/sshv1.py +++ b/lib/forward/utils/sshv1.py @@ -16,10 +16,10 @@ -----Introduction----- [Core][forward] Function for sshv1, by using pexpect module. """ -import os -import sys -import re -from forward.utils.forwardError import ForwardError +# import os +# import sys +# import re +# from forward.utils.forwardError import ForwardError import pexpect diff --git a/lib/forward/utils/telnet.py b/lib/forward/utils/telnet.py index 308bd60..3ce60ce 100644 --- a/lib/forward/utils/telnet.py +++ b/lib/forward/utils/telnet.py @@ -20,7 +20,7 @@ """ import telnetlib -import re +# import re class NJTELNETWraper(telnetlib.Telnet): diff --git a/protocol/flake8 b/protocol/flake8 index ce1ca2c..31b7a7b 100644 --- a/protocol/flake8 +++ b/protocol/flake8 @@ -1,4 +1,4 @@ [flake8] -exclude = unittests,build,tests,migrations,.git,.tox,docs,*egg,env,instance,callback -ignore = E402, E123, F401, W605, E501, W601 -max-line-length = 120 +exclude=unittests,build,tests,migrations,.git,.tox,docs,*egg,env,instance,callback +ignore=E402,E123,F401,W605,E501,W601 +max-line-length=120 From 1a90c491b55308b176d7b7a3e595af90a3b4e322 Mon Sep 17 00:00:00 2001 From: linzhigeng Date: Thu, 12 Mar 2020 17:17:12 +0800 Subject: [PATCH 4/5] add markdowns --- docs/class/sshv2/baer/bear7850.md | 467 +++++++++++++++++++++++++++ docs/class/sshv2/baer/sr7750.md | 2 + docs/class/sshv2/f5/f510000.md | 2 + docs/class/sshv2/fenghuo/s5700.md | 442 +++++++++++++++++++++++++ docs/class/sshv2/fortinet/fg3800.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/fortinet/fg3950.md | 2 + docs/class/sshv2/h3c/README.md | 439 +++++++++++++++++++++++++ docs/class/sshv2/h3c/m9006.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/h3c/m9008.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/h3c/m9012.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/h3c/s12508.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/h3c/s12516.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/h3c/s6900.md | 478 ++++++++++++++++++++++++++++ docs/class/sshv2/huawei/ce16808.md | 421 ++++++++++++++++++++++++ docs/class/sshv2/huawei/ce16816.md | 421 ++++++++++++++++++++++++ docs/class/sshv2/huawei/ce6881.md | 421 ++++++++++++++++++++++++ docs/class/sshv2/huawei/ne40ex16.md | 2 + docs/class/sshv2/huawei/ne40ex8.md | 421 ++++++++++++++++++++++++ 18 files changed, 6386 insertions(+) create mode 100644 docs/class/sshv2/baer/bear7850.md create mode 100644 docs/class/sshv2/fenghuo/s5700.md create mode 100644 docs/class/sshv2/fortinet/fg3800.md create mode 100644 docs/class/sshv2/h3c/README.md create mode 100644 docs/class/sshv2/h3c/m9006.md create mode 100644 docs/class/sshv2/h3c/m9008.md create mode 100644 docs/class/sshv2/h3c/m9012.md create mode 100644 docs/class/sshv2/h3c/s12508.md create mode 100644 docs/class/sshv2/h3c/s12516.md create mode 100644 docs/class/sshv2/h3c/s6900.md create mode 100644 docs/class/sshv2/huawei/ce16808.md create mode 100644 docs/class/sshv2/huawei/ce16816.md create mode 100644 docs/class/sshv2/huawei/ce6881.md create mode 100644 docs/class/sshv2/huawei/ne40ex8.md diff --git a/docs/class/sshv2/baer/bear7850.md b/docs/class/sshv2/baer/bear7850.md new file mode 100644 index 0000000..8f78f7d --- /dev/null +++ b/docs/class/sshv2/baer/bear7850.md @@ -0,0 +1,467 @@ +## 基本介绍 + +* 支持贝尔7850型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看Hostname信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseBaer](/docs/class/sshv2/baer/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"DGJD-PSC-P9F1-P0D1-S-HL-7850GW-1","errLog":""} \ No newline at end of file diff --git a/docs/class/sshv2/baer/sr7750.md b/docs/class/sshv2/baer/sr7750.md index f28c0c9..2070ffa 100644 --- a/docs/class/sshv2/baer/sr7750.md +++ b/docs/class/sshv2/baer/sr7750.md @@ -365,6 +365,8 @@ >>> instance.showSnmp() >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} +--- + * showInterface 查看设备的Interface列表信息。 diff --git a/docs/class/sshv2/f5/f510000.md b/docs/class/sshv2/f5/f510000.md index a29f65a..9b5abc5 100644 --- a/docs/class/sshv2/f5/f510000.md +++ b/docs/class/sshv2/f5/f510000.md @@ -365,6 +365,8 @@ >>> instance.showSnmp() >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} +--- + * showInterface 查看设备的Interface列表信息。 diff --git a/docs/class/sshv2/fenghuo/s5700.md b/docs/class/sshv2/fenghuo/s5700.md new file mode 100644 index 0000000..6c0aae1 --- /dev/null +++ b/docs/class/sshv2/fenghuo/s5700.md @@ -0,0 +1,442 @@ +## 基本介绍 + +* 支持F5的S5700型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFenghuo](/docs/class/sshv2/fenghuo/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + diff --git a/docs/class/sshv2/fortinet/fg3800.md b/docs/class/sshv2/fortinet/fg3800.md new file mode 100644 index 0000000..d753cc6 --- /dev/null +++ b/docs/class/sshv2/fortinet/fg3800.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持烽火的FG3800型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/fortinet/fg3950.md b/docs/class/sshv2/fortinet/fg3950.md index 5b3ef2c..78d1984 100644 --- a/docs/class/sshv2/fortinet/fg3950.md +++ b/docs/class/sshv2/fortinet/fg3950.md @@ -365,6 +365,8 @@ >>> instance.showSnmp() >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} +--- + * showInterface 查看设备的Interface列表信息。 diff --git a/docs/class/sshv2/h3c/README.md b/docs/class/sshv2/h3c/README.md new file mode 100644 index 0000000..8bfb21c --- /dev/null +++ b/docs/class/sshv2/h3c/README.md @@ -0,0 +1,439 @@ +## 基本介绍 + +* 支持华三设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseSSHV2](/docs/class/sshv2/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/h3c/m9006.md b/docs/class/sshv2/h3c/m9006.md new file mode 100644 index 0000000..0d6bc2a --- /dev/null +++ b/docs/class/sshv2/h3c/m9006.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的M9006型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/h3c/m9008.md b/docs/class/sshv2/h3c/m9008.md new file mode 100644 index 0000000..f24e1e1 --- /dev/null +++ b/docs/class/sshv2/h3c/m9008.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的M9008型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/h3c/m9012.md b/docs/class/sshv2/h3c/m9012.md new file mode 100644 index 0000000..d268344 --- /dev/null +++ b/docs/class/sshv2/h3c/m9012.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的M9012型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/h3c/s12508.md b/docs/class/sshv2/h3c/s12508.md new file mode 100644 index 0000000..362a6e3 --- /dev/null +++ b/docs/class/sshv2/h3c/s12508.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的S12508型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/h3c/s12516.md b/docs/class/sshv2/h3c/s12516.md new file mode 100644 index 0000000..99d929c --- /dev/null +++ b/docs/class/sshv2/h3c/s12516.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的S12516型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/h3c/s6900.md b/docs/class/sshv2/h3c/s6900.md new file mode 100644 index 0000000..20a2309 --- /dev/null +++ b/docs/class/sshv2/h3c/s6900.md @@ -0,0 +1,478 @@ +## 基本介绍 + +* 支持华三的S6900型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| configMode | 切换至配置模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | +| showHostname | 查看设备名称信息 | + + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseFortinet](/docs/class/sshv2/fortinet/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权模式。支持从普通模式切换至特权模式,也支持从更高一级的模式(如配置模式、接口模式等)降低至特权模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果设备提示需要输入特权模式密码的,在登录之前必须传递对应的特权模式密码给Forward,以便在切换时自动输入,否则会切换失败;如果切换至特权模式无需密码的,可以传递特权模式密码动作。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 用户名或密码错误 | + + * 案例(部分设备需切换至特权模式才能执行show run命令,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.privilegeMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("show run",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` +--- + +* configMode + + 在设备上,切换至配置模式。支持从普通模式直接切换至配置模式,也支持从更高一级的模式(如接口模式等)降低至配置模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:如果是从普通模式直接切换到配置模式的,中间需要经过切换至`特权模式`,在该过程中有可能需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例(当设备进入配置模式时,才能进入interface模式,下面模拟这样的场景) + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.configMode() + >>> {"status":True,"content":"","errLog":""} + >>> instance.command("interface ge0/0/1",prompt={"success":"(#|>|\]) ?$"},"error":"error") + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + +--- + +* Interface数据格式字段 + + 查看设备的Interface列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} + +--- + +* showHostname + + 查看设备名称信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | DGJD-PSC..... | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showHostname() + >>> {"status":True,"content":"xxxxxxxxxxxxxxxxxx","errLog":""} diff --git a/docs/class/sshv2/huawei/ce16808.md b/docs/class/sshv2/huawei/ce16808.md new file mode 100644 index 0000000..9fead19 --- /dev/null +++ b/docs/class/sshv2/huawei/ce16808.md @@ -0,0 +1,421 @@ +## 基本介绍 + +* 支持华为的CE16808型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| generalMode | 切换至普通模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权(sys)模式。 + + 注意:账户需要具备权限才能切换,否则不能切换。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) +--- + +* generalMode + + 在设备上,切换至至普通模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:保存配置需要降低至该模式下。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.generalModeMode() + >>> {"status":True,"content":"","errLog":""} + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/ce16816.md b/docs/class/sshv2/huawei/ce16816.md new file mode 100644 index 0000000..e6e0710 --- /dev/null +++ b/docs/class/sshv2/huawei/ce16816.md @@ -0,0 +1,421 @@ +## 基本介绍 + +* 支持华为的CE16816型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| generalMode | 切换至普通模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权(sys)模式。 + + 注意:账户需要具备权限才能切换,否则不能切换。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) +--- + +* generalMode + + 在设备上,切换至至普通模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:保存配置需要降低至该模式下。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.generalModeMode() + >>> {"status":True,"content":"","errLog":""} + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/ce6881.md b/docs/class/sshv2/huawei/ce6881.md new file mode 100644 index 0000000..7ba3ac1 --- /dev/null +++ b/docs/class/sshv2/huawei/ce6881.md @@ -0,0 +1,421 @@ +## 基本介绍 + +* 支持华为的CE6881型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| generalMode | 切换至普通模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权(sys)模式。 + + 注意:账户需要具备权限才能切换,否则不能切换。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) +--- + +* generalMode + + 在设备上,切换至至普通模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:保存配置需要降低至该模式下。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.generalModeMode() + >>> {"status":True,"content":"","errLog":""} + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} diff --git a/docs/class/sshv2/huawei/ne40ex16.md b/docs/class/sshv2/huawei/ne40ex16.md index e718073..4f5ef12 100644 --- a/docs/class/sshv2/huawei/ne40ex16.md +++ b/docs/class/sshv2/huawei/ne40ex16.md @@ -344,6 +344,8 @@ >>> instance.showSnmp() >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} +--- + * showInterface 查看设备的Interface列表信息。 diff --git a/docs/class/sshv2/huawei/ne40ex8.md b/docs/class/sshv2/huawei/ne40ex8.md new file mode 100644 index 0000000..b075646 --- /dev/null +++ b/docs/class/sshv2/huawei/ne40ex8.md @@ -0,0 +1,421 @@ +## 基本介绍 + +* 支持华为的NE40EX8型设备的操作。 + +## 接口列表 + + +| 接口名 | 描述 | +| --- | --- | +| __init__ | 实例初始化 | +| login | 登录目标设备 | +| logout | 登出目标设备 | +| execute | 执行查询命令(普通) | +| command | 执行所有命令(高级) | +| getPrompt | 获取主机提示符,并识别登录设备后所处模式 | +| getMore | 自动获取分页消息 | +| cleanBuffer | 清除通道内残留信息 | +| privilegeMode | 切换至特权模式 | +| generalMode | 切换至普通模式 | +| commit | 保存配置 | +| showVersion | 查看设备版本信息 | +| showRoute | 查看路由表信息 | +| showVlan | 查看Vlan表信息 | +| showNtp | 查看NTP服务器地址信息 | +| showLog | 查看SYSLOG服务器地址信息 | +| showSnmp | 查看SNMP服务端地址信息 | +| showInterface | 查看Interface列表信息 | +| showRun | 查看设备整体配置信息 | + +## 接口详情 + + +* __init__ + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* login + + 调用此接口进行登录(参数来自init),成功后取得shell环境、清除登陆后设备发送的欢迎信息、设置超时时间(timeout),判断登录设备是否遇到密码过期提醒需要修改、以及取得主机提示符,比如 `[root@localhost ] # ` 。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* logout + + 注销与单个设备的会话。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* execute + + 在目标设备上执行一个`查询`命令,比如`show`、`display`,然后取得该命令的执行结果,最后返回一个字典(dict)格式的数据。 + + 注意: 不要使用该接口执行切换模式的命令,比如`enable`、`sys`、`config`、`interface`,也不要在切换模式后使用该接口,如果真的有需要,请使用command高级开发接口。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* command + + 在目标设备上执行`任何`命令,然后一直等待收取该命令的执行结果,直到`预期的消息出现`或`等待超时`为止,最后返回一个字典(dict)格式的数据。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getPrompt + + 取得目标设备上的主机提示符,比如:`TEST-N7710-1# `、`TEST-N7710-1> `等。 + + `注意:该接口一般仅用于Forward内部使用。` + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* getMore + + 自动获取因一个命令结果较长而导致的分页内容。 + + `注意:该接口仅用于Forward内部使用`。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* cleanBuffer + + 清除在`socket`内,因接受消息不彻底而遗留的字符数据。 + + 注意:`execute`、`command`在每次执行命令之前会自动调用该接口进行清除,该接口一般只用于Forward内部使用。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) + +--- + +* privilegeMode + + 在设备上,切换至特权(sys)模式。 + + 注意:账户需要具备权限才能切换,否则不能切换。 + + 功能特性继承自[baseHuawei](/docs/class/sshv2/huawei/README.md) +--- + +* generalMode + + 在设备上,切换至至普通模式。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:保存配置需要降低至该模式下。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 切换失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.generalModeMode() + >>> {"status":True,"content":"","errLog":""} + ``` + +--- + +* commit + + 在设备上,当配置好一些参数后,可以调用该接口进行保存配置。而在调用之前,无需关心设备处于哪一级模式下。 + + 注意:调用该接口需要shell处于特权模式下(华为设备除外),在这个过程中可能会需要特权模式密码。所以在Forward登录之初,就应该传递特权模式密码以备用,如果设备不需要特权模式密码,则可以不用传递。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 保存失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.commit() + >>> {"status":True,"content":"保存成功","errLog":""} + +--- + +* showVersion + + 查看设备的软件版本信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | str | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVersion() + >>> {"status":True,"content":"V7.1.2.3","errLog":""} + +--- + +* showRoute + + 查看设备的路由表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | 路由列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 路由列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | net | str | 网段 | 192.168.1.0 | + | mask | str | 掩码 | 24 | + | metric | str | metric值 | 1 | + | type | str | 路由类型 | ospf | + | description | str | 描述 | 无 | + | interface | str | 网卡口 | g1 | + | via | str | 下一跳网关地址 | 10.0.0.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRoute() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showVlan + + 查看设备的Vlan列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Vlan列表的详细字段 | + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * Vlan列表的详细字段 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | id | str | ID | 20 | + | description | str | 描述 | 无 | + | status | str | 状态 | 无 | + | type | str | Vlan类型 | 无 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showVlan() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + +--- + +* showNtp + + 查看设备的NTP服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.1.1","192.168.1.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showNtp() + >>> {"status":True,"content":["192.168.1.1","192.168.1.2"],"errLog":""} + +--- + +* showLog + + 查看设备的SYSLOG服务器地址列表信息。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.2.1","192.168.2.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showLog() + >>> {"status":True,"content":["192.168.2.1","192.168.2.2"],"errLog":""} + +--- + +* showSnmp + + 查看设备的SYSLOG服务器地址列表信息。 + + 注意:该接口只获取trap模式的SNMP服务器地址列表。 + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | ["192.168.3.1","192.168.3.2"]| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showSnmp() + >>> {"status":True,"content":["192.168.3.1","192.168.3.2"],"errLog":""} + +--- + +* showInterface + + 查看设备的Interface列表信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Interface数据格式字段| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + + * Interface数据格式字段 + + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | interfaceName| str | 名称 | ge/0/1/1 | + | members | list | 接口绑定的网卡 | [....] | + | lineState | str | 接口状态 | enable或其他叫法 | + | adminSteate | str | 管理状态 | admin down等等 | + | description | str | 描述 | 无 | + | speed | str | 接口速率 | 100M/bps | + | type | str | 接口类型 | 各个设备型号叫法不一 | + | duplex | str | 工作模式 | 双工/半双工/自动 | + | inputRate | str | 接口吞数据量速率 | 无 | + | outputRate | str | 接口吐数据量速率 | 无 | + | crc | str | CRC值 | 无 | + | mtu | str | MTU值 | 1500 | + | ip | str | 接口配置的IP地址 | 192.168.1.1 | + + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showInterface() + >>> {"status":True,"content":[{...},{...}],"errLog":""} + + +--- + +* showRun + + 查看设备整体的配置信息。 + + + * 调用参数 + + 无。 + + * 返回参数 + + | 字段 | 类型 | 描述 | 样例 | + | --- | --- | --- | --- | + | status | bool | 调用该接口是否成功 | False | + | content | list | 调用该接口所产生的正确内容输出,但可能为空,这取决于所执行命令的结果 | Version...SoftWare...| + | errLog | str | 调用该接口所产生的错误内容或Forward的错误提示信息 | 命令执行失败 | + + * 案例 + + ``` Python + >>> instance=...... + >>> instance.login() + >>> instance.showRun() + >>> {"status":True,"content":"Version...SoftWare...","errLog":""} From 33fb89c818775053d6a2eba4c32fb8efceb3e71d Mon Sep 17 00:00:00 2001 From: linzhigeng Date: Thu, 12 Mar 2020 17:22:34 +0800 Subject: [PATCH 5/5] add unittests , update version to 3.3.3 --- lib/forward/release.py | 2 +- unittests/testBaer7850.py | 69 +++++++++++++++++++++++++++++++++++++++ unittests/testBaseH3C.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testCe16808.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testCe16816.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testCe6881.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testFg3800y.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testM9008.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testM9012.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testNe40ex8.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testS12508.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testS12516.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testS5700.py | 65 ++++++++++++++++++++++++++++++++++++ unittests/testS6900.py | 65 ++++++++++++++++++++++++++++++++++++ 14 files changed, 850 insertions(+), 1 deletion(-) create mode 100644 unittests/testBaer7850.py create mode 100644 unittests/testBaseH3C.py create mode 100644 unittests/testCe16808.py create mode 100644 unittests/testCe16816.py create mode 100644 unittests/testCe6881.py create mode 100644 unittests/testFg3800y.py create mode 100644 unittests/testM9008.py create mode 100644 unittests/testM9012.py create mode 100644 unittests/testNe40ex8.py create mode 100644 unittests/testS12508.py create mode 100644 unittests/testS12516.py create mode 100644 unittests/testS5700.py create mode 100644 unittests/testS6900.py diff --git a/lib/forward/release.py b/lib/forward/release.py index 6f5be8e..f7cd94a 100755 --- a/lib/forward/release.py +++ b/lib/forward/release.py @@ -14,5 +14,5 @@ # along with this program. If not, see . -__version__ = '3.3.0' +__version__ = '3.3.3' __author__ = 'Wang Zhe, Zhang Qi Chuan, Lin Zhigeng' diff --git a/unittests/testBaer7850.py b/unittests/testBaer7850.py new file mode 100644 index 0000000..4536574 --- /dev/null +++ b/unittests/testBaer7850.py @@ -0,0 +1,69 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseBaer import BASEBAER + + +class deviceClassBaer7850(unittest.TestCase): + def setUp(self): + self.deviceClassName = "baer7850" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer", + "showRun", + "showInterfacePower", + "showSyslog", + "showHostname"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEBAER) diff --git a/unittests/testBaseH3C.py b/unittests/testBaseH3C.py new file mode 100644 index 0000000..6170f60 --- /dev/null +++ b/unittests/testBaseH3C.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseSSHV2 import BASESSHV2 + + +class deviceClassBaseHuawei(unittest.TestCase): + def setUp(self): + self.deviceClassName = "baseH3C" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASESSHV2) diff --git a/unittests/testCe16808.py b/unittests/testCe16808.py new file mode 100644 index 0000000..7fe7119 --- /dev/null +++ b/unittests/testCe16808.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseHuawei import BASEHUAWEI + + +class deviceClassCe16808(unittest.TestCase): + def setUp(self): + self.deviceClassName = "ce16808" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEHUAWEI) diff --git a/unittests/testCe16816.py b/unittests/testCe16816.py new file mode 100644 index 0000000..c64a9e4 --- /dev/null +++ b/unittests/testCe16816.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseHuawei import BASEHUAWEI + + +class deviceClassCe16816(unittest.TestCase): + def setUp(self): + self.deviceClassName = "ce16816" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEHUAWEI) diff --git a/unittests/testCe6881.py b/unittests/testCe6881.py new file mode 100644 index 0000000..9cf980a --- /dev/null +++ b/unittests/testCe6881.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseHuawei import BASEHUAWEI + + +class deviceClassCe6881(unittest.TestCase): + def setUp(self): + self.deviceClassName = "ce6881" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEHUAWEI) diff --git a/unittests/testFg3800y.py b/unittests/testFg3800y.py new file mode 100644 index 0000000..91d974b --- /dev/null +++ b/unittests/testFg3800y.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseFortinet import BASEFORTINET + + +class deviceClassFg3800(unittest.TestCase): + def setUp(self): + self.deviceClassName = "fg3800" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEFORTINET) diff --git a/unittests/testM9008.py b/unittests/testM9008.py new file mode 100644 index 0000000..b634347 --- /dev/null +++ b/unittests/testM9008.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseH3C import BASEH3C + + +class deviceClassM9008(unittest.TestCase): + def setUp(self): + self.deviceClassName = "m9008" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEH3C) diff --git a/unittests/testM9012.py b/unittests/testM9012.py new file mode 100644 index 0000000..3719b21 --- /dev/null +++ b/unittests/testM9012.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseH3C import BASEH3C + + +class deviceClassM9012(unittest.TestCase): + def setUp(self): + self.deviceClassName = "m9012" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEH3C) diff --git a/unittests/testNe40ex8.py b/unittests/testNe40ex8.py new file mode 100644 index 0000000..290ec55 --- /dev/null +++ b/unittests/testNe40ex8.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseHuawei import BASEHUAWEI + + +class deviceClassNe40ex8(unittest.TestCase): + def setUp(self): + self.deviceClassName = "ne40ex8" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEHUAWEI) diff --git a/unittests/testS12508.py b/unittests/testS12508.py new file mode 100644 index 0000000..cbf3b94 --- /dev/null +++ b/unittests/testS12508.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseH3C import BASEH3C + + +class deviceClassS12508(unittest.TestCase): + def setUp(self): + self.deviceClassName = "s12508" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEH3C) diff --git a/unittests/testS12516.py b/unittests/testS12516.py new file mode 100644 index 0000000..fc42f45 --- /dev/null +++ b/unittests/testS12516.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseH3C import BASEH3C + + +class deviceClassS12516(unittest.TestCase): + def setUp(self): + self.deviceClassName = "s12516" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEH3C) diff --git a/unittests/testS5700.py b/unittests/testS5700.py new file mode 100644 index 0000000..843f4c8 --- /dev/null +++ b/unittests/testS5700.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseFenghuo import BASEFENGHUO + + +class deviceClassS5700(unittest.TestCase): + def setUp(self): + self.deviceClassName = "s5700" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASESSHV2 + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEFENGHUO) diff --git a/unittests/testS6900.py b/unittests/testS6900.py new file mode 100644 index 0000000..a79ea0d --- /dev/null +++ b/unittests/testS6900.py @@ -0,0 +1,65 @@ +# (c) 2015-2018, Wang Zhe , Zhang Qi Chuan +# +# This file is part of Ansible +# +# Forward is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Forward is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import unittest +import importlib +from forward.utils.forwardError import ForwardError +from forward.devclass.baseH3C import BASEH3C + + +class deviceClassS6900(unittest.TestCase): + def setUp(self): + self.deviceClassName = "s6900" + self.initParameters = ["ip", + "username", + "password", + "port", + "timeout", + "privilegePw", + "isLogin", + "isEnable", + "channel", + "shell", + "basePrompt", + "prompt", + "moreFlag"] + self.baseClassMethod = ["login", + "logout", + "execute", + "getMore", + "getPrompt", + "cleanBuffer"] + + def test_class_parameters(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for parameter in self.initParameters: + if not hasattr(_dev(1,2,3), parameter): + raise IOError('%s not have parameter:' % (self.deviceClassName), parameter) + + def test_base_class_method(self): + _dev = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + for method in self.baseClassMethod: + if not hasattr(_dev(1,2,3), method): + raise IOError('%s not have parameter:' % (self.deviceClassName), method) + + def test_inherit_check(self): + # Inherit from BASETELNET + cls = getattr(importlib.import_module('forward.devclass.{dev}'.format(dev=self.deviceClassName)), + self.deviceClassName.upper()) + self.assertEquals(cls.__bases__[0], BASEH3C)