mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 07:35:22 +00:00
Merge pull request #538 from catborise/master
make cd-rom and input devices optional while instance creating
This commit is contained in:
commit
2dc4048053
11 changed files with 210 additions and 55 deletions
|
@ -41,6 +41,7 @@ RUN python3 -m venv venv && \
|
||||||
chown -R www-data:www-data /srv/webvirtcloud
|
chown -R www-data:www-data /srv/webvirtcloud
|
||||||
|
|
||||||
RUN . venv/bin/activate && \
|
RUN . venv/bin/activate && \
|
||||||
|
python3 manage.py makemigrations && \
|
||||||
python3 manage.py migrate && \
|
python3 manage.py migrate && \
|
||||||
python3 manage.py collectstatic --noinput && \
|
python3 manage.py collectstatic --noinput && \
|
||||||
chown -R www-data:www-data /srv/webvirtcloud
|
chown -R www-data:www-data /srv/webvirtcloud
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
defautl_app_config = 'admin.apps.AdminConfig'
|
default_app_config = 'admin.apps.AdminConfig'
|
||||||
|
|
|
@ -24,5 +24,5 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(add_default_settings, del_default_settings),
|
migrations.RunPython(add_default_settings, del_default_settings),
|
||||||
]
|
]
|
||||||
|
|
21
appsettings/migrations/0007_auto_20220905_0918.py
Normal file
21
appsettings/migrations/0007_auto_20220905_0918.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-06-30 07:17
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
def update_default_settings(apps, schema_editor):
|
||||||
|
setting = apps.get_model("appsettings", "AppSettings")
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
setting.objects.using(db_alias).filter(key="INSTANCE_MACHINE_DEFAULT_TYPE").update(choices="q35,x86_64,virt"),
|
||||||
|
setting.objects.using(db_alias).filter(key="INSTANCE_ARCH_DEFAULT_TYPE").update(choices="x86_64,i686,aarch64"),
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('appsettings', '0006_auto_20220630_0717'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_default_settings, None)
|
||||||
|
]
|
32
appsettings/migrations/0008_auto_20220905_1459.py
Normal file
32
appsettings/migrations/0008_auto_20220905_1459.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-06-30 07:17
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
def add_default_settings(apps, schema_editor):
|
||||||
|
setting = apps.get_model("appsettings", "AppSettings")
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
setting.objects.using(db_alias).bulk_create([
|
||||||
|
setting(32, _("VM CD-ROM Device"), "INSTANCE_CDROM_ADD", "sata", "None,ide,sata,scsi,virtio", _("Add or not cdrom device while instance creating")),
|
||||||
|
setting(33, _("VM Video Type"), "INSTANCE_VIDEO_DEFAULT_TYPE", "vga", "None,virtio,vga,cirrus,vmvga,bochs,ramfb", _("Change instance default video type")),
|
||||||
|
setting(34, _("VM Input Device"), "INSTANCE_INPUT_DEFAULT_DEVICE", "default", "None,default,virtio,usb", _("Add or not input device with specify its type")),
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def del_default_settings(apps, schema_editor):
|
||||||
|
setting = apps.get_model("appsettings", "AppSettings")
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
setting.objects.using(db_alias).filter(key="INSTANCE_CDROM_ADD").delete()
|
||||||
|
setting.objects.using(db_alias).filter(key="INSTANCE_VIDEO_DEFAULT_TYPE").delete()
|
||||||
|
setting.objects.using(db_alias).filter(key="INSTANCE_INPUT_DEFAULT_DEVICE").delete()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('appsettings', '0007_auto_20220905_0918'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(add_default_settings, del_default_settings),
|
||||||
|
]
|
|
@ -199,24 +199,24 @@ class CreateInstanceViewSet(viewsets.ViewSet):
|
||||||
firmware["secure"] = "yes"
|
firmware["secure"] = "yes"
|
||||||
|
|
||||||
ret = conn.create_instance(
|
ret = conn.create_instance(
|
||||||
serializer.validated_data['name'],
|
name=serializer.validated_data['name'],
|
||||||
serializer.validated_data['memory'],
|
memory=serializer.validated_data['memory'],
|
||||||
serializer.validated_data['vcpu'],
|
vcpu=serializer.validated_data['vcpu'],
|
||||||
serializer.validated_data['vcpu_mode'],
|
vcpu_mode=serializer.validated_data['vcpu_mode'],
|
||||||
util.randomUUID(),
|
uuid=util.randomUUID(),
|
||||||
arch,
|
arch=arch,
|
||||||
machine,
|
machine=machine,
|
||||||
firmware,
|
firmware=firmware,
|
||||||
volume_list,
|
volumes=volume_list,
|
||||||
serializer.validated_data['networks'],
|
networks=serializer.validated_data['networks'],
|
||||||
serializer.validated_data['nwfilter'],
|
nwfilter=serializer.validated_data['nwfilter'],
|
||||||
serializer.validated_data['graphics'],
|
graphics=serializer.validated_data['graphics'],
|
||||||
serializer.validated_data['virtio'],
|
virtio=serializer.validated_data['virtio'],
|
||||||
serializer.validated_data['listener_addr'],
|
listener_addr=serializer.validated_data['listener_addr'],
|
||||||
serializer.validated_data['video'],
|
video=serializer.validated_data['video'],
|
||||||
serializer.validated_data['console_pass'],
|
console_pass=serializer.validated_data['console_pass'],
|
||||||
serializer.validated_data['mac'],
|
mac=serializer.validated_data['mac'],
|
||||||
serializer.validated_data['qemu_ga'],
|
qemu_ga=serializer.validated_data['qemu_ga'],
|
||||||
)
|
)
|
||||||
msg = f"Instance {serializer.validated_data['name']} is created"
|
msg = f"Instance {serializer.validated_data['name']} is created"
|
||||||
return Response({'status': msg })
|
return Response({'status': msg })
|
||||||
|
|
|
@ -3,7 +3,6 @@ from django.utils.functional import cached_property
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from libvirt import VIR_DOMAIN_XML_SECURE
|
from libvirt import VIR_DOMAIN_XML_SECURE
|
||||||
from vrtManager.create import wvmCreate
|
|
||||||
from webvirtcloud.settings import QEMU_CONSOLE_LISTENER_ADDRESSES
|
from webvirtcloud.settings import QEMU_CONSOLE_LISTENER_ADDRESSES
|
||||||
|
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
|
@ -228,7 +227,7 @@ class MigrateInstance(models.Model):
|
||||||
class CreateInstance(models.Model):
|
class CreateInstance(models.Model):
|
||||||
compute = models.ForeignKey(Compute, related_name='host', on_delete=models.DO_NOTHING)
|
compute = models.ForeignKey(Compute, related_name='host', on_delete=models.DO_NOTHING)
|
||||||
name = models.CharField(max_length=64, error_messages={'required': _('No Virtual Machine name has been entered')})
|
name = models.CharField(max_length=64, error_messages={'required': _('No Virtual Machine name has been entered')})
|
||||||
firmware = models.CharField(max_length=50)
|
firmware = models.CharField(max_length=64)
|
||||||
vcpu = models.IntegerField(error_messages={'required': _('No VCPU has been entered')})
|
vcpu = models.IntegerField(error_messages={'required': _('No VCPU has been entered')})
|
||||||
vcpu_mode = models.CharField(max_length=20, blank=True)
|
vcpu_mode = models.CharField(max_length=20, blank=True)
|
||||||
disk = models.IntegerField(blank=True)
|
disk = models.IntegerField(blank=True)
|
||||||
|
@ -238,15 +237,17 @@ class CreateInstance(models.Model):
|
||||||
storage = models.CharField(max_length=256, blank=True)
|
storage = models.CharField(max_length=256, blank=True)
|
||||||
template = models.CharField(max_length=256, blank=True)
|
template = models.CharField(max_length=256, blank=True)
|
||||||
images = models.CharField(max_length=256, blank=True)
|
images = models.CharField(max_length=256, blank=True)
|
||||||
cache_mode = models.CharField(max_length=12, error_messages={'required': _('Please select HDD cache mode')})
|
cache_mode = models.CharField(max_length=16, error_messages={'required': _('Please select HDD cache mode')})
|
||||||
hdd_size = models.IntegerField(blank=True)
|
hdd_size = models.IntegerField(blank=True)
|
||||||
meta_prealloc = models.BooleanField(default=False, blank=True)
|
meta_prealloc = models.BooleanField(default=False, blank=True)
|
||||||
virtio = models.BooleanField(default=True)
|
virtio = models.BooleanField(default=True)
|
||||||
qemu_ga = models.BooleanField(default=False)
|
qemu_ga = models.BooleanField(default=False)
|
||||||
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)
|
||||||
graphics = models.CharField(max_length=12, error_messages={'required': _('Please select a graphics type')})
|
add_cdrom = models.CharField(max_length=16)
|
||||||
video = models.CharField(max_length=12, error_messages={'required': _('Please select a video driver')})
|
add_input = models.CharField(max_length=16)
|
||||||
|
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')})
|
||||||
listener_addr = models.CharField(max_length=20, choices=QEMU_CONSOLE_LISTENER_ADDRESSES)
|
listener_addr = models.CharField(max_length=20, choices=QEMU_CONSOLE_LISTENER_ADDRESSES)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -227,7 +227,7 @@
|
||||||
<option value="cirrus">cirrus</option>
|
<option value="cirrus">cirrus</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for video in videos %}
|
{% for video in videos %}
|
||||||
<option value="{{ video }}">{{ video }}</option>
|
<option value="{{ video }}" {% if default_video == video %}selected{% endif %}>{{ video }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -248,6 +248,32 @@
|
||||||
<input class="form-control" type="password" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
<input class="form-control" type="password" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-4 col-form-label">{% trans "Add CD-Rom" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_cdrom" name="add_cdrom">
|
||||||
|
<option value="None" {% if bus == default_cdrom %}selected{% endif %}>--{% trans "False" %}--</option>
|
||||||
|
{% for bus in disk_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_cdrom %}selected {% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</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">
|
||||||
|
@ -478,6 +504,32 @@
|
||||||
<input type="password" class="form-control" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
<input type="password" class="form-control" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Add CD-Rom" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_cdrom" name="add_cdrom">
|
||||||
|
<option value="None" {% if bus == default_cdrom %}selected{% endif %} >--{% trans "False" %}--</option>
|
||||||
|
{% for bus in disk_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_cdrom %}selected {% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</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">
|
||||||
|
@ -694,6 +746,32 @@
|
||||||
<input type="password" class="form-control" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
<input type="password" class="form-control" name="console_pass" placeholder="{% trans "Console Password" %}" maxlength="64">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Add CD-Rom" %}</label>
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<select class="form-select" id="add_cdrom" name="add_cdrom">
|
||||||
|
<option value="None" {% if bus == default_cdrom %}selected{% endif %}>--{% trans "False" %}--</option>
|
||||||
|
{% for bus in disk_buses %}
|
||||||
|
<option value="{{ bus }}" {% if bus == default_cdrom %}selected {% endif %}>
|
||||||
|
{% trans bus %}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</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">
|
||||||
|
|
|
@ -1376,6 +1376,7 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
default_cpu_mode = app_settings.INSTANCE_CPU_DEFAULT_MODE
|
default_cpu_mode = app_settings.INSTANCE_CPU_DEFAULT_MODE
|
||||||
instances = conn.get_instances()
|
instances = conn.get_instances()
|
||||||
videos = conn.get_video_models(arch, machine)
|
videos = conn.get_video_models(arch, machine)
|
||||||
|
default_video = app_settings.INSTANCE_VIDEO_DEFAULT_TYPE
|
||||||
cache_modes = sorted(conn.get_cache_modes().items())
|
cache_modes = sorted(conn.get_cache_modes().items())
|
||||||
default_cache = app_settings.INSTANCE_VOLUME_DEFAULT_CACHE
|
default_cache = app_settings.INSTANCE_VOLUME_DEFAULT_CACHE
|
||||||
default_io = app_settings.INSTANCE_VOLUME_DEFAULT_IO
|
default_io = app_settings.INSTANCE_VOLUME_DEFAULT_IO
|
||||||
|
@ -1394,6 +1395,9 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
nwfilters = conn.get_nwfilters()
|
nwfilters = conn.get_nwfilters()
|
||||||
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
|
||||||
|
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)
|
||||||
|
@ -1552,6 +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_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()
|
||||||
|
|
|
@ -165,6 +165,8 @@ class wvmCreate(wvmConnect):
|
||||||
console_pass="random",
|
console_pass="random",
|
||||||
mac=None,
|
mac=None,
|
||||||
qemu_ga=True,
|
qemu_ga=True,
|
||||||
|
add_cdrom="sata",
|
||||||
|
add_input="default"
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create VM function
|
Create VM function
|
||||||
|
@ -233,10 +235,20 @@ class wvmCreate(wvmConnect):
|
||||||
fd_disk_letters = list(string.ascii_lowercase)
|
fd_disk_letters = list(string.ascii_lowercase)
|
||||||
hd_disk_letters = list(string.ascii_lowercase)
|
hd_disk_letters = list(string.ascii_lowercase)
|
||||||
sd_disk_letters = list(string.ascii_lowercase)
|
sd_disk_letters = list(string.ascii_lowercase)
|
||||||
add_cd = True
|
def get_letter(bus_type):
|
||||||
|
if bus_type == "ide":
|
||||||
|
return hd_disk_letters.pop(0)
|
||||||
|
elif bus_type in ["sata", "scsi"]:
|
||||||
|
return sd_disk_letters.pop(0)
|
||||||
|
elif bus_type == "fdc":
|
||||||
|
return fd_disk_letters.pop(0)
|
||||||
|
elif bus_type == "virtio":
|
||||||
|
return vd_disk_letters.pop(0)
|
||||||
|
else:
|
||||||
|
return sd_disk_letters.pop(0)
|
||||||
|
|
||||||
|
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
|
|
||||||
disk_opts = ""
|
disk_opts = ""
|
||||||
if volume["cache_mode"] is not None and volume["cache_mode"] != "default":
|
if volume["cache_mode"] is not None and volume["cache_mode"] != "default":
|
||||||
disk_opts += f"cache='{volume['cache_mode']}' "
|
disk_opts += f"cache='{volume['cache_mode']}' "
|
||||||
|
@ -251,7 +263,7 @@ class wvmCreate(wvmConnect):
|
||||||
stg_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
stg_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||||
|
|
||||||
if volume["device"] == "cdrom":
|
if volume["device"] == "cdrom":
|
||||||
add_cd = False
|
add_cdrom = "None"
|
||||||
|
|
||||||
if stg_type == "rbd":
|
if stg_type == "rbd":
|
||||||
ceph_user, secret_uuid, ceph_hosts = get_rbd_storage_data(stg)
|
ceph_user, secret_uuid, ceph_hosts = get_rbd_storage_data(stg)
|
||||||
|
@ -274,34 +286,24 @@ class wvmCreate(wvmConnect):
|
||||||
xml += f""" <driver name='qemu' type='{volume["type"]}' {disk_opts}/>"""
|
xml += f""" <driver name='qemu' type='{volume["type"]}' {disk_opts}/>"""
|
||||||
xml += f""" <source file='{volume["path"]}'/>"""
|
xml += f""" <source file='{volume["path"]}'/>"""
|
||||||
|
|
||||||
if volume.get("bus") == "virtio":
|
if volume.get("bus") in dom_caps["disk_bus"]:
|
||||||
xml += """<target dev='vd%s' bus='%s'/>""" % (vd_disk_letters.pop(0), volume.get("bus"))
|
dev_prefix = util.vol_dev_type(volume.get("bus"))
|
||||||
elif volume.get("bus") == "ide":
|
xml += """<target dev='%s%s' bus='%s'/>""" % (dev_prefix, get_letter(volume.get("bus")), volume.get("bus"))
|
||||||
xml += """<target dev='hd%s' bus='%s'/>""" % (hd_disk_letters.pop(0), volume.get("bus"))
|
|
||||||
elif volume.get("bus") == "fdc":
|
|
||||||
xml += """<target dev='fd%s' bus='%s'/>""" % (fd_disk_letters.pop(0), volume.get("bus"))
|
|
||||||
elif volume.get("bus") in ["sata", "scsi"]:
|
|
||||||
xml += """<target dev='sd%s' bus='%s'/>""" % (sd_disk_letters.pop(0), volume.get("bus"))
|
|
||||||
else:
|
else:
|
||||||
xml += """<target dev='sd%s'/>""" % sd_disk_letters.pop(0)
|
xml += """<target dev='sd%s'/>""" % get_letter("sata")
|
||||||
xml += """</disk>"""
|
xml += """</disk>"""
|
||||||
|
|
||||||
if volume.get("bus") == "scsi":
|
if volume.get("bus") == "scsi":
|
||||||
xml += f"""<controller type='scsi' model='{volume.get('scsi_model')}'/>"""
|
xml += f"""<controller type='scsi' model='{volume.get('scsi_model')}'/>"""
|
||||||
|
|
||||||
if add_cd:
|
if add_cdrom != "None":
|
||||||
xml += """<disk type='file' device='cdrom'>
|
xml += """<disk type='file' device='cdrom'>
|
||||||
<driver name='qemu' type='raw'/>
|
<driver name='qemu' type='raw'/>
|
||||||
<source file = '' />
|
<source file = '' />
|
||||||
<readonly/>"""
|
<readonly/>"""
|
||||||
if "ide" in dom_caps["disk_bus"]:
|
if add_cdrom in dom_caps["disk_bus"]:
|
||||||
xml += """<target dev='hd%s' bus='%s'/>""" % (hd_disk_letters.pop(0), "ide")
|
dev_prefix = util.vol_dev_type(add_cdrom)
|
||||||
elif "sata" in dom_caps["disk_bus"]:
|
xml += """<target dev='%s%s' bus='%s'/>""" % (dev_prefix, get_letter(add_cdrom), add_cdrom)
|
||||||
xml += """<target dev='sd%s' bus='%s'/>""" % (sd_disk_letters.pop(0), "sata")
|
|
||||||
elif "scsi" in dom_caps["disk_bus"]:
|
|
||||||
xml += """<target dev='sd%s' bus='%s'/>""" % (sd_disk_letters.pop(0), "scsi")
|
|
||||||
else:
|
|
||||||
xml += """<target dev='vd%s' bus='%s'/>""" % (vd_disk_letters.pop(0), "virtio")
|
|
||||||
xml += """</disk>"""
|
xml += """</disk>"""
|
||||||
|
|
||||||
if mac:
|
if mac:
|
||||||
|
@ -322,14 +324,16 @@ 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}'/>"""
|
||||||
else:
|
xml += f"""<input type='keyboard' bus='{add_input}'/>"""
|
||||||
xml += """<input type='mouse'/>"""
|
xml += f"""<input type='tablet' bus='{add_input}'/>"""
|
||||||
xml += """<input type='keyboard'/>"""
|
else:
|
||||||
xml += """<input type='tablet'/>"""
|
xml += """<input type='mouse'/>"""
|
||||||
|
xml += """<input type='keyboard'/>"""
|
||||||
|
xml += """<input type='tablet'/>"""
|
||||||
|
|
||||||
xml += f"""
|
xml += f"""
|
||||||
<graphics type='{graphics}' port='-1' autoport='yes' {console_pass} listen='{listener_addr}'/>
|
<graphics type='{graphics}' port='-1' autoport='yes' {console_pass} listen='{listener_addr}'/>
|
||||||
|
|
|
@ -182,3 +182,15 @@ UEFI_ARCH_PATTERNS = {
|
||||||
r".*arm/QEMU_EFI.*", # fedora, gerd's firmware repo
|
r".*arm/QEMU_EFI.*", # fedora, gerd's firmware repo
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def vol_dev_type(vol_bus):
|
||||||
|
if vol_bus == "ide":
|
||||||
|
return "hd"
|
||||||
|
elif vol_bus == "fdc":
|
||||||
|
return "fd"
|
||||||
|
elif vol_bus == "virtio":
|
||||||
|
return "vd"
|
||||||
|
elif vol_bus in ["scsi", "sata"]:
|
||||||
|
return "sd"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue