From f08ce2cb79b5fbaddf1ecb60a4b60432062440da Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Mon, 6 Jun 2016 18:01:46 +0200 Subject: [PATCH] A Pool should always have a volumes property NOTE: FilesPool need some way to dynamically discover volumes --- qubes/storage/__init__.py | 6 ++++++ qubes/storage/file.py | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index c8d1305e..d98d56c4 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -294,6 +294,12 @@ class Pool(object): raise NotImplementedError("Pool %s has verify() not implemented" % self.name) + @property + def volumes(self): + ''' Return a list of volumes managed by this pool ''' + raise NotImplementedError("Pool %s has volumes() not implemented" % + self.name) + def pool_drivers(): """ Return a list of EntryPoints names """ diff --git a/qubes/storage/file.py b/qubes/storage/file.py index d9e41eea..a7e9c33a 100644 --- a/qubes/storage/file.py +++ b/qubes/storage/file.py @@ -46,6 +46,7 @@ class FilePool(Pool): super(FilePool, self).__init__(name=name) assert dir_path, "No pool dir_path specified" self.dir_path = os.path.normpath(dir_path) + self._volumes = [] def clone(self, source, target): ''' Clones the volume if the `source.pool` if the source is a @@ -259,13 +260,16 @@ class FilePool(Pool): else: volume_config['target_dir'] = self.target_dir(vm) - return known_types[volume_type](**volume_config) + volume = known_types[volume_type](**volume_config) + self._volumes += [volume] + return volume def verify(self, volume): return volume.verify() - def verify(self, volume): - return volume.verify() + @property + def volumes(self): + return self._volumes class FileVolume(Volume):