Commit fb2bd674 by Bach Dániel

storage: add ide bus support

parent 082389aa
......@@ -25,5 +25,6 @@
<div style="clear: both;"></div>
{% if request.user.is_superuser %}
<small>{% trans "File name" %}: {{ d.filename }}</small>
<small>{% trans "File name" %}: {{ d.filename }}</small><br/>
<small>{% trans "Bus" %}: {{ d.device_bus }}</small>
{% endif %}
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('storage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='disk',
name='bus',
field=models.CharField(default=None, max_length=10, null=True, blank=True, choices=[('virtio', 'virtio'), ('ide', 'ide'), ('scsi', 'scsi')]),
preserve_default=True,
),
]
......@@ -83,12 +83,15 @@ class Disk(TimeStampedModel):
"""
TYPES = [('qcow2-norm', 'qcow2 normal'), ('qcow2-snap', 'qcow2 snapshot'),
('iso', 'iso'), ('raw-ro', 'raw read-only'), ('raw-rw', 'raw')]
BUS_TYPES = (('virtio', 'virtio'), ('ide', 'ide'), ('scsi', 'scsi'))
name = CharField(blank=True, max_length=100, verbose_name=_("name"))
filename = CharField(max_length=256, unique=True,
verbose_name=_("filename"))
datastore = ForeignKey(DataStore, verbose_name=_("datastore"),
help_text=_("The datastore that holds the disk."))
type = CharField(max_length=10, choices=TYPES)
bus = CharField(max_length=10, choices=BUS_TYPES, null=True, blank=True,
default=None)
size = FileSizeField(null=True, default=None)
base = ForeignKey('self', blank=True, null=True,
related_name='derivatives')
......@@ -222,6 +225,8 @@ class Disk(TimeStampedModel):
def device_bus(self):
"""Returns the proper device prefix for different types of images.
"""
if self.bus:
return self.bus
return {
'qcow2-norm': 'virtio',
'qcow2-snap': 'virtio',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment