From 07800a0e675e14fc06e2d2bd1167fa513a9d4039 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Wed, 27 Apr 2016 21:51:40 +0200 Subject: [PATCH] Add Volume.eq, neq and hash --- qubes/storage/__init__.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index d98d56c4..5b0505f0 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -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.