diff --git a/conf/virtualbox_mapping.yml b/conf/virtualbox_mapping.yml index 46e9575f636dfeae1763fa2e27a9629aba2e7adf..e9fa6f447a33a9a6513ea2e053dd7fccb3b426cf 100644 --- a/conf/virtualbox_mapping.yml +++ b/conf/virtualbox_mapping.yml @@ -1,3 +1,5 @@ integer: memory: memory cpus: cpus +other: + vb_customize: customize diff --git a/modules/preprocessing.py b/modules/preprocessing.py index d49c7bff5e53ed1f617743ecb3b332012083b916..bc64659aa6f6342856c68ff61e0940b6e63ed926 100644 --- a/modules/preprocessing.py +++ b/modules/preprocessing.py @@ -72,6 +72,14 @@ def _delete_dummy_router(definitions): return +def _add_usb_passthrough(definitions): + """Add usb passthrough to devices""" + for host in definitions["hosts"]: + if "extra" in host and host["extra"]: + if "usb_passthrough" in host["extra"]: + host["vb_customize"] = '["modifyvm", :id, "--usb", "on"]' + + def _find_windows_boxes(definitions): """Find and return list of host names with windows boxes.""" windows_hosts = [] @@ -147,3 +155,9 @@ def preprocess(definitions, flags): except Exception: cleanup_and_exit("Preprocessing not successful: " "Could not add flavors.") + + try: + _add_usb_passthrough(definitions) + except Exception: + cleanup_and_exit("Preprocessing not successful: " + "Could not add USB passthrough.") diff --git a/modules/vagrant_generator.py b/modules/vagrant_generator.py index b8fabb3f4b2b39dc3bb88238942944f9e2e6e9d5..96259be693d3d52ef4c0066214098f7a40cb875b 100644 --- a/modules/vagrant_generator.py +++ b/modules/vagrant_generator.py @@ -24,7 +24,8 @@ def _create_simple_attribute(key, value, attribute_type): def _create_complex_attribute(key, value): """Create complex vagrant attributes that are not string, int or bool.""" - separators = {VAGRANT_MAPPING["other"]["synced_folder"]: ""} + separators = {VAGRANT_MAPPING["other"]["synced_folder"]: "", + VIRTUALBOX_MAPPING["other"]["vb_customize"]: ""} attribute = dict() attribute["type"] = "other" @@ -85,6 +86,10 @@ def _create_commands(device_attributes): vagrant_attribute = VIRTUALBOX_MAPPING["integer"][attribute] vb_commands.append(_create_simple_attribute(vagrant_attribute, value, "integer")) + elif attribute in VIRTUALBOX_MAPPING["other"]: + vagrant_attribute = VIRTUALBOX_MAPPING["other"][attribute] + vb_commands.append(_create_complex_attribute(vagrant_attribute, + value)) if vb_commands: virtual_box_command = dict() diff --git a/templates/vagrantfile b/templates/vagrantfile index b5eff4a5e6f8302d7d955bbe862f7f1a6a449ba8..2636960ca873928a373a53834ea2b7f5aef244f3 100644 --- a/templates/vagrantfile +++ b/templates/vagrantfile @@ -162,6 +162,8 @@ end {{ dictionary(item, namespace) -}} {% elif item.type == "groups" %} {{ groups(item, namespace) -}} +{% elif item.type == "other" %} + {{ other(item, namespace) -}} {% endif %} {% endfor %} end diff --git a/topologies/2-routers-4-networks-4-hosts.yml b/topologies/2-routers-4-networks-4-hosts.yml index d5da8422880dd595a194f9a4ba738500b4776295..b1f21f8f2360103c5fb2cf46059294f2dad8003e 100644 --- a/topologies/2-routers-4-networks-4-hosts.yml +++ b/topologies/2-routers-4-networks-4-hosts.yml @@ -59,4 +59,4 @@ router_mappings: ip: 10.10.40.1 - router: router2 network: network4 - ip: 10.10.50.1 \ No newline at end of file + ip: 10.10.50.1 diff --git a/topology.yml b/topology.yml index 02978c440bfc5fa16af7c4cc13a860a819ec0888..97b9d257b46e0d21ffe640a61ed3ed4e7ded5914 100644 --- a/topology.yml +++ b/topology.yml @@ -2,15 +2,13 @@ name: small-sandbox hosts: - name: server base_box: - image: ubuntu/xenial64 + image: munikypo/debian-10 flavor: csirtmu.tiny1x4 cpus: 2 - name: home base_box: - image: ubuntu/xenial64 - boot_timeout: 1000 - box_check_update: false + image: munikypo/debian-10 routers: - name: router