From eae47d81ffd8c2c520d77de8b833f9fa43ff14d3 Mon Sep 17 00:00:00 2001 From: xdai555 Date: Fri, 18 Feb 2022 22:57:54 +0800 Subject: [PATCH] feat: add README_CN.md --- README.md | 42 +++++++++++++-- README_CN.md | 97 ++++++++++++++++++++++++++++++++++ napalm_h3c_comware/__init__.py | 2 +- 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 README_CN.md diff --git a/README.md b/README.md index ddd18cc..db19b3f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # napalm-h3c-cw7-ssh +[English](README.md) | [中文](README_CN.md) + This repository is published in https://github.com/napalm-automation-community/napalm-h3c-cw7-ssh ## NAPALM @@ -16,22 +18,26 @@ NAPALM driver for H3C Comware V7 network devices, over ssh. S5100、S5500、S6800、S12500 Series Data Center Switches. +Some methods may work on Routers. + +Looking forward to your testing and feedback :). + # Supported functions - :white_check_mark: is_alive() - :white_check_mark: get_facts() - :white_check_mark: get_interfaces() -- :white_check_mark: get_lldp_neighbors() -- :white_check_mark: get_environment() +- :white_check_mark: get_interfaces_ip() - :white_check_mark: get_interfaces_counters() +- :white_check_mark: get_lldp_neighbors() - :white_check_mark: get_lldp_neighbors_detail() +- :white_check_mark: get_environment() - :white_check_mark: cli() - :white_check_mark: get_arp_table() - :white_check_mark: get_mac_address_move_table() - :white_check_mark: get_mac_address_table() - :white_check_mark: get_vlans() - :white_check_mark: get_config() -- :white_check_mark: get_interfaces() - :white_check_mark: get_irf_config() - :white_check_mark: is_irf() @@ -52,6 +58,8 @@ pip install napalm-h3c-comware -U ## Use +You can use this driver like this: + ```python from napalm import get_network_driver @@ -60,4 +68,32 @@ driver = driver("192.168.56.20", "netdevops", "NetDevops@01",) driver.open() ret = driver.is_alive() print(ret) +``` + +If you want to custom some connection parameter, example: the port connected to the device, you should use `optional_args`, it is exactly the same as `netmiko.BaseConnection.__init__`: + +```python +from napalm import get_network_driver + +driver = get_network_driver("h3c_comware") +conn_args = { + "port": 2222 +} +driver = driver("192.168.56.21", "netdevops", "NetDevops@01",optional_args=conn_args) +driver.open() +ret = driver.is_alive() +print(ret) +``` + +Sometimes you want to execute raw command via netmiko, you can use `send_command`, it is exactly the same as `netmiko.send_command`: + +```python +from napalm import get_network_driver + +driver = get_network_driver("h3c_comware") +driver = driver("192.168.56.20", "netdevops", "NetDevops@01",) +driver.open() +# you can use any options that supported by netmiko.send_command +ret = driver.send_command("display clock", use_textfsm=True) +print(ret) ``` \ No newline at end of file diff --git a/README_CN.md b/README_CN.md new file mode 100644 index 0000000..9d21d25 --- /dev/null +++ b/README_CN.md @@ -0,0 +1,97 @@ +# napalm-h3c-cw7-ssh + +[English](README.md) | [中文](README_CN.md) + +本仓库同步发布在 https://github.com/napalm-automation-community/napalm-h3c-cw7-ssh + +## NAPALM + +[NAPALM](https://github.com/napalm-automation/napalm) (Network Automation and Programmability Abstraction Layer with Multivendor support) 是一个实现了使用统一的 API 来与多厂商网络设备交换的 Python 库。它支持使用多种方法来连接到设备、操作设备、读取数据等。 + + +## napalm-h3c-cw7-ssh + +`napalm-h3c-cw7-ssh` 是一个基于 SSH 的 H3C Comware V7 的网络设备驱动,是 Netmiko 的高级封装。 + +# 支持的设备 + +本驱动支持 S5100、S5500、S6800、S12500 等系列的数据中心交换机,一些功能也适用于路由器设备。 + +一般来说,只要是 V7 的设备都支持,期待你的测试和反馈 :)。 + + +# 支持的功能 + +- :white_check_mark: is_alive():检查当前是否与设备连接 +- :white_check_mark: get_facts():获取设备基础信息,如型号、软件版本、序列号等 +- :white_check_mark: get_interfaces():获取所有接口列表 +- :white_check_mark: get_interfaces_ip():获取当前存在 IP 地址的接口列表,目前只支持 IPv4 +- :white_check_mark: get_interfaces_counters():获取接口的计数信息,包括收发包、收发字节、错包、丢包、CRC 等 +- :white_check_mark: get_lldp_neighbors():获取 LLDP 邻居信息 +- :white_check_mark: get_lldp_neighbors_detail():获取 LLDP 的详细信息,包括对端的系统名称及描述、接口名称及描述等 +- :white_check_mark: get_environment():获取设备运行信息,包括 CPU、内存、电源、风扇、温度等状态 +- :white_check_mark: cli():在设备上执行命令 +- :white_check_mark: get_arp_table():获取 ARP 表 +- :white_check_mark: get_mac_address_move_table():获取 MAC 地址漂移表 +- :white_check_mark: get_mac_address_table():获取 MAC 地址表 +- :white_check_mark: get_vlans():获取 VLAN 信息,包括 VLAN 及其成员接口 +- :white_check_mark: get_config():获取设备配置,包括运行时配置和启动配置 +- :white_check_mark: get_irf_config():获取 IRF 配置信息 +- :white_check_mark: is_irf():判断是否为 IRF 设备 + + +# 快速开始 + +## 安装 + +```shell +pip install napalm-h3c-comware +``` + +## 升级 + +```shell +pip install napalm-h3c-comware -U +``` + +## 使用 + +简单使用: + +```python +from napalm import get_network_driver + +driver = get_network_driver("h3c_comware") +driver = driver("192.168.56.20", "netdevops", "NetDevops@01",) +driver.open() +ret = driver.is_alive() +print(ret) +``` + +如果需要自定义连接参数,例如连接到设备的 SSH 端口, 请使用 `optional_args` 参数,它支持 netmiko 初始化时的所有参数: + +```python +from napalm import get_network_driver + +driver = get_network_driver("h3c_comware") +conn_args = { + "port": 2222 +} +driver = driver("192.168.56.21", "netdevops", "NetDevops@01",optional_args=conn_args) +driver.open() +ret = driver.is_alive() +print(ret) +``` + +如果需要通过原生的 netmiko 来执行命令,可以使用 `send_command`, 它和 `netmiko.send_command` 完全一样,支持所有参数: + +```python +from napalm import get_network_driver + +driver = get_network_driver("h3c_comware") +driver = driver("192.168.56.20", "netdevops", "NetDevops@01",) +driver.open() +# you can use any options that supported by netmiko.send_command +ret = driver.send_command("display clock", use_textfsm=True) +print(ret) +``` \ No newline at end of file diff --git a/napalm_h3c_comware/__init__.py b/napalm_h3c_comware/__init__.py index f941be0..d667d00 100644 --- a/napalm_h3c_comware/__init__.py +++ b/napalm_h3c_comware/__init__.py @@ -15,4 +15,4 @@ from napalm_h3c_comware.comware import ComwareDriver __all__ = ("ComwareDriver",) -__version__ = "0.1.2" \ No newline at end of file +__version__ = "0.1.4" \ No newline at end of file