[PATCH V4] Sort device paths shown when creating a logical storage pool

This patch sorts the host partitions list returned by backend by partition path. Then UI is going to show paths sorted, improving the user experience. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/control/host.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py index cfc24bd..ee9fe7b 100644 --- a/src/kimchi/control/host.py +++ b/src/kimchi/control/host.py @@ -64,6 +64,12 @@ class Partitions(Collection): super(Partitions, self).__init__(model) self.resource = Partition + # Defining get_resources in order to return list of partitions in UI + # sorted by their path + def _get_resources(self, flag_filter): + res_list = super(Partitions, self)._get_resources(flag_filter) + res_list.sort(key=lambda x: x.info['path']) + return res_list class Partition(Resource): def __init__(self, model, id): -- 1.8.5.3

Reviewed-By: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Tested on my VM. Before the patch, the devices are listed as follow. vdb5 vdb6 mpathb vdb1 mpatha After the patch, the devices are listed as follow. mpatha mpathb vdb1 vdb5 vdb6 on 2014/04/01 22:34, Rodrigo Trujillo wrote:
This patch sorts the host partitions list returned by backend by partition path. Then UI is going to show paths sorted, improving the user experience.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/control/host.py | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py index cfc24bd..ee9fe7b 100644 --- a/src/kimchi/control/host.py +++ b/src/kimchi/control/host.py @@ -64,6 +64,12 @@ class Partitions(Collection): super(Partitions, self).__init__(model) self.resource = Partition
+ # Defining get_resources in order to return list of partitions in UI + # sorted by their path + def _get_resources(self, flag_filter): + res_list = super(Partitions, self)._get_resources(flag_filter) + res_list.sort(key=lambda x: x.info['path']) + return res_list
class Partition(Resource): def __init__(self, model, id):
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

Tested-By: Christy Perez <christy@linux.vnet.ibm.com> Before the patch: /dev/mapper/mpathd /dev/mapper/mpathb /dev/mapper/mpatha1 /dev/mapper/mpathc After the patch: /dev/mapper/mpatha1 /dev/mapper/mpathb /dev/mapper/mpathc /dev/mapper/mpathd On Tue, 2014-04-01 at 11:34 -0300, Rodrigo Trujillo wrote:
This patch sorts the host partitions list returned by backend by partition path. Then UI is going to show paths sorted, improving the user experience.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/control/host.py | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py index cfc24bd..ee9fe7b 100644 --- a/src/kimchi/control/host.py +++ b/src/kimchi/control/host.py @@ -64,6 +64,12 @@ class Partitions(Collection): super(Partitions, self).__init__(model) self.resource = Partition
+ # Defining get_resources in order to return list of partitions in UI + # sorted by their path + def _get_resources(self, flag_filter): + res_list = super(Partitions, self)._get_resources(flag_filter) + res_list.sort(key=lambda x: x.info['path']) + return res_list
class Partition(Resource): def __init__(self, model, id):
Regards, - Christy
participants (3)
-
Christy Perez
-
Rodrigo Trujillo
-
Zhou Zheng Sheng