Commit 3eb04d1b by Karsa Zoltán István

cluster size

parent b81542de
......@@ -863,6 +863,10 @@ class VmCreateDiskForm(OperationForm):
widget=FileSizeWidget, initial=(1 << 20), label=_('Metadata cache size'),
help_text=_('Metadata cache size, '
'like KB, MB'))
cluster_size = forms.CharField(
widget=FileSizeWidget, initial=(1 << 14), label=_('Cluster size'),
help_text=_('Disk cluster (block) size, '
'like KB'))
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', None)
......@@ -884,6 +888,13 @@ class VmCreateDiskForm(OperationForm):
raise forms.ValidationError(_("Invalid format, you can use "
" KB or MB!"))
return int(size_in_kbytes) / 1024
def clean_cluster_size(self):
size_in_kbytes = self.cleaned_data.get("cluster_size")
if not size_in_kbytes.isdigit() and len(size_in_kbytes) > 0:
raise forms.ValidationError(_("Invalid format, you can use "
" KB or MB!"))
return int(size_in_kbytes) / 1024
class VmDiskExportForm(OperationForm):
......
......@@ -150,6 +150,9 @@ class Disk(TimeStampedModel):
cache_size = IntegerField(default=1024,
help_text=_("Disk metadata cache max size (Kbyte)"),
verbose_name=_('cache size'))
cluster_size = IntegerField(default=64,
help_text=_("Disk cluster (block) size (Kbyte)"),
verbose_name=_('cluster size'))
class Meta:
ordering = ['name']
......@@ -350,7 +353,7 @@ class Disk(TimeStampedModel):
'target_device': self.device_type + self.dev_num,
'target_bus': self.device_bus,
'disk_device': 'cdrom' if self.type == 'iso' else 'disk',
'cache_size': self.cache_size
'cache_size': self.cache_size,
}
def get_disk_desc(self):
......@@ -365,6 +368,7 @@ class Disk(TimeStampedModel):
'type': 'snapshot' if self.base else 'normal',
'cache_size': self.cache_size,
'base_dir': self.base.datastore.path if self.base else None,
'cluster_size': self.cluster_size
}
def get_remote_queue_name(self, queue_id='storage', priority=None,
......
......@@ -292,7 +292,7 @@ class CreateDiskOperation(InstanceOperation):
accept_states = ('STOPPED', 'PENDING', 'RUNNING')
concurrency_check = False
def _operation(self, user, size, activity, datastore, name=None, cache_size=1024):
def _operation(self, user, size, activity, datastore, name=None, cache_size=1024, cluster_size=64):
from storage.models import Disk
if not name:
......
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