CML2 Plugin: Enhanced pyATS integration with CML2 (Cisco Modeling Labs)#110
Open
CML2 Plugin: Enhanced pyATS integration with CML2 (Cisco Modeling Labs)#110
Conversation
- 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
- 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
- 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()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CLI Arguments
--cml2-enable--cml2-url--cml2-username--cml2-password--cml2-keep-labPlatform Support
Automatic platform inference and node definition mapping for:
Default Credentials
Automatic application of CML2 default credentials based on node definition:
genie.testbed.load()Link Verification
RuntimeErrorif expected links are missingTopology Summary Display
Displays comprehensive lab topology information before
pre_jobcompletion:Implementation Details
Key Methods
CML2LabBuilder.build()- Creates CML2 lab from testbedCML2LabBuilder.verify_links()- Validates lab link topologyCML2Plugin.pre_job()- Handles lab creation and startupCML2Plugin.post_job()- Handles lab cleanupCML2Plugin._update_testbed_in_place()- Updates testbed with CML2 infoCML2Plugin._display_topology_summary()- Shows topology summaryHelper Functions
infer_platform()- Infers CML2 platform from device attributesget_node_definition()- Maps platform to CML2 node definitionFiles Changed
src/pyats/contrib/plugins/cml2_plugin/cml2.pyTesting
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