cannon-0.0.9
0.0.9
0.0.80
0.0.8
0.0.79
0.0.78
0.0.77
0.0.76
0.0.75
0.0.74
0.0.73
0.0.72
0.0.71
0.0.70
0.0.7
0.0.69
0.0.68
0.0.67
0.0.66
0.0.65
0.0.64
0.0.63
0.0.60
0.0.59
0.0.58
0.0.57
0.0.56
0.0.55
0.0.54
0.0.53
0.0.52
0.0.51
0.0.50
0.0.49
0.0.48
0.0.47
0.0.46
0.0.45
0.0.44
0.0.43
0.0.42
0.0.41
0.0.40
0.0.39
0.0.38
0.0.37
0.0.36
0.0.35
0.0.34
0.0.33
0.0.31
0.0.30
0.0.3
0.0.29
0.0.28
0.0.27
0.0.25
0.0.24
0.0.23
0.0.22
0.0.21
0.0.20
0.0.2
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.1
0.0.9
0.0.80
0.0.8
0.0.79
0.0.78
0.0.77
0.0.76
0.0.75
0.0.74
0.0.73
0.0.72
0.0.71
0.0.70
0.0.7
0.0.69
0.0.68
0.0.67
0.0.66
0.0.65
0.0.64
0.0.63
0.0.60
0.0.59
0.0.58
0.0.57
0.0.56
0.0.55
0.0.54
0.0.53
0.0.52
0.0.51
0.0.50
0.0.49
0.0.48
0.0.47
0.0.46
0.0.45
0.0.44
0.0.43
0.0.42
0.0.41
0.0.40
0.0.39
0.0.38
0.0.37
0.0.36
0.0.35
0.0.34
0.0.33
0.0.31
0.0.30
0.0.3
0.0.29
0.0.28
0.0.27
0.0.25
0.0.24
0.0.23
0.0.22
0.0.21
0.0.20
0.0.2
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.1
توضیحات
An SSH automation tool based on Exscript
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | cannon-0.0.9 |
| نام | cannon |
| نسخه کتابخانه | 0.0.9 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Mike Pennington |
| ایمیل نویسنده | mike@pennington.net |
| آدرس صفحه اصلی | https://github.com/mpenning/cannon |
| آدرس اینترنتی | https://pypi.org/project/cannon/ |
| مجوز | BSD-3-Clause |
# Introduction
[cannon][1] is a wrapper around [exscript][2] to connect with remote server or network
devices with ssh.
## Example Usage - Cisco IOS
This script will login, run a few show commands. If you want an interactive session, set `interact=True` when calling Shell()
```python
import sys
from cannon import Shell, Account
from loguru import logger
log_stderr_id = logger.add(sink=sys.stderr)
@logger.catch(default=True, onerror=lambda _: sys.exit(1))
def main():
sess = Shell(
host='route-views.routeviews.org',
# route-views doesn't need password
account= Account(name='rviews', password=''),
debug=0,
json_logfile='/tmp/cmd_log.json',
)
sess.execute('term len 0')
sess.execute('show clock')
sess.execute('show version')
version_text = sess.response
# template is a TextFSM template
values = sess.execute('show ip int brief',
template="""Value INTF (\S+)\nValue IPADDR (\S+)\nValue STATUS (up|down|administratively down)\nValue PROTO (up|down)\n\nStart\n ^${INTF}\s+${IPADDR}\s+\w+\s+\w+\s+${STATUS}\s+${PROTO} -> Record""")
print("VALUES "+str(values))
sess.close()
```
## Example Usage - Linux
```python
from getpass import getpass
import sys
from cannon.main import Shell, Account
log_stderr_id = logger.add(sink=sys.stderr)
@logger.catch(default=True, onerror=lambda _: sys.exit(1))
def main():
account = Account("mpenning", getpass("Login password: "))
conn = Shell(host="127.0.0.1", port=22, account=account, driver="generic", debug=0)
assert conn is not None
example_tfsm_template = """Value UNAME_LINE (.+)
Start
^${UNAME_LINE}
"""
print(conn.execute("sudo uname -a", debug=0, template=example_tfsm_template, timeout=2))
print(conn.execute("whoami", debug=0, template=None, timeout=2))
#print("FOO2", conn.response)
conn.close(force=True)
if __name__=="__main__":
main()
```
## Example test suite setup
- `git clone git@github.com:knipknap/Exscript`
- `cd` into `Exscript/tests/Exscript/protocols` and `chmod 600 id_rsa`
- exscript spawns a local tests ssh daemon, `pytest Exscript/tests/Exscript/protocols/SSH2Test.py`
- Connect with `ssh -i id_rsa -p 1236 user@localhost`
- one command is supported: `ls`
[1]: https://pypi.python.org/pypi/cannon # cannon on pypi
[2]: https://pypi.python.org/pypi/exscript # Exscript on pypi
نیازمندی
| مقدار | نام |
|---|---|
| ==2.6.3 | exscript |
| ==0.5.3 | loguru |
| ==6.3.2 | traits |
| ==1.1.2 | textfsm |
| ==1.2.1 | arrow |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl cannon-0.0.9:
pip install cannon-0.0.9.whl
نصب پکیج tar.gz cannon-0.0.9:
pip install cannon-0.0.9.tar.gz