Package: cml2tf
CML2TF: CML to Terraform converterConverts existing Cisco Modeling Labs lab into Terraform HCL .tf files from exported lab topology YAML file.This is an early version of the script. This version is compatible withterraform-provider-cml2version 0.6.2/0.7.0. Not all features are implemented, yet. Please refer toTODO.mdfile for the list of unsupported features and current restrictions.InstallationTo use this package install it via PyPIpip install cml2tf.  It's recommended to use either a virtual environment or use something likepipxto properly isolate the package.DevelopmentIf you want to develop the package thenPDMis needed.  Follow their instructions on the web site to install PDM.  This requires Python3, it's been tested w/ 3.8, 3.9, 3.10 and 3.11.Once installed, you can get a development environment using the follwing steps:Clone the repogitclonehttps://github.com/WojciechowskiPiotr/cml-terraform-converter.gitGo to your project foldercdcml-terraform-converterSet up a Python venv. First make sure that you have Python 3 installed on your machine. We will then be using PDM to create an isolated environment with only the necessary packages.pdmvenvcreate
pdmvenvactivateCopy / paste the resulting string into your shell or use something likedirenvto automate this.Note:Creation of the venv is only needed once, activation whenever you want to work with the venv!Install dependenciespdminstall--devInstall the package as editable (optional, but eases development by installing the script / entry point). Don't commit it to the repo, though.pdmadd--dev--editable.You can remove it again usingpdmremove--dev.Code should be formatted withruffwhich is installed as part of the dev dependencies.  Please ensure to format your code before submitting a PR, the GH action will fail otherwise.UsageFirst, export the lab topology from Cisco Modeling Labs to the YAML file and store it in the project folder. Log into your Cisco Modeling Labs instance to export the lab, enter the lab you want to export from the top menu, select Lab → Download Lab, and save the file.To convert a lab into Terraform files, use the following command:cml2tf -i lab.yamlwherelab.yamlis the name of the exported file.As a result of running the script, a new folderlabwill be created. The folder name is always the same as the exported YAML filename. It contains two files:variables.tfandmain.tf. The first file contains variables like CML server URL, login, and password. Edit this file, providing the correct credentials. Themain.tfhas the topology for Terraform.If a destination folder exists you need to use the-foption to overwrite its content. This will let you update the convertedmain.tffile. Thevariables.tffile, if it exists, remains unchanged.If you want to have the configurations of the lab nodes separated out into individual files which then you can provide the-c / --configsflag.  Themain.tffile will include the exported configurations viafile().To read the full usage information issuecml2tf -hcommand.usage: cml2tf [-h] [-i INPUT] [-o OUTDIR] [-f]

options:
  -h, --help            show this help message and exit

Input options:
  -i INPUT, --input INPUT
                        File with input lab topology in YAML exported from CML2

Output options:
  -o OUTDIR, --outdir OUTDIR
                        Output directory name where terraform files will be created (by default input topology filename)
  -c, --configs         store configurations in separate files
  -f, --force           Overwrite files if destination folder exists

Usage example: cml2tf -i topology.yamlKnown issuesUseGitHub Issuesto report any problems or share ideas about expanding the script.Getting involvedIf you want to contribute to this project, feel free to fork it and then send your proposal using aPull Request.