Connpy is a SSH/Telnet connection manager and automation module
Project description
Conn
Connpy is a ssh and telnet connection manager and automation module
Installation
pip install connpy
Automation module usage
Standalone module
import connpy
router = connpy.node("unique name","ip/hostname", user="username", password="password")
router.run(["term len 0","show run"])
print(router.output)
hasip = router.test("show ip int brief","1.1.1.1")
if hasip:
print("Router has ip 1.1.1.1")
else:
print("router does not have ip 1.1.1.1")
Using manager configuration
import connpy
conf = connpy.configfile()
device = conf.getitem("router@office")
router = connpy.node("unique name", **device, config=conf)
result = router.run("show ip int brief")
print(result)
Running parallel tasks on multiple devices
import connpy
conf = connpy.configfile()
#You can get the nodes from the config from a folder and fitlering in it
nodes = conf.getitem("@office", ["router1", "router2", "router3"])
#You can also get each node individually:
nodes = {}
nodes["router1"] = conf.getitem("router1@office")
nodes["router2"] = conf.getitem("router2@office")
nodes["router10"] = conf.getitem("router10@datacenter")
#Also, you can create the nodes manually:
nodes = {}
nodes["router1"] = {"host": "1.1.1.1", "user": "username", "password": "password1"}
nodes["router2"] = {"host": "1.1.1.2", "user": "username", "password": "password2"}
nodes["router3"] = {"host": "1.1.1.2", "user": "username", "password": "password3"}
#Finally you run some tasks on the nodes
mynodes = connpy.nodes(nodes, config = conf)
result = mynodes.test(["show ip int br"], "1.1.1.2")
for i in result:
print("---" + i + "---")
print(result[i])
print()
# Or for one specific node
mynodes.router1.run(["term len 0". "show run"], folder = "/home/user/logs")
Connection manager usage
usage: conn [-h] [--add | --del | --mod | --show | --debug] [node|folder]
conn {profile,move,mv,copy,cp,list,ls,bulk,config} ...
positional arguments:
node|folder node[@subfolder][@folder]
Connect to specific node or show all matching nodes
[@subfolder][@folder]
Show all available connections globaly or in specified path
Options:
-h, --help show this help message and exit
-a, --add Add new node[@subfolder][@folder] or [@subfolder]@folder
-r, --del, --rm Delete node[@subfolder][@folder] or [@subfolder]@folder
-e, --mod, --edit Modify node[@subfolder][@folder]
-s, --show Show node[@subfolder][@folder]
-d, --debug Display all conections steps
Commands:
profile Manage profiles
move (mv) Move node
copy (cp) Copy node
list (ls) List profiles, nodes or folders
bulk Add nodes in bulk
config Manage app config
Manage profiles:
usage: conn profile [-h] (--add | --del | --mod | --show) profile
positional arguments:
profile Name of profile to manage
options:
-h, --help show this help message and exit
-a, --add Add new profile
-r, --del, --rm Delete profile
-e, --mod, --edit Modify profile
-s, --show Show profile
Examples:
conn profile --add office-user
conn --add @office
conn --add @datacenter@office
conn --add server@datacenter@office
conn --add pc@office
conn --show server@datacenter@office
conn pc@office
conn server
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
connpy-2.0.3.tar.gz
(19.1 kB
view details)
Built Distributions
connpy-2.0.3-py3-none-any.whl
(20.1 kB
view details)
connpy-2.0.3-2-py3-none-any.whl
(20.3 kB
view details)
File details
Details for the file connpy-2.0.3.tar.gz
.
File metadata
- Download URL: connpy-2.0.3.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8b640e41928638e6bcb77d47393c3ef610ff533af3e6870e29fb0021e9bfc9c |
|
MD5 | a7fe2962bebfe4fa2bc5f0208199efca |
|
BLAKE2b-256 | be221117efe6381fb9b0f427bdb2bf1c231760e68ded61839a713963a815942e |
File details
Details for the file connpy-2.0.3-py3-none-any.whl
.
File metadata
- Download URL: connpy-2.0.3-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5db335dc525b2e8189b17df9440fed3e8d56650751fc6045ff083cd8c58f1227 |
|
MD5 | 75556962863e2b7fe0bea44addd4c107 |
|
BLAKE2b-256 | c671212de225dd11daab8288ae4cc0ae3ddebc90e942a7541104e2178dfd62dc |
File details
Details for the file connpy-2.0.3-2-py3-none-any.whl
.
File metadata
- Download URL: connpy-2.0.3-2-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df7c82615c5ef9d08aee7a5f0c4941c802c319a181b20677edc50fc86607c59b |
|
MD5 | 5aa4aed3746c04aa304e4c16ba94bacc |
|
BLAKE2b-256 | f4b9d9377b1c5c56c4decaae0daedf9da7d92698a2f10f7b487cc2d7ff0ef0d7 |