Commit 20af2315 by Karsa Zoltán István

update view and forms

parent f056e0a0
...@@ -643,6 +643,7 @@ class TemplateForm(forms.ModelForm): ...@@ -643,6 +643,7 @@ class TemplateForm(forms.ModelForm):
widgets = { widgets = {
'system': forms.TextInput, 'system': forms.TextInput,
'max_ram_size': forms.HiddenInput, 'max_ram_size': forms.HiddenInput,
'num_cores_max': forms.HiddenInput,
'parent': forms.Select(attrs={'disabled': ""}), 'parent': forms.Select(attrs={'disabled': ""}),
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<legend>{% trans "Resource configuration" %}</legend> <legend>{% trans "Resource configuration" %}</legend>
{% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %} {% include "dashboard/_resources-sliders.html" with field_priority=form.priority field_num_cores=form.num_cores field_ram_size=form.ram_size %}
{{ form.max_ram_size|as_crispy_field }} {{ form.max_ram_size|as_crispy_field }}
{{ form.num_cores_max|as_crispy_field }}
</fieldset> </fieldset>
<fieldset> <fieldset>
......
...@@ -49,16 +49,16 @@ class BaseResourceConfigModel(Model): ...@@ -49,16 +49,16 @@ class BaseResourceConfigModel(Model):
help_text=_('Number of virtual CPU cores ' help_text=_('Number of virtual CPU cores '
'available to the virtual machine.'), 'available to the virtual machine.'),
validators=[MinValueValidator(0)]) validators=[MinValueValidator(0)])
num_cores_max = IntegerField(verbose_name=_('number of cores'), num_cores_max = IntegerField(verbose_name=_('number of max cores'),
help_text=_('Number of max virtual CPU cores ' help_text=_('Number of max virtual CPU cores '
'available to the virtual machine.'), 'available to the virtual machine (for hotplug).'),
validators=[MinValueValidator(0)], default=0) validators=[MinValueValidator(0)], default=0)
ram_size = IntegerField(verbose_name=_('RAM size'), ram_size = IntegerField(verbose_name=_('RAM size'),
help_text=_('Mebibytes of memory.'), help_text=_('Mebibytes of memory.'),
validators=[MinValueValidator(0)]) validators=[MinValueValidator(0)])
max_ram_size = IntegerField(verbose_name=_('maximal RAM size'), max_ram_size = IntegerField(verbose_name=_('maximal RAM size'),
help_text=_('Upper memory size limit ' help_text=_('Upper memory size limit '
'for balloning.'), 'for balloning (or hotplug).'),
validators=[MinValueValidator(0)]) validators=[MinValueValidator(0)])
arch = CharField(max_length=10, verbose_name=_('architecture'), arch = CharField(max_length=10, verbose_name=_('architecture'),
choices=ARCHITECTURES) choices=ARCHITECTURES)
......
...@@ -1462,13 +1462,16 @@ class HotPlugMem(RemoteInstanceOperation): ...@@ -1462,13 +1462,16 @@ class HotPlugMem(RemoteInstanceOperation):
name = _("hotplug_mem") name = _("hotplug_mem")
description = _("") description = _("")
acl_level = "owner" acl_level = "owner"
required_perms = () required_perms = ('vm.change_resources',)
accept_states = ('RUNNING',) accept_states = ('RUNNING',)
task = vm_tasks.hotplug_memset task = vm_tasks.hotplug_memset
def _get_remote_args(self, **kwargs): def _get_remote_args(self, **kwargs):
return (super(HotPlugMem, self)._get_remote_args(**kwargs) + [kwargs["memory"]] ) return (super(HotPlugMem, self)._get_remote_args(**kwargs) + [kwargs["memory"]] )
def _operation(self, **kwargs):
super()._operation(**kwargs)
return create_readable(ugettext_noop("Hotplug memory: set to %(mem)sKb"), mem=kwargs["memory"])
@register_operation @register_operation
class HotPlugVCPU(RemoteInstanceOperation): class HotPlugVCPU(RemoteInstanceOperation):
...@@ -1476,13 +1479,17 @@ class HotPlugVCPU(RemoteInstanceOperation): ...@@ -1476,13 +1479,17 @@ class HotPlugVCPU(RemoteInstanceOperation):
name = _("hotplug_vcpu") name = _("hotplug_vcpu")
description = _("") description = _("")
acl_level = "owner" acl_level = "owner"
required_perms = () required_perms = ('vm.change_resources',)
accept_states = ('RUNNING',) accept_states = ('RUNNING',)
task = vm_tasks.hotplug_vcpuset task = vm_tasks.hotplug_vcpuset
def _get_remote_args(self, **kwargs): def _get_remote_args(self, **kwargs):
return (super(HotPlugVCPU, self)._get_remote_args(**kwargs) + [kwargs["vcpu"]] ) return (super(HotPlugVCPU, self)._get_remote_args(**kwargs) + [kwargs["vcpu"]] )
def _operation(self, **kwargs):
super()._operation(**kwargs)
return create_readable(ugettext_noop("Hotplug vcpu: set to %(vcpu)s"), vcpu=kwargs["vcpu"])
@register_operation @register_operation
class RecoverOperation(InstanceOperation): class RecoverOperation(InstanceOperation):
...@@ -1576,7 +1583,7 @@ class ResourcesOperation(InstanceOperation): ...@@ -1576,7 +1583,7 @@ class ResourcesOperation(InstanceOperation):
accept_states = ('STOPPED', 'PENDING', 'RUNNING') accept_states = ('STOPPED', 'PENDING', 'RUNNING')
def _operation(self, user, activity, def _operation(self, user, activity,
num_cores, ram_size, max_ram_size, priority, num_cores, ram_size, priority,
with_shutdown=False, task=None): with_shutdown=False, task=None):
if self.instance.status == 'RUNNING' and not with_shutdown: if self.instance.status == 'RUNNING' and not with_shutdown:
raise Instance.WrongStateError(self.instance) raise Instance.WrongStateError(self.instance)
...@@ -1590,7 +1597,6 @@ class ResourcesOperation(InstanceOperation): ...@@ -1590,7 +1597,6 @@ class ResourcesOperation(InstanceOperation):
self.instance.num_cores = num_cores self.instance.num_cores = num_cores
self.instance.ram_size = ram_size self.instance.ram_size = ram_size
self.instance.max_ram_size = max_ram_size
self.instance.priority = priority self.instance.priority = priority
self.instance.full_clean() self.instance.full_clean()
......
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