Commit 8dc295a5 by Kálmán Viktor

dashboard: resize request only for resizable disks

parent 747fd41c
......@@ -12,10 +12,12 @@
{% if op.resize_disk.disabled %}disabled{% endif %}">
<i class="fa fa-{{ op.resize_disk.icon }} fa-fw-12"></i> {% trans "Resize" %}
</a>
{% else %}
{% elif d.is_resizable %}
<a href="{% url "request.views.request-resize" vm_pk=instance.pk disk_pk=d.pk %}" class="btn btn-xs btn-primary operation">
<i class="fa fa-arrows-alt fa-fw-12"></i> {% trans "Request resize" %}
</a>
{% else %}
<small class="text-muted">{% trans "Cannot be resized" %}</small>
{% endif %}
{% if op.remove_disk %}
<a href="{{ op.remove_disk.get_url }}?disk={{d.pk}}"
......
{% spaceless %}
{% if LANGUAGE_CODE == "en" %}
Why do you need bigger disk?
Why do you need a bigger disk?
{% else %} {# place your translations here #}
Why do you need bigger disk?
Why do you need a bigger disk?
{% endif %}
{% endspaceless %}
......@@ -327,8 +327,11 @@ class ResizeRequestView(VmRequestMixin, FormView):
return context
def form_valid(self, form):
vm = self.get_vm()
disk = self.get_disk()
if not disk.is_resizable:
raise SuspiciousOperation
vm = self.get_vm()
data = form.cleaned_data
user = self.request.user
......
......@@ -539,3 +539,7 @@ class Disk(TimeStampedModel):
def get_absolute_url(self):
return reverse('dashboard.views.disk-detail', kwargs={'pk': self.pk})
@property
def is_resizable(self):
return self.type in ('qcow2-norm', 'raw-rw')
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