storage: make Volumes sortable
But do not fetch any additional info just for this purpose.
This commit is contained in:
parent
e94bdca206
commit
a5a459840a
@ -93,6 +93,16 @@ class Volume(object):
|
|||||||
return self.pool == other.pool and self.vid == other.vid
|
return self.pool == other.pool and self.vid == other.vid
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
if isinstance(other, Volume):
|
||||||
|
if self._vm and other._vm:
|
||||||
|
return (self._vm, self._vm_name) < (other._vm, other._vm_name)
|
||||||
|
elif self._vid and other._vid:
|
||||||
|
return (self._pool, self._vid) < (other._pool, other._vid)
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
'''per-VM volume name, if available'''
|
'''per-VM volume name, if available'''
|
||||||
|
Loading…
Reference in New Issue
Block a user