A Pool should always have a volumes property

NOTE: FilesPool need some way to dynamically discover volumes
This commit is contained in:
Bahtiar `kalkin-` Gadimov 2016-06-06 18:01:46 +02:00
parent 88198fb7ac
commit f08ce2cb79
No known key found for this signature in database
GPG Key ID: 96ED3C3BA19C3DEE
2 changed files with 13 additions and 3 deletions

View File

@ -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 """

View File

@ -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):