Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

CIRCLE / cloud

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 94
  • Merge Requests 10
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Merged
Merge request !213 opened Sep 23, 2014 by Guba Sándor@gubasandor 
  • Report abuse
Report abuse

Feature Resize Disk

Resize disk image on a running virtual machine.

  • Discussion 14
  • Commits 17
  • Changes
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Őry Máté
    @orymate started a discussion on commit 9958e0cb Sep 23, 2014
    circle/dashboard/forms.py
    809 809 queryset=choices, initial=default, required=True,
    810 810 empty_label=None, label=_('Disk')))
    811 811  
    812 def clean_size(self):
    812 def clean(self):
    813 cleaned_data = super(VmDiskResizeForm, self).clean()
    813 814 size_in_bytes = self.cleaned_data.get("size")
    815 disk = self.cleaned_data.get('disk')
    814 816 if not size_in_bytes.isdigit() and len(size_in_bytes) > 0:
    815 817 raise forms.ValidationError(_("Invalid format, you can use "
    816 818 " GB or MB!"))
    817 return size_in_bytes
    819 if float(size_in_bytes) < float(disk.size):
    • Őry Máté @orymate commented Sep 23, 2014
      Owner

      what about int? (aed52db7)

      Edited Sep 24, 2014
      ~~what about int?~~ (aed52db71)
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    Last updated by Guba Sándor Sep 24, 2014
    circle/vm/operations.py
    208 208 register_operation(CreateDiskOperation)
    209 209  
    210 210  
    211 class ResizeDiskOperation(InstanceOperation):
    212
    213 activity_code_suffix = 'resize_disk'
    214 id = 'resize_disk'
    215 name = _("resize disk")
    216 description = _("Resize the virtual disk image. "
    217 "Size must be greater value than the actual size.")
    218 required_perms = ('vm.resize_disk', )
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner
      diff --git a/circle/storage/models.py b/circle/storage/models.py
      index 8345532..ca78d40 100644
      --- a/circle/storage/models.py
      +++ b/circle/storage/models.py
      @@ -104,6 +104,7 @@ class Disk(TimeStampedModel):
               verbose_name_plural = _('disks')
               permissions = (
                   ('create_empty_disk', _('Can create an empty disk.')),
      +            ('resize_disk', _('Can resize a disk.')),
                   ('download_disk', _('Can download a disk.')))
      
           class DiskError(HumanReadableException):
      diff --git a/circle/vm/operations.py b/circle/vm/operations.py
      index eb9def6..0cb4310 100644
      --- a/circle/vm/operations.py
      +++ b/circle/vm/operations.py
      @@ -215,7 +215,7 @@ class ResizeDiskOperation(InstanceOperation):
           name = _("resize disk")
           description = _("Resize the virtual disk image. "
                           "Size must be greater value than the actual size.")
      -    required_perms = ('vm.resize_disk', )
      +    required_perms = ('storage.resize_disk', )
           accept_states = ('RUNNING', )
           async_queue = "localhost.man.slow"
      
      ```diff diff --git a/circle/storage/models.py b/circle/storage/models.py index 8345532..ca78d40 100644 --- a/circle/storage/models.py +++ b/circle/storage/models.py @@ -104,6 +104,7 @@ class Disk(TimeStampedModel): verbose_name_plural = _('disks') permissions = ( ('create_empty_disk', _('Can create an empty disk.')), + ('resize_disk', _('Can resize a disk.')), ('download_disk', _('Can download a disk.'))) class DiskError(HumanReadableException): diff --git a/circle/vm/operations.py b/circle/vm/operations.py index eb9def6..0cb4310 100644 --- a/circle/vm/operations.py +++ b/circle/vm/operations.py @@ -215,7 +215,7 @@ class ResizeDiskOperation(InstanceOperation): name = _("resize disk") description = _("Resize the virtual disk image. " "Size must be greater value than the actual size.") - required_perms = ('vm.resize_disk', ) + required_perms = ('storage.resize_disk', ) accept_states = ('RUNNING', ) async_queue = "localhost.man.slow" ```
    • Guba Sándor @gubasandor commented Sep 24, 2014
      Owner

      fixed

      fixed
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    Last updated by Guba Sándor Sep 24, 2014
    circle/dashboard/templates/dashboard/_disk-list-element.html
    17 17 >
    18 18 <i class="fa fa-times"></i>{% if long_remove %} {% trans "Remove" %}{% endif %}
    19 19 </a>
    20 <span class="operation-wrapper">
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      {% if op.resize_disk %}

      {% if op.resize_disk %}
    • Guba Sándor @gubasandor commented Sep 24, 2014
      Owner

      fixed

      fixed
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on commit aed52db7 Sep 24, 2014
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    Last updated by Guba Sándor Sep 24, 2014
    circle/vm/models/instance.py
    790 790 else:
    791 791 raise
    792 792  
    793 def resize_disk_live(self, disk, size, timeout=15):
    794 try:
    795 queue_name = self.get_remote_queue_name('vm', 'slow')
    796 return vm_tasks.resize_disk.apply_async(
    797 args=[self.vm_name, disk.path, size],
    798 queue=queue_name).get(timeout=timeout)
    799 except:
    800 raise
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      ~~💻 🐕 ~~ 7a0b8d2

      Edited Sep 24, 2014
      ~~:computer: :dog2: ~~ 7a0b8d2
    • Guba Sándor @gubasandor commented Sep 24, 2014
      Owner

      🐈

      :cat2:
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on the diff Sep 24, 2014
    circle/vm/models/instance.py
    790 790 else:
    791 791 raise
    792 792  
    793 def resize_disk_live(self, disk, size, timeout=15):
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      move this to the actual operation. this is anyways a private (protected) method. #304 (closed)

      Edited Sep 24, 2014
      ~~move this to the actual operation. this is anyways a private (protected) method.~~ #304
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    Last updated by Guba Sándor Sep 24, 2014
    circle/vm/operations.py
    208 208 register_operation(CreateDiskOperation)
    209 209  
    210 210  
    211 class ResizeDiskOperation(InstanceOperation):
    212
    213 activity_code_suffix = 'resize_disk'
    214 id = 'resize_disk'
    215 name = _("resize disk")
    216 description = _("Resize the virtual disk image. "
    217 "Size must be greater value than the actual size.")
    218 required_perms = ('storage.resize_disk', )
    219 accept_states = ('RUNNING', )
    220 async_queue = "localhost.man.slow"
    221
    222 def _operation(self, user, disk, size, activity):
    223 if self.instance.is_running:
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      accept_states ensures this 8f929b5

      Edited Sep 24, 2014
      ~~accept_states ensures this~~ 8f929b5
    • Guba Sándor @gubasandor commented Sep 24, 2014
      Owner

      condition for the future offline resize

      condition for the future offline resize
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    circle/dashboard/views/vm.py
    368 class VmDiskResizeView(FormOperationMixin, VmOperationView):
    369
    370 op = 'resize_disk'
    371 form_class = VmDiskResizeForm
    372 show_in_toolbar = False
    373 icon = 'arrows-alt'
    374 effect = "success"
    375
    376 def get_form_kwargs(self):
    377 choices = self.get_op().instance.disks
    378 disk_pk = self.request.GET.get('disk')
    379 if disk_pk:
    380 try:
    381 default = choices.get(pk=disk_pk)
    382 except (ValueError, Disk.DoesNotExist):
    383 raise SuspiciousOperation()
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      404 a237f57

      Edited Sep 24, 2014
      ~~404~~ a237f57
    Please register or sign in to reply
  • Bach Dániel
    @bachdaniel started a discussion on an old version of the diff Sep 24, 2014
    circle/dashboard/views/vm.py
    370 op = 'resize_disk'
    371 form_class = VmDiskResizeForm
    372 show_in_toolbar = False
    373 icon = 'arrows-alt'
    374 effect = "success"
    375
    376 def get_form_kwargs(self):
    377 choices = self.get_op().instance.disks
    378 disk_pk = self.request.GET.get('disk')
    379 if disk_pk:
    380 try:
    381 default = choices.get(pk=disk_pk)
    382 except (ValueError, Disk.DoesNotExist):
    383 raise SuspiciousOperation()
    384 else:
    385 raise SuspiciousOperation()
    • Bach Dániel @bachdaniel commented Sep 24, 2014
      Owner

      none (no initial) a237f57

      Edited Sep 24, 2014
      ~~none (no initial)~~ a237f57
    Please register or sign in to reply
  • Bach Dániel @bachdaniel commented Sep 24, 2014
    Owner

    +1

    +1
  • Bach Dániel
    @bachdaniel started a discussion on commit a27aafa6 Sep 25, 2014
    circle/vm/models/instance.py
    791 791 raise
    792 792  
    793 793 def resize_disk_live(self, disk, size, timeout=15):
    794 try:
    795 queue_name = self.get_remote_queue_name('vm', 'slow')
    796 return vm_tasks.resize_disk.apply_async(
    • Bach Dániel @bachdaniel commented Sep 25, 2014
      Owner

      💻 🐕

      Edited Sep 25, 2014
      :computer: :dog2:
    Please register or sign in to reply
  • Write
  • Preview
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
Őry Máté
Assignee
Őry Máté @orymate
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View labels
3
3 participants
Reference: circle/cloud!213