[Kimchi-devel] [PATCH] issue #312: Rename LVM while deleting logical storage pool

Shu Ming shuming at linux.vnet.ibm.com
Wed Mar 5 07:50:15 UTC 2014


2014/3/5 4:49, Aline Manera:
> From: Aline Manera <alinefm at br.ibm.com>
>
> When creating a Logical storage pool, a LVM is created with the same
> name.

I assume you mean a volume group here.

> And when deleting the storage pool the LVM keeps on the system. Which is
> the correct behavior as the storage pool is only a concept and deleting it
> should not affect the file system.
I am a bit confusing here.  The volume group was created when the user 
tried to create a storage pool from a raw device like "/dev/sda3".   
When the storage pool was undefined, it was reasonable to remove the 
volume group and make the raw device available again.   Is it?

> But it prevents the user to create a new logical pool with a name used
> before which is odd.
> So when deleting a logical pool, rename the LVM to a single name to
> allow user create a logical pool with any name.
So the raw device will be used after the renaming and will not be 
available any more?

>
> Also convert an error message parameter to string instead of virStoragePool
> instance.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/model/storagepools.py |   15 ++++++++++++++-
>   1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py
> index 76ab2d6..dd3c9a2 100644
> --- a/src/kimchi/model/storagepools.py
> +++ b/src/kimchi/model/storagepools.py
> @@ -17,6 +17,8 @@
>   # License along with this library; if not, write to the Free Software
>   # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
>
> +import time
> +
>   import libvirt
>
>   from kimchi import xmlutils
> @@ -172,7 +174,8 @@ class StoragePoolModel(object):
>                   return 0
>           except libvirt.libvirtError as e:
>               raise OperationFailed("KCHPOOL0008E",
> -                                  {'name': pool, 'err': e.get_error_message()})
> +                                  {'name': pool.name(),
> +                                   'err': e.get_error_message()})
>
>       def _get_storage_source(self, pool_type, pool_xml):
>           source = {}
> @@ -348,7 +351,17 @@ class StoragePoolModel(object):
>           if pool.isActive():
>               raise InvalidOperation("KCHPOOL0005E", {'name': name})
>           try:
> +            xml = pool.XMLDesc(0)
> +            pool_type = xmlutils.xpath_get_text(xml, "/pool/@type")[0]
>               pool.undefine()
> +            # The user may want to create a logical pool with the same name
> +            # used before but a LVM will already exist with this name
> +            # So rename the former LVM to avoid future conflicts
> +            if pool_type == 'logical':
> +                lvm_name = "%s-%s" % (name, str(int(time.time()*1000)))
> +                vgrename_cmd = ["vgrename", name, lvm_name]
> +                run_command(vgrename_cmd)
> +
>           except libvirt.libvirtError as e:
>               raise OperationFailed("KCHPOOL0011E",
>                                     {'name': name, 'err': e.get_error_message()})




More information about the Kimchi-devel mailing list