mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 15:45:23 +00:00
make adding input devices optional. give bus control for input devices whie instance creating
This commit is contained in:
parent
5f5bd379af
commit
481c110f01
4 changed files with 55 additions and 9 deletions
|
@ -245,6 +245,7 @@ class CreateInstance(models.Model):
|
||||||
mac = models.CharField(max_length=17, blank=True)
|
mac = models.CharField(max_length=17, blank=True)
|
||||||
console_pass = models.CharField(max_length=64, blank=True)
|
console_pass = models.CharField(max_length=64, blank=True)
|
||||||
add_cdrom = models.CharField(max_length=16)
|
add_cdrom = models.CharField(max_length=16)
|
||||||
|
add_input = models.CharField(max_length=16)
|
||||||
graphics = models.CharField(max_length=16, error_messages={'required': _('Please select a graphics type')})
|
graphics = models.CharField(max_length=16, error_messages={'required': _('Please select a graphics type')})
|
||||||
video = models.CharField(max_length=16, error_messages={'required': _('Please select a video driver')})
|
video = models.CharField(max_length=16, error_messages={'required': _('Please select a video driver')})
|
||||||
listener_addr = models.CharField(max_length=20, choices=QEMU_CONSOLE_LISTENER_ADDRESSES)
|
listener_addr = models.CharField(max_length=20, choices=QEMU_CONSOLE_LISTENER_ADDRESSES)
|
||||||
|
|
|
@ -261,6 +261,19 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-4 col-form-label">{% trans "Add Input Device" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_input" name="add_input">
|
||||||
|
<option value="None" {% if bus == default_input_device_bus %}selected{% endif %}>--{% trans "False" %}--</option>
|
||||||
|
{% for bus in input_device_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_input_device_bus %}selected{% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-4 col-form-label">{% trans "Guest Agent" %}</label>
|
<label class="col-sm-4 col-form-label">{% trans "Guest Agent" %}</label>
|
||||||
<div class="col-sm-7">
|
<div class="col-sm-7">
|
||||||
|
@ -504,6 +517,19 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Add Input Device" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_input" name="add_input">
|
||||||
|
<option value="None" {% if bus == default_input_device_bus %}selected{% endif %}>--{% trans "False" %}--</option>
|
||||||
|
{% for bus in input_device_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_input_device_bus %}selected{% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "Guest Agent" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "Guest Agent" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -733,6 +759,19 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Add Input Device" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_input" name="add_input">
|
||||||
|
<option value="None" {% if bus == default_input_device_bus %}selected{% endif %}>--{% trans "False" %}--</option>
|
||||||
|
{% for bus in input_device_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_input_device_bus %}selected{% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "Guest Agent" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "Guest Agent" %}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
|
|
@ -1396,6 +1396,8 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
storages = sorted(conn.get_storages(only_actives=True))
|
storages = sorted(conn.get_storages(only_actives=True))
|
||||||
default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE
|
default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE
|
||||||
default_cdrom = app_settings.INSTANCE_CDROM_ADD
|
default_cdrom = app_settings.INSTANCE_CDROM_ADD
|
||||||
|
input_device_buses = ['default', 'virtio', 'usb']
|
||||||
|
default_input_device_bus = app_settings.INSTANCE_INPUT_DEFAULT_DEVICE
|
||||||
|
|
||||||
dom_caps = conn.get_dom_capabilities(arch, machine)
|
dom_caps = conn.get_dom_capabilities(arch, machine)
|
||||||
caps = conn.get_capabilities(arch)
|
caps = conn.get_capabilities(arch)
|
||||||
|
@ -1554,7 +1556,8 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
console_pass=data["console_pass"],
|
console_pass=data["console_pass"],
|
||||||
mac=data["mac"],
|
mac=data["mac"],
|
||||||
qemu_ga=data["qemu_ga"],
|
qemu_ga=data["qemu_ga"],
|
||||||
add_cdrom=data["add_cdrom"]
|
add_cdrom=data["add_cdrom"],
|
||||||
|
add_input=data["add_input"],
|
||||||
)
|
)
|
||||||
create_instance = Instance(compute_id=compute_id, name=data["name"], uuid=uuid)
|
create_instance = Instance(compute_id=compute_id, name=data["name"], uuid=uuid)
|
||||||
create_instance.save()
|
create_instance.save()
|
||||||
|
|
|
@ -166,6 +166,7 @@ class wvmCreate(wvmConnect):
|
||||||
mac=None,
|
mac=None,
|
||||||
qemu_ga=True,
|
qemu_ga=True,
|
||||||
add_cdrom="sata",
|
add_cdrom="sata",
|
||||||
|
add_input="default"
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create VM function
|
Create VM function
|
||||||
|
@ -324,10 +325,12 @@ class wvmCreate(wvmConnect):
|
||||||
elif console_pass != "":
|
elif console_pass != "":
|
||||||
console_pass = "passwd='" + console_pass + "'"
|
console_pass = "passwd='" + console_pass + "'"
|
||||||
|
|
||||||
if "usb" in dom_caps["disk_bus"]:
|
if add_input != "None":
|
||||||
xml += f"""<input type='mouse' bus='{"virtio" if virtio else "usb"}'/>"""
|
xml += """<controller type='usb'/>"""
|
||||||
xml += f"""<input type='keyboard' bus='{"virtio" if virtio else "usb"}'/>"""
|
if add_input in dom_caps["disk_bus"]:
|
||||||
xml += f"""<input type='tablet' bus='{"virtio" if virtio else "usb"}'/>"""
|
xml += f"""<input type='mouse' bus='{add_input}'/>"""
|
||||||
|
xml += f"""<input type='keyboard' bus='{add_input}'/>"""
|
||||||
|
xml += f"""<input type='tablet' bus='{add_input}'/>"""
|
||||||
else:
|
else:
|
||||||
xml += """<input type='mouse'/>"""
|
xml += """<input type='mouse'/>"""
|
||||||
xml += """<input type='keyboard'/>"""
|
xml += """<input type='keyboard'/>"""
|
||||||
|
|
Loading…
Reference in a new issue