Skip to content

Conversation

@tahigash
Copy link
Contributor

@tahigash tahigash commented Dec 6, 2025

Description

This PR provides a comprehensive CML2 (Cisco Modeling Labs 2) plugin for pyATS that enables automatic lab creation, management, and device connectivity from pyATS testbed definitions.

Features

Core Functionality

  • Automatic Lab Creation: Creates CML2 labs from pyATS testbed topology definitions
  • Lab Lifecycle Management: Handles lab startup, convergence waiting, and cleanup
  • Terminal Server Integration: Configures device connections through CML2 console server
  • Testbed Synchronization: Updates pyATS testbed with CML2 connection information

CLI Arguments

Argument Description
--cml2-enable Enable CML2 plugin
--cml2-url CML2 server URL
--cml2-username CML2 authentication username
--cml2-password CML2 authentication password
--cml2-keep-lab Keep lab running after job completion

Platform Support

Automatic platform inference and node definition mapping for:

  • IOS: IOL, IOL L2
  • IOS-XE: CSR1000v, Cat8000v, Cat9000v
  • NX-OS: NX-OSv9000
  • IOS-XR: IOS-XRv9000
  • ASA: ASAv
  • Linux: Ubuntu, Alpine
  • Infrastructure: External Connector, Unmanaged Switch

Default Credentials

Automatic application of CML2 default credentials based on node definition:

  • Credentials are set on both device and connection objects
  • Ensures compatibility with genie.testbed.load()
  • Includes enable password configuration

Link Verification

  • Verifies expected topology links exist in CML2 lab after convergence
  • Raises RuntimeError if expected links are missing
  • Helps catch topology configuration issues early

Topology Summary Display

Displays comprehensive lab topology information before pre_job completion:

  • Device table: name, node definition, state, console port
  • Connection details for each device
  • Link information showing interface connections

Implementation Details

Key Methods

  • CML2LabBuilder.build() - Creates CML2 lab from testbed
  • CML2LabBuilder.verify_links() - Validates lab link topology
  • CML2Plugin.pre_job() - Handles lab creation and startup
  • CML2Plugin.post_job() - Handles lab cleanup
  • CML2Plugin._update_testbed_in_place() - Updates testbed with CML2 info
  • CML2Plugin._display_topology_summary() - Shows topology summary

Helper Functions

  • infer_platform() - Infers CML2 platform from device attributes
  • get_node_definition() - Maps platform to CML2 node definition

Files Changed

  • src/pyats/contrib/plugins/cml2_plugin/cml2.py

Testing

  • Tested with pyATS jobs using CML2 lab with multiple device types
  • Verified device connections using CML2 default credentials
  • Verified link verification catches missing links
  • Verified topology summary displays correctly
  • Tested lab cleanup and keep-lab functionality

Usage Example

pyats run job my_job.py \
  --testbed-file testbed.yaml \
  --cml2-enable \
  --cml2-url https://cml2-server/ \
  --cml2-username admin \
  --cml2-password 'password' \
  --cml2-keep-lab

- Add new plugin: cml2_plugin
- Creates CML2 lab topology from pyATS testbed definition
- Starts lab and waits for convergence
- Merges original testbed with CML2-generated testbed (preserves alias, credentials, etc.)
- Cleans up lab after job completion (optional --cml2-keep-lab)
- Add virl2_client to install_requires
@tahigash tahigash requested a review from a team as a code owner December 6, 2025 15:04
- Always infer platform for credential lookup (existing platform may be generic)
- Set credentials on both device and connection objects
- Update nxosv9000 default password to 'cisco'
- Add link verification after lab convergence
- Add topology summary table display before pre_job completion
- Fix node.state() callable check in topology summary
@tahigash tahigash changed the title Add CML2 Dynamic Topology Plugin CML2 Plugin: Link verification, topology summary, and credential fixes Dec 7, 2025
@tahigash tahigash changed the title CML2 Plugin: Link verification, topology summary, and credential fixes CML2 Plugin: Enhanced pyATS integration with CML2 (Cisco Modeling Labs) Dec 7, 2025
- Add configure_nodes() method to apply hostname and basic config to CML2 nodes
- Add --cml2-init-config CLI argument (enabled by default)
- Store device alias in DeviceInfo dataclass
- Use device name for hostname to match Unicon's hostname validation
- Update README with new option documentation
- Add _transform_logical_testbed() to handle logical testbed configs
- Remove unsupported OS types (pagent, traffic generators) from testbed
- Strip dyntopo-specific keys from device configs
- Rename interface aliases to actual_name values in topology
- Handle skip-bringup mode for testbed.actual.yaml creation
- Fix IP address serialization in _testbed_to_dict()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants