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:
parent
6847377d9a
commit
c39a2a996b
|
@ -822,7 +822,18 @@ class LibvirtL2NetworkDevice(network.L2NetworkDevice):
|
|||
|
||||
|
||||
class LibvirtVolume(volume.Volume):
|
||||
"""Note: This class is imported as Volume at .__init__.py """
|
||||
"""Note: This class is imported as Volume at .__init__.py
|
||||
|
||||
|
||||
For use a shared backing storage put shared_backing_store_name param while
|
||||
definig a node volume, example:
|
||||
|
||||
- name: system
|
||||
capacity: !os_env NODE_VOLUME_SIZE, 150
|
||||
shared_backing_store_name: !os_env IMAGE_NAME
|
||||
format: qcow2
|
||||
|
||||
"""
|
||||
|
||||
uuid = base.ParamField()
|
||||
capacity = base.ParamField(default=None) # in gigabytes
|
||||
|
@ -833,6 +844,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 +888,18 @@ 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}. shared_backing_store_name "
|
||||
"volume {!r} does not exists.".format(
|
||||
self.name, self.shared_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:
|
||||
|
|
Loading…
Reference in New Issue