Name | netmiko-bridge JSON |
Version |
0.1.1
JSON |
| download |
home_page | |
Summary | A decorator for Netmiko vendor driver extension. |
upload_time | 2023-03-22 09:37:25 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | MIT License |
keywords |
netmiko
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Netmiko Bridge
English | [简体中文](./README.zh-hans.md)
This is a decorator for [Netmiko](https://github.com/ktbyers/netmiko) vendor driver extension.
You can use this module to add yourself vendor driver without modify [Netmiko](https://github.com/ktbyers/netmiko) source code.
## How to build
First you must install __wheel__ or __build__ with `pip`.
This example is use __build__.
### use build
```bash
pip install --upgrade build
```
Then you can build this module.
```bash
python -m build
```
## How to install
### Install via Directory
You can install __netmiko_bridge__ direct with directory.
```bash
pip install --upgrade {netmiko_bridge_path}
```
### Install via Binary
After build this module, you can install it to your system.
```bash
pip install -f {netmiko_bridge_path}/dist/ --upgrade netmiko_bridge
```
### Install via PyPi
```bash
pip install netmiko-bridge
```
## How to use
### 1. Netmiko source code modify
To use this module, you must do some minimal modify in [Netmiko](https://github.com/ktbyers/netmiko).
In file [`netmiko/ssh_dispatcher.py`](https://github.com/ktbyers/netmiko/blob/develop/netmiko/ssh_dispatcher.py),
please add this code before `def ConnectHandler(*args: Any, **kwargs: Any) -> "BaseConnection":`, like
```python
import netmiko_bridge
@netmiko_bridge.connect_handler_bridge(platforms, vendor_module = "your_custom_driver_module_package", vendor_getter_attr = "your_custom_vendor_getter_attr_name")
def ConnectHandler(*args: Any, **kwargs: Any) -> "BaseConnection":
"""......"""
```
You can also use the default value on the `ConnectHandler` decorator
```python
import netmiko_bridge
@netmiko_bridge.connect_handler_bridge(platforms)
def ConnectHandler(*args: Any, **kwargs: Any) -> "BaseConnection":
"""......"""
```
This the bash script help you to modify the source code, and it can match more netmiko version.
```bash
_python_lib_path=/usr/lib64/python3.6/site-packages
_netmiko_fix_file=${_python_lib_path}/netmiko/ssh_dispatcher.py
if [ -f "${_netmiko_fix_file}" ]; then
_netmiko_fixed=$(grep -c "@netmiko_bridge.connect_handler_bridge" ${_netmiko_fix_file})
if [ "${_netmiko_fixed}" -eq "0" ]; then
sed -i "s/def ConnectHandler/import netmiko_bridge\n@netmiko_bridge.connect_handler_bridge(platforms)\ndef ConnectHandler/" ${_netmiko_fix_file}
fi
fi
```
### 2. VendorGetter Instance
Then you can build yourself vendor driver module like this
```python
from netmiko_bridge.vendor_getter import VendorGetter
from netmiko.cisco_base_connection import CiscoBaseConnection
class Custom(CiscoBaseConnection):
"""Your Custom Vendor Support"""
def __init__(self):
pass
vendor_getter = VendorGetter()
# you can add the mapper use the
vendor_getter.add_vendor({
"custom_device": Custom
})
```
To build vendor module, you can reference module [`netmiko_bridge_vendor`](https://github.com/ousui/netmiko_bridge_vendor).
### 3. Use netmiko
Now you can use [Netmiko](https://github.com/ktbyers/netmiko) with yourself vendor device driver.
```python
from netmiko.ssh_dispatcher import ConnectHandler
conn = ConnectHandler(device_type='custom_device')
```
Raw data
{
"_id": null,
"home_page": "",
"name": "netmiko-bridge",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "netmiko",
"author": "",
"author_email": "\"shuai w.\" <x@ousui.org>",
"download_url": "https://files.pythonhosted.org/packages/3e/2b/734be4797cf77ea82fcb0f4d3280f9dc055012cd21668c41dba45bf405c1/netmiko_bridge-0.1.1.tar.gz",
"platform": null,
"description": "# Netmiko Bridge\r\n\r\nEnglish | [\u7b80\u4f53\u4e2d\u6587](./README.zh-hans.md)\r\n\r\nThis is a decorator for [Netmiko](https://github.com/ktbyers/netmiko) vendor driver extension.\r\n\r\nYou can use this module to add yourself vendor driver without modify [Netmiko](https://github.com/ktbyers/netmiko) source code.\r\n\r\n## How to build\r\n\r\nFirst you must install __wheel__ or __build__ with `pip`.\r\n\r\nThis example is use __build__.\r\n\r\n### use build\r\n\r\n```bash\r\npip install --upgrade build\r\n```\r\n\r\nThen you can build this module.\r\n```bash\r\npython -m build\r\n```\r\n\r\n## How to install\r\n\r\n### Install via Directory\r\n\r\nYou can install __netmiko_bridge__ direct with directory.\r\n```bash\r\npip install --upgrade {netmiko_bridge_path}\r\n```\r\n\r\n### Install via Binary\r\n\r\nAfter build this module, you can install it to your system.\r\n```bash\r\npip install -f {netmiko_bridge_path}/dist/ --upgrade netmiko_bridge\r\n```\r\n\r\n### Install via PyPi\r\n\r\n```bash\r\npip install netmiko-bridge\r\n```\r\n\r\n## How to use\r\n\r\n### 1. Netmiko source code modify\r\n\r\nTo use this module, you must do some minimal modify in [Netmiko](https://github.com/ktbyers/netmiko).\r\n\r\nIn file [`netmiko/ssh_dispatcher.py`](https://github.com/ktbyers/netmiko/blob/develop/netmiko/ssh_dispatcher.py), \r\nplease add this code before `def ConnectHandler(*args: Any, **kwargs: Any) -> \"BaseConnection\":`, like\r\n```python\r\nimport netmiko_bridge\r\n@netmiko_bridge.connect_handler_bridge(platforms, vendor_module = \"your_custom_driver_module_package\", vendor_getter_attr = \"your_custom_vendor_getter_attr_name\")\r\ndef ConnectHandler(*args: Any, **kwargs: Any) -> \"BaseConnection\":\r\n \"\"\"......\"\"\"\r\n```\r\n\r\nYou can also use the default value on the `ConnectHandler` decorator\r\n```python\r\nimport netmiko_bridge\r\n@netmiko_bridge.connect_handler_bridge(platforms)\r\ndef ConnectHandler(*args: Any, **kwargs: Any) -> \"BaseConnection\":\r\n \"\"\"......\"\"\"\r\n```\r\n\r\nThis the bash script help you to modify the source code, and it can match more netmiko version.\r\n```bash\r\n_python_lib_path=/usr/lib64/python3.6/site-packages\r\n_netmiko_fix_file=${_python_lib_path}/netmiko/ssh_dispatcher.py\r\nif [ -f \"${_netmiko_fix_file}\" ]; then\r\n _netmiko_fixed=$(grep -c \"@netmiko_bridge.connect_handler_bridge\" ${_netmiko_fix_file})\r\n if [ \"${_netmiko_fixed}\" -eq \"0\" ]; then\r\n sed -i \"s/def ConnectHandler/import netmiko_bridge\\n@netmiko_bridge.connect_handler_bridge(platforms)\\ndef ConnectHandler/\" ${_netmiko_fix_file}\r\n fi\r\nfi\r\n```\r\n\r\n### 2. VendorGetter Instance \r\n\r\nThen you can build yourself vendor driver module like this\r\n```python\r\nfrom netmiko_bridge.vendor_getter import VendorGetter\r\nfrom netmiko.cisco_base_connection import CiscoBaseConnection\r\n\r\n\r\nclass Custom(CiscoBaseConnection):\r\n \"\"\"Your Custom Vendor Support\"\"\"\r\n\r\n def __init__(self):\r\n pass\r\n\r\n\r\nvendor_getter = VendorGetter()\r\n# you can add the mapper use the\r\nvendor_getter.add_vendor({\r\n \"custom_device\": Custom\r\n})\r\n```\r\n\r\nTo build vendor module, you can reference module [`netmiko_bridge_vendor`](https://github.com/ousui/netmiko_bridge_vendor). \r\n\r\n### 3. Use netmiko\r\n\r\nNow you can use [Netmiko](https://github.com/ktbyers/netmiko) with yourself vendor device driver.\r\n```python\r\nfrom netmiko.ssh_dispatcher import ConnectHandler\r\n\r\nconn = ConnectHandler(device_type='custom_device')\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A decorator for Netmiko vendor driver extension.",
"version": "0.1.1",
"split_keywords": [
"netmiko"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dec01c20940143b6cbde3f137fcbe175a95e262113f9a3b8b7d44e26cc8f37ef",
"md5": "35df746e1ae8ba64641b9994e5826a30",
"sha256": "bad16bde30382dbd58cc0cd41f99cee948c37219d2b3015271277d6be23754de"
},
"downloads": -1,
"filename": "netmiko_bridge-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "35df746e1ae8ba64641b9994e5826a30",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4667,
"upload_time": "2023-03-22T09:37:23",
"upload_time_iso_8601": "2023-03-22T09:37:23.139553Z",
"url": "https://files.pythonhosted.org/packages/de/c0/1c20940143b6cbde3f137fcbe175a95e262113f9a3b8b7d44e26cc8f37ef/netmiko_bridge-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e2b734be4797cf77ea82fcb0f4d3280f9dc055012cd21668c41dba45bf405c1",
"md5": "16ba744e3dee9c359074308653ebaaff",
"sha256": "6e6ddc9e38ca098e5fdf884d59ff48a29bef4e70ac4d83922833f1b9e5564ef4"
},
"downloads": -1,
"filename": "netmiko_bridge-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "16ba744e3dee9c359074308653ebaaff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5187,
"upload_time": "2023-03-22T09:37:25",
"upload_time_iso_8601": "2023-03-22T09:37:25.448105Z",
"url": "https://files.pythonhosted.org/packages/3e/2b/734be4797cf77ea82fcb0f4d3280f9dc055012cd21668c41dba45bf405c1/netmiko_bridge-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-22 09:37:25",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "netmiko-bridge"
}