[Kimchi-devel] [PATCH] Issue 292 Logical Storage Pool Returning "extended" Partitions as Possible Pool
Sheldon
shaohef at linux.vnet.ibm.com
Tue Mar 11 12:48:16 UTC 2014
Reviewed-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
pyparted is good to detect the extended partition
On 03/11/2014 01:06 PM, zhshzhou at linux.vnet.ibm.com wrote:
> From: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
>
> Extended partition is a container of logical partitions. Kimchi should
> skip extended partition regardless of it contains logical partitions or
> not. This patch uses pyparted to check if a partition is a extended
> partition and skip if it is.
>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
> ---
> contrib/DEBIAN/control.in | 1 +
> contrib/kimchi.spec.fedora.in | 1 +
> contrib/kimchi.spec.suse.in | 1 +
> docs/README.md | 6 +++---
> src/kimchi/disks.py | 19 +++++++++++++++++--
> 5 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
> index 1b03fc7..c2b2a40 100644
> --- a/contrib/DEBIAN/control.in
> +++ b/contrib/DEBIAN/control.in
> @@ -15,6 +15,7 @@ Depends: python-cherrypy3 (>= 3.2.0),
> python-libxml2,
> qemu-kvm,
> python-pam,
> + python-parted,
> python-psutil (>= 0.6.0),
> python-ethtool,
> sosreport,
> diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
> index 149c3a7..bf80104 100644
> --- a/contrib/kimchi.spec.fedora.in
> +++ b/contrib/kimchi.spec.fedora.in
> @@ -20,6 +20,7 @@ Requires: m2crypto
> Requires: python-imaging
> Requires: libxml2-python
> Requires: PyPAM
> +Requires: pyparted
> Requires: python-psutil >= 0.6.0
> Requires: python-jsonschema >= 1.3.0
> Requires: python-ethtool
> diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
> index beddada..cba0899 100644
> --- a/contrib/kimchi.spec.suse.in
> +++ b/contrib/kimchi.spec.suse.in
> @@ -16,6 +16,7 @@ Requires: python-imaging
> Requires: python-M2Crypto
> Requires: python-libxml2
> Requires: python-pam
> +Requires: python-parted
> Requires: python-psutil >= 0.6.0
> Requires: python-jsonschema >= 1.3.0
> Requires: python-ethtool
> diff --git a/docs/README.md b/docs/README.md
> index 5721878..4be0e53 100644
> --- a/docs/README.md
> +++ b/docs/README.md
> @@ -53,7 +53,7 @@ Install Dependencies
> PyPAM m2crypto python-jsonschema rpm-build \
> qemu-kvm python-psutil python-ethtool sos \
> python-ipaddr python-lxml nfs-utils \
> - iscsi-initiator-utils libxslt
> + iscsi-initiator-utils libxslt pyparted
> # If using RHEL6, install the following additional packages:
> $ sudo yum install python-unittest2 python-ordereddict
> # Restart libvirt to allow configuration changes to take effect
> @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository.
> python-pam python-m2crypto python-jsonschema \
> qemu-kvm libtool python-psutil python-ethtool \
> sosreport python-ipaddr python-lxml nfs-common \
> - open-iscsi lvm2 xsltproc
> + open-iscsi lvm2 xsltproc python-parted
>
> Packages version requirement:
> python-jsonschema >= 1.3.0
> @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository.
> python-pam python-M2Crypto python-jsonschema \
> rpm-build kvm python-psutil python-ethtool \
> python-ipaddr python-lxml nfs-client open-iscsi \
> - libxslt-tools python-xml
> + libxslt-tools python-xml python-parted
>
> Packages version requirement:
> python-psutil >= 0.6.0
> diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py
> index 8389922..cada869 100644
> --- a/src/kimchi/disks.py
> +++ b/src/kimchi/disks.py
> @@ -20,6 +20,9 @@
> import re
> import subprocess
>
> +from parted import Device as PDevice
> +from parted import Disk as PDisk
> +
> from kimchi.exception import OperationFailed
> from kimchi.utils import kimchi_log
>
> @@ -78,6 +81,17 @@ def _is_dev_leaf(devNodePath):
> return childrenCount == 0
>
>
> +def _is_dev_extended_partition(devType, devNodePath):
> + if devType != 'part':
> + return False
> + diskPath = devNodePath.rstrip('0123456789')
> + device = PDevice(diskPath)
> + disk = PDisk(device)
> + if disk.getExtendedPartition().path == devNodePath:
> + return True
> + return False
> +
> +
> def _parse_lsblk_output(output, keys):
> # output is on format key="value",
> # where key can be NAME, TYPE, FSTYPE, SIZE, MOUNTPOINT, etc
> @@ -122,12 +136,13 @@ def get_partitions_names():
> # 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. Physical volume belongs to no volume group
> - # is also listed.
> + # is also listed. Extended partitions should not be listed.
> if not (dev['type'] in ['part', 'disk'] and
> dev['fstype'] in ['', 'LVM2_member'] and
> dev['mountpoint'] == "" and
> _get_vgname(devNodePath) == "" and
> - _is_dev_leaf(devNodePath)):
> + _is_dev_leaf(devNodePath) and
> + not _is_dev_extended_partition(dev['type'], devNodePath)):
> continue
>
> names.add(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