Add shared backing storage

If user has already defined volume in pool it can be used as
    backing storage for node disk.

        - name: system
          capacity: !os_env NODE_VOLUME_SIZE, 150
          shared_backing_store_name: !os_env IMAGE_NAME
          format: qcow2

Change-Id: Ib1ec1daf74d9bd2c78288cc507e4b32c7233ef3d
This commit is contained in:
Dmitry Tyzhnenko 2017-12-05 19:32:15 +02:00
parent e115ef4bd4
commit 6efd120a5e
1 changed files with 12 additions and 0 deletions

View File

@ -833,6 +833,7 @@ class LibvirtVolume(volume.Volume):
multipath_count = base.ParamField(default=0)
cloudinit_meta_data = base.ParamField(default=None)
cloudinit_user_data = base.ParamField(default=None)
shared_backing_store_name = base.ParamField(default=None)
@property
@decorators.retry(libvirt.libvirtError)
@ -876,6 +877,17 @@ class LibvirtVolume(volume.Volume):
"not exists.".format(self.name, self.backing_store.name))
backing_store_path = self.backing_store.get_path()
backing_store_format = self.backing_store.format
elif self.shared_backing_store_name:
b_pool = self.driver.conn.storagePoolLookupByName(
self.driver.storage_pool_name)
if self.shared_backing_store_name not in b_pool.listVolumes():
raise error.DevopsError(
"Can't create volume {!r}. backing_store volume {!r} does "
"not exists.".format(self.name, self.backing_store.name))
b_vol = next(v for v in b_pool.listAllVolumes()
if v.name() == self.shared_backing_store_name)
backing_store_path = b_vol.path()
backing_store_format = self.format
# Select capacity
if self.capacity: