Skip to content

Commit caef53f

Browse files
committed
Add support for live EVE to CML conversion.
1 parent e9f87f4 commit caef53f

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
22
exclude = cmlutils,venv*,.git,.eggs,__pycache__,docs/source/conf.py,old,build,dist
33
ignore = E731
4-
max-complexity = 20
4+
max-complexity = 25
55
max-line-length = 140

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,12 @@ Technical Support: http://www.cisco.com/techsupport
488488
489489
```
490490
491+
#### EVE-NG Lab Support
492+
493+
The `cml up` command can convert EVE-NG labs to CML labs on the fly (".unl" to ".yaml" conversion) if you install the
494+
[eve2cml](https://pypi.org/project/eve2cml/) Python library. With that library installed, a command such as
495+
`cml up -f my-lab.unl` will convert `my-lab.unl` to `my-lab.yaml` in the same directory and import it into CML.
496+
491497
#### Ansible Inventory Generation
492498
493499
quickly turn your simulations into an inventory file that can be used to run your playbooks
@@ -686,7 +692,6 @@ User bob successfully updated
686692
687693
Check the cli help for more options.
688694
689-
690695
To delete one or multiple users.
691696
692697
``` sh
@@ -707,7 +712,6 @@ User bob successfully deleted
707712
╘════════════╧═════════════════╧═════════════╧═════════╧════════════╧════════════════════════╛
708713
```
709714
710-
711715
#### Groups
712716
713717
To manage groups you can use the `cml groups` command

virl/about.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.2.1"
1+
__version__ = "2.3.0"

virl/cli/up/commands.py

+24-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
import click
66

77
from virl.api import CachedLab, VIRLServer
8-
from virl.helpers import (cache_lab, check_lab_cache, clear_current_lab,
9-
get_cml_client, get_command, get_current_lab,
10-
safe_join_existing_lab,
11-
safe_join_existing_lab_by_title, set_current_lab)
8+
from virl.helpers import (
9+
cache_lab,
10+
check_lab_cache,
11+
clear_current_lab,
12+
get_cml_client,
13+
get_command,
14+
get_current_lab,
15+
safe_join_existing_lab,
16+
safe_join_existing_lab_by_title,
17+
set_current_lab,
18+
)
1219

1320

1421
def get_lab_title(fname):
@@ -127,6 +134,19 @@ def up(repo=None, provision=False, start=True, **kwargs):
127134
lab = safe_join_existing_lab_by_title(lab_name, client)
128135

129136
if not lab and os.path.isfile(fname):
137+
(lfname, lfext) = os.path.splitext(fname)
138+
if lfext.lower() == ".unl":
139+
# This is an EVE-NG lab. Convert it if we can.
140+
rc = call(["eve2cml", fname])
141+
if rc != 0:
142+
click.secho(
143+
"ERROR: Failed to convert {} from EVE-NG to CML. Is https://pypi.org/project/eve2cml/ installed?".format(fname),
144+
fg="red",
145+
)
146+
exit(rc)
147+
148+
fname = "{}.yaml".format(lfname)
149+
130150
lname = get_lab_title(fname)
131151
click.secho("Importing lab {} from file {}".format(lname, fname))
132152
lab = client.import_lab_from_path(fname, title=lname)

0 commit comments

Comments
 (0)