Skip to content
Snippets Groups Projects
Commit b3f69eea authored by Attila Farkas's avatar Attila Farkas
Browse files

Merge branch '70-add-support-for-usb-devices' into 'master'

Resolve "Add support for USB devices"

Closes #70

See merge request !31
parents 1965c197 c055d7d7
No related branches found
No related tags found
1 merge request!31Resolve "Add support for USB devices"
integer:
memory: memory
cpus: cpus
other:
vb_customize: customize
......@@ -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.")
......@@ -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()
......
......@@ -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
......
......@@ -3,7 +3,7 @@ name: 0-routers-1-networks-1-hosts
hosts:
- name: debian10
base_box:
image: generic/debian10
image: munikypo/debian-10
flavor: csirtmu.tiny1x4
cpus: 2
......
......@@ -3,7 +3,7 @@ name: 1-network-various-boxes
hosts:
- name: debian10
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: debian9
......@@ -23,7 +23,7 @@ hosts:
- name: mu-kali
base_box:
image: kali-2019.4
image: munikypo/kali-2019.4
memory: 2048
networks:
......
......@@ -4,7 +4,7 @@ name: 1-router-1-host
hosts:
- name: debian10
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
routers:
......
......@@ -3,12 +3,12 @@ name: 2-networks
hosts:
- name: server
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: home
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
routers:
......
......@@ -4,12 +4,12 @@ name: 2-networks-connected-by-br
hosts:
- name: server
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: home
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
routers:
......
......@@ -4,19 +4,19 @@ name: 2-networks-connected-by-br
hosts:
- name: host1
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: host2
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: host3
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
- name: host4
base_box:
image: generic/debian10
image: munikypo/debian-10
memory: 512
routers:
......@@ -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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment