[project-kimchi] [PATCH 0/3 V2] Logical pool fixes
by Aline Manera
From: Aline Manera <alinefm(a)br.ibm.com>
V1 -> V2:
- Get device name from sysfs uevent file and assume its path is /dev/<devname>
Zhou Zheng Sheng (3):
PEP 8: cleanup src/kimchi/disks.py
Issue #276: logical pool: a quick fix for the device listing rules,
back-end
Issue #276, logical pool: a quick fix for the device listing rules,
front-end
Makefile.am | 1 +
src/kimchi/disks.py | 177 ++++++++++++++++--------------
ui/js/src/kimchi.storagepool_add_main.js | 2 +-
3 files changed, 94 insertions(+), 86 deletions(-)
--
1.7.10.4
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
[project-kimchi] [PATCH] logical pool fixes: only list leaf devices, and read file instead of run "cat"
by Zhou Zheng Sheng
Some devices are parent of other devices. We should just list the leaf
devices but not parent devices. For example, if a disk contains
partitions, we should only list the partitions. If a disk is held by
multipath device, we should not list the disk.
Currently we strip the last charactter from "vda1" to get "vda" and
ignore the parent "vda" device. This may fails on disk contains lots of
logical partitions, for example "vda10"'s parent is not "vda1". Another
problem is this method can not find the parent-child relation ship
between a multipath device and its slaves.
The most accurate information is on sysfs, and lsblk lists all children
device of the requested device based on sysfs. So when "lsblk -P
devices" prints only one line, it's the device itself, when it prints
more lines, they are the children devices. This patch use this method to
detect if a device a leaf one.
This patch also avoids start new "cat" process to read uevent file, it
opens the uevent file and read it directly.
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
src/kimchi/disks.py | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py
index 991bb4a..9ab9263 100644
--- a/src/kimchi/disks.py
+++ b/src/kimchi/disks.py
@@ -29,7 +29,6 @@ from kimchi.utils import kimchi_log
def _get_partition_path(name):
""" Returns device path given a partition name """
- dev_path = None
maj_min = None
keys = ["NAME", "MAJ:MIN"]
@@ -39,15 +38,14 @@ def _get_partition_path(name):
if dev['name'] == name:
maj_min = dev['maj:min']
break
+ else:
+ raise OperationFailed(
+ "Failed to find major and minor number for %s", name)
- uevent_cmd = "cat /sys/dev/block/%s/uevent" % maj_min
- uevent = subprocess.Popen(uevent_cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, shell=True)
- out, err = uevent.communicate()
- if uevent.returncode != 0:
- raise OperationFailed("Error getting partition path for %s", name)
+ with open("/sys/dev/block/%s/uevent" % maj_min) as ueventf:
+ content = ueventf.read()
- data = dict(re.findall(r'(\S+)=(".*?"|\S+)', out.replace("\n", " ")))
+ data = dict(re.findall(r'(\S+)=(".*?"|\S+)', content.replace("\n", " ")))
return "/dev/%s" % data["DEVNAME"]
@@ -63,6 +61,22 @@ def _get_lsblk_devs(keys, devs=[]):
return _parse_lsblk_output(out, keys)
+def _is_dev_leaf(name):
+ try:
+ # By default, lsblk prints a device information followed by children
+ # device information
+ childrenCount = len(
+ _get_lsblk_devs(["NAME"], [_get_partition_path(name)])) - 1
+ except OperationFailed as e:
+ # lsblk is known to fail on multipath devices
+ # Assume these devices contain children
+ kimchi_log.error(
+ "Error getting device info for %s: %s", (name, e))
+ return False
+ else:
+ return childrenCount == 0
+
+
def _parse_lsblk_output(output, keys):
# output is on format key="value",
# where key can be NAME, TYPE, FSTYPE, SIZE, MOUNTPOINT, etc
@@ -82,7 +96,6 @@ def _parse_lsblk_output(output, keys):
def get_partitions_names():
names = []
- ignore_names = []
keys = ["NAME", "TYPE", "FSTYPE", "MOUNTPOINT"]
# output is on format key="value",
# where key can be NAME, TYPE, FSTYPE, MOUNTPOINT
@@ -90,20 +103,18 @@ def get_partitions_names():
# split()[0] to avoid the second part of the name, after the
# whiteline
name = dev['name'].split()[0]
- # Only list unmounted and unformated partition or disk.
+ # Only list unmounted and unformated and leaf and (partition or disk)
+ # leaf means a partition, a disk has no partition, or a disk not held
+ # by any multipath device.
if not all([dev['type'] in ['part', 'disk'],
dev['fstype'] == "",
- dev['mountpoint'] == ""]):
-
- # the whole disk must be ignored in it has at least one
- # mounted/formatted partition
- if dev['type'] == 'part':
- ignore_names.append(name[:-1])
+ dev['mountpoint'] == "",
+ _is_dev_leaf(name)]):
continue
names.append(name)
- return list(set(names) - set(ignore_names))
+ return names
def get_partition_details(name):
--
1.7.11.7
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
Re: [Kimchi-devel] [project-kimchi] [PATCH v1 4/4] storagepool: Support Creating iSCSI storagepool in model.py
by Sheldon
On 12/16/2013 04:01 PM, Zhou Zheng Sheng wrote:
> This patch implements creating iSCSI storagepool for libvirt.
> Each LUN in iSCSI storagepool can be used as a volume, but iSCSI
> storagepool does not provide ability to create volume. For now in kimchi
> we create volume for each newly created VM. Next is to implement
> attaching existing volume to a new VM.
>
> How to test
>
> Create:
> curl -u root -H 'Content-type: application/json' \
> -H 'Accept: application/json' \
> -d '{"srcTarget":
> "targetIQN",
> "srcHost": "10.0.0.X",
> "type": "iscsi",
> "name": "iscsipool"}' \
> http://127.0.0.1:8000/storagepools
>
> Show Info:
> curl -u root -H 'Accept: application/json' \
> http://127.0.0.1:8000/storagepools/iscsipool
>
> Activate:
> curl -u root -H 'Content-type: application/json' \
> -H 'Accept: application/json' \
> -d '' http://127.0.0.1:8000/storagepools/iscsipool/activate
>
> Examine:
> iscsiadm -m session
>
> Deactivate:
> curl -u root -H 'Content-type: application/json' \
> -H 'Accept: application/json' \
> -d '' http://127.0.0.1:8000/storagepools/iscsipool/deactivate
>
> Delete:
> curl -u root -X DELETE -H 'Accept: application/json' \
> http://127.0.0.1:8000/storagepools/iscsipool
>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
> ---
> docs/API.md | 6 ++++--
> src/kimchi/model.py | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+), 2 deletions(-)
>
> diff --git a/docs/API.md b/docs/API.md
> index dd3d7f1..342c583 100644
> --- a/docs/API.md
> +++ b/docs/API.md
> @@ -182,16 +182,18 @@ Represents a snapshot of the Virtual Machine's primary monitor.
> * **POST**: Create a new Storage Pool
> * name: The name of the Storage Pool.
> * type: The type of the defined Storage Pool.
> - Supported types: 'dir', 'kimchi-iso', 'netfs', 'logical'
> + Supported types: 'dir', 'kimchi-iso', 'netfs', 'logical', 'iscsi'
> * path: The path of the defined Storage Pool.
> For 'kimchi-iso' pool refers to targeted deep scan path.
> Pool types: 'dir', 'kimchi-iso'.
> * srcHost: IP or hostname of server for a pool backed from a remote host.
> - Pool types: 'nfs'.
> + Pool types: 'nfs', 'iscsi'.
> * srcPath: Export path on NFS server for NFS pool.
> Pool types: 'nfs'.
> * srcDevices: Array of devices to be used in the Storage Pool
> Pool types: 'logical'.
> + * srcTarget: Target IQN of an iSCSI pool.
> + Pool types: 'iscsi'.
>
> ### Resource: Storage Pool
>
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index af0d728..3888903 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -1475,11 +1475,45 @@ def _get_logical_storagepool_xml(poolArgs):
> return xml
>
>
> +def _get_iscsi_storagepool_xml(poolArgs):
> + # Required parameters
> + # name:
> + # type:
> + # srcHost:
> + # srcTarget:
> + #
> + # Optional parameters
> + # srcPort:
> +
> + try:
> + portAttr = "port='%s'" % poolArgs['srcPort']
> + except KeyError:
> + portAttr = ""
> +
> + poolArgs.update({'srcPort': portAttr,
> + 'path': '/dev/disk/by-id'})
> +
> + xml = """
> + <pool type='%(type)s'>
> + <name>%(name)s</name>
> + <source>
> + <host name='%(srcHost)s' %(srcPort)s/>
> + <device path='%(srcTarget)s'/>
> + </source>
> + <target>
> + <path>%(path)s</path>
> + </target>
> + </pool>
> + """ % poolArgs
> + return xml
> +
> +
http://libvirt.org/formatstorage.html#exampleISCSI
iSCSI based storage pool
<pool type="iscsi">
<name>virtimages</name>
<source>
<host name="iscsi.example.com"/>
<device path="iqn.2013-06.com.example:iscsi-pool"/>
<auth type='chap' username='myuser'>
<secret usage='libvirtiscsi'/>
</auth>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
auth tag?
> def _get_pool_xml(**kwargs):
> getPoolXml = {
> 'dir': _get_dir_storagepool_xml,
> 'netfs': _get_netfs_storagepool_xml,
> 'logical': _get_logical_storagepool_xml,
> + 'iscsi': _get_iscsi_storagepool_xml,
> }[kwargs['type']]
> return getPoolXml(kwargs)
>
Sheldon Feng(???)
IBM Linux Technology Center
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
Re: [Kimchi-devel] [project-kimchi] [PATCH] spec: Open 8000 and 8001 port by default in spec.in post section. kimchi server use 8000 and 8001 port. Open 8000 and 8001 port by default in spec.in post section.
by Mark Wu
On 12/17/2013 02:36 PM, taget(a)linux.vnet.ibm.com wrote:
> From: Eli Qiao <taget(a)linux.vnet.ibm.com>
>
> Signed-off-by: Eli Qiao <taget(a)linux.vnet.ibm.com>
> ---
> contrib/kimchi.spec.fedora.in | 5 +++++
> contrib/kimchi.spec.suse.in | 5 +++++
> 2 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
> index 14ec359..f21ae49 100644
> --- a/contrib/kimchi.spec.fedora.in
> +++ b/contrib/kimchi.spec.fedora.in
> @@ -81,6 +81,11 @@ if [ $1 -eq 1 ] ; then
> /bin/systemctl daemon-reload >/dev/null 2>&1 || :
> fi
>
> +# open 8000 and 8001 port for firewall
> +
> +iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
> +iptables -I INPUT -p tcp --dport 8001 -j ACCEPT
> +
> %if 0%{?rhel} == 6
> start kimchid
> %else
> diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
> index 9051284..5209e03 100644
> --- a/contrib/kimchi.spec.suse.in
> +++ b/contrib/kimchi.spec.suse.in
> @@ -47,6 +47,11 @@ install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid
> service kimchid start
> chkconfig kimchid on
>
> +# open 8000 and 8001 port for firewall
> +
> +iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
> +iptables -I INPUT -p tcp --dport 8001 -j ACCEPT
> +
> %preun
> service kimchid stop
>
Eli,
Thanks for the patch. But it's not a reliable configuration. This rule
will be lost after reboot.
And shipping a configuration file is better than running commands in
spec file.
Please take a look at firewalld and firewalld.service
http://manpages.ubuntu.com/manpages/raring/man5/firewalld.service.5.html
It could be a better solution for the platforms where firewalld is
available.
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
[project-kimchi] Re: [PATCH v1 1/4] storagepool: dispatch _get_pool_xml() to respective _get_XXX_storagepool_xml() function
by Sheldon
As Pradeep mentioned:
we will add more storage pools, how about split these xml to a new file?
On 12/16/2013 04:01 PM, Zhou Zheng Sheng wrote:
> In src/kimchi/model.py, _get_pool_xml() is to generate libvirt storage
> pool XML definition from arguments provided by the POST data (a JSON
> dict). It has to support various types of pool such as dir, netfs and
> logical. Now it uses "if ... elif ... elif" to check the requested type
> of pool and go in to the respective branch and generates the correct
> XML.
>
> This is OK for now but in future we'll have more types of pool, so in
> this patch we turn "if ... elif" into a dispatching dict, and put the
> respective XML generating code to separated functions.
>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
> ---
> src/kimchi/model.py | 121 +++++++++++++++++++++++++++++++---------------------
> 1 file changed, 73 insertions(+), 48 deletions(-)
>
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index 90a9a1b..d22e02d 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -1403,60 +1403,85 @@ class LibvirtVMScreenshot(VMScreenshot):
> finally:
> os.close(fd)
>
> -def _get_pool_xml(**kwargs):
> +
> +def _get_dir_storagepool_xml(poolArgs):
> # Required parameters
> # name:
> # type:
> # path:
> + xml = """
> + <pool type='%(type)s'>
> + <name>%(name)s</name>
> + <target>
> + <path>%(path)s</path>
> + </target>
> + </pool>
> + """ % poolArgs
> + return xml
> +
> +
> +def _get_netfs_storagepool_xml(poolArgs):
> + # Required parameters
> + # name:
> + # type:
> + # nfsserver:
> # nfspath:
> - if kwargs['type'] == 'dir':
> - xml = """
> - <pool type='%(type)s'>
> - <name>%(name)s</name>
> - <target>
> - <path>%(path)s</path>
> - </target>
> - </pool>
> - """
> - elif kwargs['type'] == 'netfs':
> - path = '/var/lib/kimchi/nfs_mount/' + kwargs['name'];
> - if not os.path.exists(path):
> - os.makedirs(path)
> - kwargs.update({'path': path})
> - xml = """
> - <pool type='%(type)s'>
> - <name>%(name)s</name>
> - <source>
> - <host name='%(nfsserver)s'/>
> - <dir path='%(nfspath)s'/>
> - </source>
> - <target>
> - <path>%(path)s</path>
> - </target>
> - </pool>
> - """
> - elif kwargs['type'] == 'logical':
> - path = '/var/lib/kimchi/logical_mount/' + kwargs['name'];
> - if not os.path.exists(path):
> - os.makedirs(path)
> - xml = """
> - <pool type='%(type)s'>
> - <name>%(name)s</name>
> - <source>
> - %(devices)s
> - </source>
> - <target>
> - <path>%(path)s</path>
> - </target>
> - </pool>
> - """
> - devices = ''
> - for device_path in kwargs['devices']:
> - devices += "<device path=\""+device_path+"\" />"
> + path = '/var/lib/kimchi/nfs_mount/' + poolArgs['name']
> + if not os.path.exists(path):
> + os.makedirs(path)
> + poolArgs['path'] = path
> + xml = """
> + <pool type='%(type)s'>
> + <name>%(name)s</name>
> + <source>
> + <host name='%(nfsserver)s'/>
> + <dir path='%(nfspath)s'/>
> + </source>
> + <target>
> + <path>%(path)s</path>
> + </target>
> + </pool>
> + """ % poolArgs
> + return xml
> +
> +
> +def _get_logical_storagepool_xml(poolArgs):
> + # Required parameters
> + # name:
> + # type:
> + # devices:
> + path = '/var/lib/kimchi/logical_mount/' + poolArgs['name']
> + if not os.path.exists(path):
> + os.makedirs(path)
> +
> + devices = []
> + for device_path in poolArgs['devices']:
> + devices.append('<device path="%s" />' % device_path)
> +
> + poolArgs.update({'devices': ''.join(devices),
> + 'path': path})
> + xml = """
> + <pool type='%(type)s'>
> + <name>%(name)s</name>
> + <source>
> + %(devices)s
> + </source>
> + <target>
> + <path>%(path)s</path>
> + </target>
> + </pool>
> + """ % poolArgs
> + return xml
> +
> +
> +def _get_pool_xml(**kwargs):
> + getPoolXml = {
> + 'dir': _get_dir_storagepool_xml,
> + 'netfs': _get_netfs_storagepool_xml,
> + 'logical': _get_logical_storagepool_xml,
> + }[kwargs['type']]
> + return getPoolXml(kwargs)
>
> - kwargs.update({'devices': devices})
> - kwargs.update({'path': path})
> - return xml % kwargs
>
> def _get_volume_xml(**kwargs):
> # Required parameters
Sheldon Feng(???)
IBM Linux Technology Center
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
[PATCH 0/2] Add the iscsi pool UI support
by zhoumeina
Include create storage pool UI and translation files.
zhoumeina (2):
Add UI support of iscsi
Add the ISCSI translation po files
po/en_US.po | 31 +++++++++++++----
po/kimchi.pot | 30 ++++++++++++----
po/pt_BR.po | 31 +++++++++++++----
po/zh_CN.po | 31 +++++++++++++----
ui/js/src/kimchi.storagepool_add_main.js | 54 ++++++++++++++++++++++++-----
ui/pages/i18n.html.tmpl | 7 ++--
ui/pages/storagepool-add.html.tmpl | 19 ++++++++++
7 files changed, 158 insertions(+), 45 deletions(-)
mode change 100644 => 100755 po/kimchi.pot
11 years
Re: [Kimchi-devel] [project-kimchi] [PATCH v1 2/4] storagepool: rename and consolidate arguments of creating (back end)
by Zhou Zheng Sheng
于 2013年12月18日 09:47, Shu Ming 写道:
> 于 2013/12/16 16:01, Zhou Zheng Sheng 写道:
>> As we are adding support to new type of storage pool, the current naming
>> scheme of the storage pool creating arguments should be rearranged to be
>> more extendable. This patch renames some arguments and consolidates the
>> argument of the same purposes as follow.
>>
>> nfsserver -> srcHost
>> This is because in future patches, iSCSI pool can use this srcHost as
>> well. Other network backed storage pool can also make use of this
>> argument.
>>
>> nfspath -> srcPath
>> This is because other netfs pool can also make use of this argument.
>>
>> devices -> srcDevices
>> To differentiate source arguments from the target arguments, we can add
>> a "src" prefix to source arguments.
>> ---
>> docs/API.md | 19 +++++++++++--------
>> src/kimchi/model.py | 17 +++++++++--------
>> 2 files changed, 20 insertions(+), 16 deletions(-)
>>
>> diff --git a/docs/API.md b/docs/API.md
>> index 74bc1b5..dd3d7f1 100644
>> --- a/docs/API.md
>> +++ b/docs/API.md
>> @@ -180,15 +180,18 @@ Represents a snapshot of the Virtual Machine's
>> primary monitor.
>>
>> * **GET**: Retrieve a summarized list of all defined Storage Pools
>> * **POST**: Create a new Storage Pool
>> - * name: The name of the Storage Pool
>> - * path: The path of the defined Storage Pool,
>> + * name: The name of the Storage Pool.
>> + * type: The type of the defined Storage Pool.
>> + Supported types: 'dir', 'kimchi-iso', 'netfs', 'logical'
>> + * path: The path of the defined Storage Pool.
>> For 'kimchi-iso' pool refers to targeted deep scan path.
>> - * type: The type of the defined Storage Pool,
>> - Supported types: 'dir', 'kimchi-iso', 'netfs'
>> - * nfsserver: IP or hostname of NFS server to create NFS pool.
>> - * nfspath: export path on nfs server for NFS pool.
>> - * devices: Array of devices to be used in the Storage Pool
>> - Exclusive to the 'logical' storage pool type.
>> + Pool types: 'dir', 'kimchi-iso'.
>> + * srcHost: IP or hostname of server for a pool backed from a
>> remote host.
>> + Pool types: 'nfs'.
>
> Let's keep the name style as the others in this file, like "src_host" or
> "srchost".
>
>> + * srcPath: Export path on NFS server for NFS pool.
>> + Pool types: 'nfs'.
> The same as the above.
>
>> + * srcDevices: Array of devices to be used in the Storage Pool
>> + Pool types: 'logical'.
>
> The same as the above.
>
Thanks for the suggestion. I will change the style.
>>
>> ### Resource: Storage Pool
>>
>> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
>> index d22e02d..af0d728 100644
>> --- a/src/kimchi/model.py
>> +++ b/src/kimchi/model.py
>> @@ -1424,8 +1424,8 @@ def _get_netfs_storagepool_xml(poolArgs):
>> # Required parameters
>> # name:
>> # type:
>> - # nfsserver:
>> - # nfspath:
>> + # srcHost:
>> + # srcPath:
>> path = '/var/lib/kimchi/nfs_mount/' + poolArgs['name']
>> if not os.path.exists(path):
>> os.makedirs(path)
>> @@ -1434,8 +1434,8 @@ def _get_netfs_storagepool_xml(poolArgs):
>> <pool type='%(type)s'>
>> <name>%(name)s</name>
>> <source>
>> - <host name='%(nfsserver)s'/>
>> - <dir path='%(nfspath)s'/>
>> + <host name='%(srcHost)s'/>
>> + <dir path='%(srcPath)s'/>
>> </source>
>> <target>
>> <path>%(path)s</path>
>> @@ -1449,22 +1449,23 @@ def _get_logical_storagepool_xml(poolArgs):
>> # Required parameters
>> # name:
>> # type:
>> - # devices:
>> + # srcDevices:
>> path = '/var/lib/kimchi/logical_mount/' + poolArgs['name']
>> if not os.path.exists(path):
>> os.makedirs(path)
>>
>> devices = []
>> - for device_path in poolArgs['devices']:
>> + for device_path in poolArgs['srcDevices']:
>> devices.append('<device path="%s" />' % device_path)
>>
>> - poolArgs.update({'devices': ''.join(devices),
>> + poolArgs.update({'srcDevices': ''.join(devices),
>> 'path': path})
>> +
>> xml = """
>> <pool type='%(type)s'>
>> <name>%(name)s</name>
>> <source>
>> - %(devices)s
>> + %(srcDevices)s
>> </source>
>> <target>
>> <path>%(path)s</path>
>
--
Thanks and best regards!
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou(a)linux.vnet.ibm.com
Telephone: 86-10-82454397
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
Re: [Kimchi-devel] [project-kimchi] [PATCH v1 1/4] storagepool: dispatch _get_pool_xml() to respective _get_XXX_storagepool_xml() function
by Zhou Zheng Sheng
on 2013/12/18/ 09:44, Shu Ming wrote:
> 于 2013/12/16 16:01, Zhou Zheng Sheng 写道:
>> In src/kimchi/model.py, _get_pool_xml() is to generate libvirt storage
>> pool XML definition from arguments provided by the POST data (a JSON
>> dict). It has to support various types of pool such as dir, netfs and
>> logical. Now it uses "if ... elif ... elif" to check the requested type
>> of pool and go in to the respective branch and generates the correct
>> XML.
>>
>> This is OK for now but in future we'll have more types of pool, so in
>> this patch we turn "if ... elif" into a dispatching dict, and put the
>> respective XML generating code to separated functions.
>>
>> Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
>> ---
>> src/kimchi/model.py | 121
>> +++++++++++++++++++++++++++++++---------------------
>> 1 file changed, 73 insertions(+), 48 deletions(-)
>>
>> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
>> index 90a9a1b..d22e02d 100644
>> --- a/src/kimchi/model.py
>> +++ b/src/kimchi/model.py
>> @@ -1403,60 +1403,85 @@ class LibvirtVMScreenshot(VMScreenshot):
>> finally:
>> os.close(fd)
>>
>> -def _get_pool_xml(**kwargs):
>> +
>> +def _get_dir_storagepool_xml(poolArgs):
>> # Required parameters
>> # name:
>> # type:
>> # path:
>> + xml = """
>> + <pool type='%(type)s'>
>> + <name>%(name)s</name>
>> + <target>
>> + <path>%(path)s</path>
>> + </target>
>> + </pool>
>> + """ % poolArgs
>> + return xml
>> +
>> +
>> +def _get_netfs_storagepool_xml(poolArgs):
>> + # Required parameters
>> + # name:
>> + # type:
>> + # nfsserver:
>> # nfspath:
>> - if kwargs['type'] == 'dir':
>> - xml = """
>> - <pool type='%(type)s'>
>> - <name>%(name)s</name>
>> - <target>
>> - <path>%(path)s</path>
>> - </target>
>> - </pool>
>> - """
>> - elif kwargs['type'] == 'netfs':
>> - path = '/var/lib/kimchi/nfs_mount/' + kwargs['name'];
>> - if not os.path.exists(path):
>> - os.makedirs(path)
>> - kwargs.update({'path': path})
>> - xml = """
>> - <pool type='%(type)s'>
>> - <name>%(name)s</name>
>> - <source>
>> - <host name='%(nfsserver)s'/>
>> - <dir path='%(nfspath)s'/>
>> - </source>
>> - <target>
>> - <path>%(path)s</path>
>> - </target>
>> - </pool>
>> - """
>> - elif kwargs['type'] == 'logical':
>> - path = '/var/lib/kimchi/logical_mount/' + kwargs['name'];
>> - if not os.path.exists(path):
>> - os.makedirs(path)
>> - xml = """
>> - <pool type='%(type)s'>
>> - <name>%(name)s</name>
>> - <source>
>> - %(devices)s
>> - </source>
>> - <target>
>> - <path>%(path)s</path>
>> - </target>
>> - </pool>
>> - """
>> - devices = ''
>> - for device_path in kwargs['devices']:
>> - devices += "<device path=\""+device_path+"\" />"
>> + path = '/var/lib/kimchi/nfs_mount/' + poolArgs['name']
>> + if not os.path.exists(path):
>> + os.makedirs(path)
>> + poolArgs['path'] = path
>> + xml = """
>> + <pool type='%(type)s'>
>> + <name>%(name)s</name>
>> + <source>
>> + <host name='%(nfsserver)s'/>
> Is it not the intention to replace "nfsserver" with "src_host"?
>
>> + <dir path='%(nfspath)s'/>
>
> Is it not the intention to replace "nfspath" with "src_path"?
>
Yes. This is in another patch, "storagepool: rename and consolidate
arguments of creating (back end)"
>> + </source>
>> + <target>
>> + <path>%(path)s</path>
>> + </target>
>> + </pool>
>> + """ % poolArgs
>> + return xml
>> +
>> +
>> +def _get_logical_storagepool_xml(poolArgs):
>> + # Required parameters
>> + # name:
>> + # type:
>> + # devices:
>> + path = '/var/lib/kimchi/logical_mount/' + poolArgs['name']
> Can we make the path configurable? and make
>
> '/var/lib/kimchi/*" as the default setting.
>
>
I agree, let's do it in another patch.
>> + if not os.path.exists(path):
>> + os.makedirs(path)
>> +
>> + devices = []
>> + for device_path in poolArgs['devices']:
>> + devices.append('<device path="%s" />' % device_path)
>> +
>> + poolArgs.update({'devices': ''.join(devices),
>> + 'path': path})
>> + xml = """
>> + <pool type='%(type)s'>
>> + <name>%(name)s</name>
>> + <source>
>> + %(devices)s
>> + </source>
>> + <target>
>> + <path>%(path)s</path>
>> + </target>
>> + </pool>
>> + """ % poolArgs
>> + return xml
>> +
>> +
>> +def _get_pool_xml(**kwargs):
>> + getPoolXml = {
>> + 'dir': _get_dir_storagepool_xml,
>> + 'netfs': _get_netfs_storagepool_xml,
>> + 'logical': _get_logical_storagepool_xml,
>> + }[kwargs['type']]
>> + return getPoolXml(kwargs)
>>
>> - kwargs.update({'devices': devices})
>> - kwargs.update({'path': path})
>> - return xml % kwargs
>>
>> def _get_volume_xml(**kwargs):
>> # Required parameters
>
--
Thanks and best regards!
Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou(a)linux.vnet.ibm.com
Telephone: 86-10-82454397
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years
[project-kimchi] Kimchi 1.1 is released!
by Aline Manera
On behalf of everyone who has worked hard on this release, I am pleased
to announce the availability of Kimchi 1.1! This release adds many new
features including:
* Easy Template creation from Remote ISO images
* Template customization
* Basic guest customization
* NSF and logical Pool support
* Basic network management
* Basic host management
* Support for Kimchi plugins
We have worked hard to ensure that Kimchi runs well on the most popular
Linux distributions including: Fedora 19, Ubuntu 13.10, openSUSE 13.1,
and RHEL 6.5. Kimchi uses standard Linux interfaces so it should run
well on many other distributions too.
You can easily grab this release in tarball format or via git:
*https://github.com/kimchi-project/kimchi/archive/kimchi-1.1.0.tar.gz
* git clonehttps://github.com/kimchi-project/kimchi.git
Go ahead and give it a try and let us know what you think!
Regards,
----
Aline Manera
--
project-kimchi mailing list <project-kimchi(a)googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
---
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe(a)googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
11 years