{"library":"pyats-kleenex","title":"pyATS Kleenex: Testbed Preparation, Clean & Finalization","description":"pyATS Kleenex is a crucial component of the larger pyATS ecosystem, specifically designed for testbed preparation, cleaning, and finalization tasks. It enables network engineers to restore network devices to a known good state before or after executing automated tests, ensuring consistent testing environments. As part of the pyATS framework, it maintains a regular release cadence, often monthly or bi-monthly, aligning with overall pyATS updates. The current version is 26.3.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pyats.kleenex","pip install 'pyats[kleenex]'"],"cli":{"name":"kleenex","version":"Traceback (most recent call last):"}},"imports":["from pyats.clean.loader import KleenexFileLoader"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# Create a simple testbed.yaml file\n# devices:\n#   csr1:\n#     os: iosxe\n#     type: router\n#     connections:\n#       cli:\n#         protocol: ssh\n#         ip: 10.0.0.1\n#         credentials:\n#           default:\n#             username: cisco\n#             password: cisco\n\n# To run a clean operation using the pyats clean CLI command (recommended approach)\n# Assuming you have a testbed.yaml and a clean.yaml defining the clean stages\n# pyats clean <testbed.yaml> -clean_file <clean.yaml>\n\n# Example of a simple clean.yaml content:\n# clean:\n#   csr1:\n#     sections:\n#       - 'power_cycle'\n#       - 'install_image':\n#           image: \"/path/to/image.bin\"\n\n# Example Python snippet to initiate a clean operation (simplified conceptual view)\nimport os\nfrom pyats import topology\nfrom pyats.clean import clean_testbed\n\ntry:\n    # Load your testbed\n    testbed = topology.load(os.environ.get('TESTBED_YAML', 'testbed.yaml'))\n    device = testbed.devices['csr1']\n\n    # Example: Perform a clean operation on a device\n    # This typically requires a separate clean.yaml file to define the stages\n    # For a full execution, you would use pyats run job with a Python job file\n    # that orchestrates the clean operation, or the pyats clean CLI command.\n\n    # Programmatic invocation of clean (requires a clean_file argument in a real scenario)\n    # The clean_testbed function typically takes a testbed object and a clean file path.\n    print(f\"Attempting to clean device: {device.name}\")\n    # This is a conceptual example, actual clean invocation is more complex\n    # and often driven by EasyPy or the 'pyats clean' CLI.\n\n    # For demonstration, we'll simulate a successful clean stage\n    print(f\"Device {device.name} is ready for cleaning operations.\")\n    print(\"To execute a full clean, use the 'pyats clean <testbed.yaml> -clean_file <clean.yaml>' CLI command.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"The quickstart demonstrates the general approach to using pyATS Kleenex functionality. While `pyats.kleenex` is the package, the primary interaction for cleaning devices is through the `pyats clean` command-line interface. This example shows how to conceptually set up a testbed and points to the CLI for execution.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}