Commit 3eb04d1b by Karsa Zoltán István

cluster size

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