Commit 1cf58446 by Őry Máté

storage: clean up Disk.create_empty

parent 0a27abe6
...@@ -270,22 +270,18 @@ class Disk(AclBase, TimeStampedModel): ...@@ -270,22 +270,18 @@ class Disk(AclBase, TimeStampedModel):
self.filename = str(uuid.uuid4()) self.filename = str(uuid.uuid4())
@classmethod @classmethod
def create_empty(cls, instance=None, params=None, def create_empty(cls, instance=None, user=None, **kwargs):
user=None, task_uuid=None):
"""Create empty Disk object. """Create empty Disk object.
:param instance: instnace object to connect disk :param instance: Instance attach the Disk to.
:type instane: vm.models.Instance :type instane: vm.models.Instance or NoneType
:param params: disk custom parameters :param user: Creator of the disk.
:type params: dict
:param user: owner of the disk
:type user: django.contrib.auth.User :type user: django.contrib.auth.User
:return: Disk object without a real image, to be .deploy()ed later.
""" """
with disk_activity(code_suffix="create", task_uuid=task_uuid, with disk_activity(code_suffix="create", user=user) as act:
user=user) as act: disk = cls(**kwargs)
disk = cls()
if params:
disk.__dict__.update(params)
if disk.filename is None: if disk.filename is None:
disk.generate_filename() disk.generate_filename()
disk.save() disk.save()
......
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