[Kimchi-devel] [PATCH 6/8] MockModel: Extend logical storage pool

Royce Lv lvroyce at linux.vnet.ibm.com
Fri Jan 16 13:32:48 UTC 2015


On 01/13/2015 02:16 PM, Aline Manera wrote:
> Model does not use libvirt to extend the logical pool. Instead of that,
> the LVM is extended by using vgextend command.
> As in MockModel environment we don't have a LVM itself, we need to fake
> the extend operation. In that case only the pool XML is updated without
> affecting the current system.
>
> Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
> ---
>   src/kimchi/mockmodel.py | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
> index affbf42..0c8186c 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -26,6 +26,7 @@ import time
>   import kimchi.model.cpuinfo
>
>   from lxml import objectify
> +from lxml.builder import E
>
>   from kimchi import config
>   from kimchi import imageinfo
> @@ -35,6 +36,7 @@ from kimchi.model.host import DeviceModel
>   from kimchi.model.libvirtstoragepool import IscsiPoolDef, NetfsPoolDef
>   from kimchi.model.libvirtstoragepool import StoragePoolDef
>   from kimchi.model.model import Model
> +from kimchi.model.storagepools import StoragePoolModel
>   from kimchi.model.storagevolumes import StorageVolumesModel
>   from kimchi.model.templates import LibvirtVMTemplate
>   from kimchi.model.users import PAMUsersModel
> @@ -107,6 +109,7 @@ class MockModel(Model):
>                   setattr(self, m, mock_method)
>
>           DeviceModel.lookup = self._mock_device_lookup
> +        StoragePoolModel._update_lvm_disks = self._update_lvm_disks
>           StorageVolumesModel.get_list = self._mock_storagevolumes_get_list
>           DebugReportsModel._gen_debugreport_file = self._gen_debugreport_file
>           LibvirtVMTemplate._get_volume_path = self._get_volume_path
> @@ -256,6 +259,20 @@ class MockModel(Model):
>           os.rename(tmpf, realf)
>           cb("OK", True)
>
> +    def _update_lvm_disks(self, pool_name, disks):
> +        conn = self.conn.get()
> +        pool = conn.storagePoolLookupByName(pool_name.encode('utf-8'))
> +        xml = pool.XMLDesc(0)
> +
> +        root = ET.fromstring(xml)
> +        source = root.xpath('./source')[0]
> +
> +        for d in disks:
> +            dev = E.device(path=d)
> +            source.append(dev)
> +
> +        conn.storagePoolDefineXML(ET.tostring(root), 0)
Does this also work when logical storage pool status is active?
> +
>       def _mock_storagevolumes_create(self, pool, params):
>           vol_source = ['file', 'url', 'capacity']
>           index_list = list(i for i in range(len(vol_source))




More information about the Kimchi-devel mailing list