Net Command
Net Command 是一个类似 Ansible 的批量 SSH 操作工具,使用 netmiko 作为核心库。它支持通过 YAML 配置文件管理设备清单和批量配置文件,并支持多进程执行任务。
安装
使用 poetry 安装依赖:
poetry install
使用方法
查看设备清单
使用 --list 参数查看设备清单的字典输出:
netcmd -i inventory.yaml --list
执行 Playbook
指定设备清单和 Playbook 文件来执行任务:
netcmd -i inventory.yaml playbook.yaml
配置文件格式
设备清单 (inventory.yaml)
设备清单文件使用 YAML 格式,示例如下:
all:
vars:
port: 22
user: 'admin'
password: 'password@123456'
vendor: 'hp_comware'
box_as:
hosts:
192.168.56.2:
192.168.56.3:
192.168.56.4:
Playbook (playbook.yaml)
Playbook 文件使用 YAML 格式,示例如下:
- name: H3C NTP Configuration
hosts: box_as
num_processes: 2
vars:
host: "{{ host }}"
port: "{{ port }}"
username: "{{ user }}"
password: "{{ password }}"
tasks:
- name: Check NTP status on H3C devices
when: vendor == 'hp_comware'
commands:
- display ntp status
测试
使用 pytest 运行测试:
pytest
贡献
欢迎提交问题和贡献代码!
许可证
本项目使用 MIT 许可证。
Metadata
Release files for net-command 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| net_command-0.1.0.tar.gz | 3.3 kB | Without provenance | Details for net_command-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| net_command-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for net_command-0.1.0-py3-none-any.whl |
Total release size: 8.3 kB
Release files / net_command-0.1.0.tar.gz
| Download URL | net_command-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59276b685884efa1a84c140677e10f30bf503e1967be50348b765fbedd2c6532
|
|
BLAKE2b-256 checksum How to use checksums |
509c22718a5296b9ac749738714c39ca1e771684d1f335345cbe539df01dde83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.8.18 Linux/6.8.0-1021-azure
|
Release files / net_command-0.1.0-py3-none-any.whl
| Download URL | net_command-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a70d67bcc08906cf541c4f90fe0516e530a7a36940fcd46bc8b22559c0882ec
|
|
BLAKE2b-256 checksum How to use checksums |
20b047756c661c72275529f6ef2f385f0452ead30577f19102e95fd516387fff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.8.18 Linux/6.8.0-1021-azure
|
Security for net-command 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.