Add Volume.eq, neq and hash

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2016-04-27 21:51:40 +02:00
parent f08ce2cb79
commit 07800a0e67
No known key found for this signature in database
GPG Key ID: 96ED3C3BA19C3DEE

View File

@ -30,13 +30,12 @@ from __future__ import absolute_import
import os
import os.path
import pkg_resources
import lxml.etree
import pkg_resources
import qubes
import qubes.devices
import qubes.exc
import qubes.utils
import qubes.devices
STORAGE_ENTRY_POINT = 'qubes.storage'
@ -89,6 +88,16 @@ class Volume(object):
return qubes.devices.BlockDevice(self.path, self.name, self.script,
self.rw, self.domain, self.devtype)
def __eq__(self, other):
return other.pool == self.pool and other.vid == self.vid \
and other.volume_type == self.volume_type
def __neq__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash('%s:%s %s' % (self.pool, self.vid, self.volume_type))
class Storage(object):
''' Class for handling VM virtual disks.