[Kimchi-devel] [PATCH 1/5] Dedicated ISO pool: create an out of box ISO pool
Sheldon
shaohef at linux.vnet.ibm.com
Tue Jun 10 10:23:32 UTC 2014
Just a minor inline comment below
On 06/10/2014 06:06 PM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> An out of box ISO pool is created to make sure user
> will find a well known place to put his ISO.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
> src/kimchi/model/model.py | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/src/kimchi/model/model.py b/src/kimchi/model/model.py
> index a766ca5..579f2d1 100644
> --- a/src/kimchi/model/model.py
> +++ b/src/kimchi/model/model.py
> @@ -24,6 +24,8 @@ import sys
>
> import cherrypy
> import libvirt
> +import lxml.etree as ET
> +from lxml.builder import E
>
> from kimchi.basemodel import BaseModel
> from kimchi.model.libvirtconnection import LibvirtConnection
> @@ -31,6 +33,9 @@ from kimchi.objectstore import ObjectStore
> from kimchi.utils import import_module, listPathModules
>
>
> +DEFAULT_POOLS = {'default': {'path': '/var/lib/libvirt/images'},
> + 'ISO': {'path': '/var/lib/libvirt/isos'}}
> +
> class Model(BaseModel):
> def __init__(self, libvirt_uri='qemu:///system', objstore_loc=None):
> self.objstore = ObjectStore(objstore_loc)
> @@ -38,7 +43,8 @@ class Model(BaseModel):
> kargs = {'objstore': self.objstore, 'conn': self.conn}
>
> if 'qemu:///' in libvirt_uri:
> - self._default_pool_check()
> + for pool_name, pool_arg in DEFAULT_POOLS.iteritems():
> + self._default_pool_check(pool_name, pool_arg)
>
> this = os.path.basename(__file__)
> this_mod = os.path.splitext(this)[0]
> @@ -57,21 +63,18 @@ class Model(BaseModel):
>
> return super(Model, self).__init__(models)
>
> - def _default_pool_check(self):
> + def _default_pool_check(self, pool_name, pool_arg):
> conn = self.conn.get()
> - xml = """
> - <pool type='dir'>
> - <name>default</name>
> - <target>
> - <path>/var/lib/libvirt/images</path>
> - </target>
> - </pool>
> - """
> + pool = E.pool(E.name(pool_name), type='dir')
> + pool.append(E.target(E.path(pool_arg['path'])))
> + xml = ET.tostring(pool)
> try:
> - pool = conn.storagePoolLookupByName("default")
> + pool = conn.storagePoolLookupByName(pool_name)
> except libvirt.libvirtError:
> try:
> pool = conn.storagePoolDefineXML(xml, 0)
> + # Add build step to make sure target directory created
> + pool.build(libvirt.VIR_STORAGE_POOL_BUILD_NEW)
> pool.setAutostart(1)
> except libvirt.libvirtError, e:
> cherrypy.log.error("Fatal: Cannot create default pool because "
can not create %s pool because, pool_name
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center
More information about the Kimchi-devel
mailing list