Commit 397cb5c2 by Őry Máté

storage: fix docstrings and style

parent 451cd484
...@@ -205,7 +205,7 @@ class Disk(AclBase, TimeStampedModel): ...@@ -205,7 +205,7 @@ class Disk(AclBase, TimeStampedModel):
return None return None
def __unicode__(self): def __unicode__(self):
return u"%s (#%d)" % (self.name, self.id) return u"%s (#%d)" % (self.name, self.id or 0)
def clean(self, *args, **kwargs): def clean(self, *args, **kwargs):
if self.size == "" and self.base: if self.size == "" and self.base:
...@@ -311,11 +311,11 @@ class Disk(AclBase, TimeStampedModel): ...@@ -311,11 +311,11 @@ class Disk(AclBase, TimeStampedModel):
@classmethod @classmethod
def create_from_url_async(cls, url, instance=None, params=None, user=None): def create_from_url_async(cls, url, instance=None, params=None, user=None):
"""Create disk object and download data from url asynchronusly. """Create disk object and download data from url asynchrnously.
:param url: image url to download. :param url: URL of image to download.
:type url: url :type url: string
:param instance: instnace object to connect disk :param instance: instance object to connect disk
:type instane: vm.models.Instance :type instane: vm.models.Instance
:param params: disk custom parameters :param params: disk custom parameters
:type params: dict :type params: dict
...@@ -343,16 +343,18 @@ class Disk(AclBase, TimeStampedModel): ...@@ -343,16 +343,18 @@ class Disk(AclBase, TimeStampedModel):
:type params: dict :type params: dict
:param user: owner of the disk :param user: owner of the disk
:type user: django.contrib.auth.User :type user: django.contrib.auth.User
:param task_uuid: TODO
:param abortable_task: TODO
:return: Task :return: The created Disk object
:rtype: AsyncResult :rtype: Disk
""" """
disk = cls() disk = cls()
disk.generate_filename() disk.generate_filename()
disk.type = "iso" disk.type = "iso"
disk.size = 1 disk.size = 1
# TODO get proper datastore # TODO get proper datastore
disk.datastore = DataStore.objects.all()[0] disk.datastore = DataStore.objects.get()
if params: if params:
disk.__dict__.update(params) disk.__dict__.update(params)
disk.save() disk.save()
...@@ -388,6 +390,7 @@ class Disk(AclBase, TimeStampedModel): ...@@ -388,6 +390,7 @@ class Disk(AclBase, TimeStampedModel):
disk.size = size disk.size = size
disk.ready = True disk.ready = True
disk.save() disk.save()
return disk
def destroy(self, user=None, task_uuid=None): def destroy(self, user=None, task_uuid=None):
if self.destroyed: if self.destroyed:
...@@ -407,7 +410,7 @@ class Disk(AclBase, TimeStampedModel): ...@@ -407,7 +410,7 @@ class Disk(AclBase, TimeStampedModel):
queue='localhost.man') queue='localhost.man')
def restore(self, user=None, task_uuid=None): def restore(self, user=None, task_uuid=None):
"""Restore destroyed disk. """Recover destroyed disk from trash if possible.
""" """
# TODO # TODO
pass pass
......
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