Commit 38633b61 by Dudás Ádám

storage: reorder members of Disk

parent 3d29b14c
...@@ -57,6 +57,14 @@ class Disk(TimeStampedModel): ...@@ -57,6 +57,14 @@ class Disk(TimeStampedModel):
verbose_name = _('disk') verbose_name = _('disk')
verbose_name_plural = _('disks') verbose_name_plural = _('disks')
class WrongDiskTypeError(Exception):
def __init__(self, type):
self.type = type
def __str__(self):
return ("Operation can't be invoked on a disk of type '%s'." %
self.type)
@property @property
def path(self): def path(self):
return self.datastore.path + '/' + self.filename return self.datastore.path + '/' + self.filename
...@@ -71,13 +79,13 @@ class Disk(TimeStampedModel): ...@@ -71,13 +79,13 @@ class Disk(TimeStampedModel):
'raw-rw': 'raw', 'raw-rw': 'raw',
}[self.type] }[self.type]
class WrongDiskTypeError(Exception): @property
def __init__(self, type): def device_type(self):
self.type = type return {
'qcow2': 'vd',
def __str__(self): 'raw': 'vd',
return ("Operation can't be invoked on a disk of type '%s'." % 'iso': 'hd',
self.type) }[self.format]
def get_exclusive(self): def get_exclusive(self):
"""Get an instance of the disk for exclusive usage. """Get an instance of the disk for exclusive usage.
...@@ -96,14 +104,6 @@ class Disk(TimeStampedModel): ...@@ -96,14 +104,6 @@ class Disk(TimeStampedModel):
filename=filename, name=self.name, filename=filename, name=self.name,
size=self.size, type=new_type) size=self.size, type=new_type)
@property
def device_type(self):
return {
'qcow2': 'vd',
'raw': 'vd',
'iso': 'hd',
}[self.format]
def get_vmdisk_desc(self): def get_vmdisk_desc(self):
return { return {
'source': self.path, 'source': self.path,
......
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