From b830cb55443262b24a115ad7f510551236ee947a Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Tue, 21 Jun 2016 12:39:47 +0200 Subject: [PATCH] Volume add eq, neq & hash methods --- qubes/storage/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 64d97329..ebb78468 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -87,7 +87,17 @@ class Volume(object): the libvirt XML template as . ''' return qubes.devices.BlockDevice(self.path, self.name, self.script, - self.rw, self.domain, self.devtype) + self.rw, self.domain, self.devtype) # NOQA + + 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):