Skip to content
 
 

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Comware7 Ansible Library

Python library for integrating Ansible with the Comware7 embedded system, enabling automation of inventory and device orchestration.

Installation

Create a new virtual environment

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Install the package

pip install pycw7-ansible

Usage

Open Connection

To open a connection, you need to create a dictionary with the device parameters and pass it to the COM7 class, then call the open method, as shown below:

>>> from pycw7_ansible.comware import COM7
>>> HOST_IP = "10.100.73.119"
>>> USERNAME = "ped"
>>> PASSWORD = "Admin@1234"
>>> PORT = 830
>>> args = dict(host=HOST_IP, username=USERNAME, password=PASSWORD, port=PORT)
>>> device = COM7(**args)
>>> device.open()
<ncclient.manager.Manager object at 0x7c5536f51d60>

Running Command Example

To get run a command, you need to call the cli_display or cli_config method, as shown below:

>>> command = device.cli_config("vlan 1 \n name VLAN 0001 \n description VLAN-1-MANAGEMENT")
>>> print(command)
{'vlanid': '1', 'name': 'VLAN 0001', 'descr': 'VLAN-1-MANAGEMENT'}

>>> command = device.cli_display("display vlan 1")
>>> print(command)
{'vlanid': '1', 'name': 'VLAN 0001', 'descr': 'VLAN-1-MANAGEMENT'}

Getting Example Configuration

To get the configuration of a feature, you need to create an instance of the feature class and call the get_config method, as shown below:

>>> from pycw7_ansible.features.vlan import Vlan
>>> vlan1 = Vlan(device, "1")
>>> config = vlan1.get_config()
>>> print(config)
{'vlanid': '1', 'name': 'VLAN 0001', 'descr': 'VLAN-1-MANAGEMENT'}

About

Python library for integrating Ansible with the Comware7 embedded system, enabling automation of inventory and device orchestration.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages