Commit b81542de by Karsa Zoltán István

metadata cache update

parent 82fee5fc
......@@ -92,12 +92,15 @@ class VmSaveForm(OperationForm):
help_text=_('Human readable name of template.'))
datastore = forms.ModelChoiceField(queryset=None, initial=0, empty_label=None,
help_text=_('Backing file location'))
overlay_path = forms.ModelChoiceField(queryset=None, initial=0, empty_label=None,
help_text=_('Overlay image dir'))
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', None)
clone = kwargs.pop('clone', False)
super(VmSaveForm, self).__init__(*args, **kwargs)
self.fields['datastore'].queryset = DataStore.objects.all()
self.fields['overlay_path'].queryset = DataStore.objects.all()
if default:
self.fields['name'].initial = default
if clone:
......@@ -856,6 +859,10 @@ class VmCreateDiskForm(OperationForm):
help_text=_('Size of disk to create in bytes or with units '
'like MB or GB.'))
datastore = forms.ModelChoiceField(queryset=None, initial=0, empty_label=None)
cache_size = forms.CharField(
widget=FileSizeWidget, initial=(1 << 20), label=_('Metadata cache size'),
help_text=_('Metadata cache size, '
'like KB, MB'))
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', None)
......@@ -871,6 +878,13 @@ class VmCreateDiskForm(OperationForm):
" GB or MB!"))
return size_in_bytes
def clean_cache_size(self):
size_in_kbytes = self.cleaned_data.get("cache_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):
exported_name = forms.CharField(max_length=100, label=_('Filename'))
......
......@@ -363,7 +363,8 @@ class Disk(TimeStampedModel):
'size': self.size,
'base_name': self.base.filename if self.base else None,
'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,
}
def get_remote_queue_name(self, queue_id='storage', priority=None,
......
......@@ -292,12 +292,12 @@ class CreateDiskOperation(InstanceOperation):
accept_states = ('STOPPED', 'PENDING', 'RUNNING')
concurrency_check = False
def _operation(self, user, size, activity, datastore, name=None):
def _operation(self, user, size, activity, datastore, name=None, cache_size=1024):
from storage.models import Disk
if not name:
name = "new disk"
disk = Disk.create(size=size, name=name, datastore=datastore.name, type="qcow2-norm")
disk = Disk.create(size=size, name=name, datastore=datastore.name, type="qcow2-norm", cache_size=cache_size)
disk.full_clean()
devnums = list(ascii_lowercase)
for d in self.instance.disks.all():
......
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