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

Add USB passthrough

parent 1965c197
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
......
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