FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 03-09-2009, 03:36 PM
Joel Granados Moreno
 
Default Be more careful when selecting a vg name.

lvm allows metadata that lives in unused disks to interfere with its
behavior. For example you can have an old VG name in an ignored disk
and if you are trying to create a new VG with the same name, lvm will
not let you do it. The safest thing to do is just to avoid repeating
names.

* storage/__init__.py (createSuggestedVGName): call the new
vgdetectednames function and put it in the names that cannot be
repeated.
* storage/devicelibs/lvm.py (vgdetectednames): new function. Returns
the VG names that lvm has detected in the system.
---
storage/__init__.py | 2 ++
storage/devicelibs/lvm.py | 14 ++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index 8dda2a4..6e9dbf0 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -42,6 +42,7 @@ from formats import getFormat
from formats import get_device_format_class
from formats import get_default_filesystem_type
from devicelibs.lvm import safeLvmName
+from devicelibs.lvm import vgdetectednames
from devicelibs.mdraid import mdRaidBootArches
from udev import udev_trigger
import iscsi
@@ -611,6 +612,7 @@ class Storage(object):
# try to create a volume group name incorporating the hostname
hn = network.hostname
vgnames = [vg.name for vg in self.vgs]
+ vgnames.extend(vgdetectednames())
if hn is not None and hn != ':
if hn == 'localhost' or hn == 'localhost.localdomain':
vgtemplate = "VolGroup"
diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index bdb732a..e5b0bd9 100644
--- a/storage/devicelibs/lvm.py
+++ b/storage/devicelibs/lvm.py
@@ -236,6 +236,20 @@ def vginfo(vg_name):
d['pe_count'],d['pe_free'],d['pv_count']) = info
return d

+def vgdetectednames():
+ """ Will run vgs and return all the detected names.
+
+ There is a change that there are vgnames that are recognized by lvm.
+ It is important to know what these vgs are.
+ """
+ retval = []
+ names = iutil.execWithCapture("lvm",
+ ["vgs", "--noheadings", "-o", "vg_name"],
+ stderr="/dev/tty5")
+ for name in names.strip("
").split("
"):
+ retval.append(name.strip())
+ return retval
+
def lvs(vg_name):
buf = iutil.execWithCapture("lvm",
["lvs", "--noheadings", "--nosuffix",
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-09-2009, 05:29 PM
Chris Lumens
 
Default Be more careful when selecting a vg name.

> diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
> index bdb732a..e5b0bd9 100644
> --- a/storage/devicelibs/lvm.py
> +++ b/storage/devicelibs/lvm.py
> @@ -236,6 +236,20 @@ def vginfo(vg_name):
> d['pe_count'],d['pe_free'],d['pv_count']) = info
> return d
>
> +def vgdetectednames():
> + """ Will run vgs and return all the detected names.
> +
> + There is a change that there are vgnames that are recognized by lvm.
> + It is important to know what these vgs are.
> + """
> + retval = []
> + names = iutil.execWithCapture("lvm",
> + ["vgs", "--noheadings", "-o", "vg_name"],
> + stderr="/dev/tty5")
> + for name in names.strip("
").split("
"):
> + retval.append(name.strip())
> + return retval
> +

I like, but how are you going to split on a newline if you've already
stripped it off?

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-10-2009, 09:59 AM
Joel Granados
 
Default Be more careful when selecting a vg name.

On Mon, Mar 09, 2009 at 02:29:58PM -0400, Chris Lumens wrote:
> > diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
> > index bdb732a..e5b0bd9 100644
> > --- a/storage/devicelibs/lvm.py
> > +++ b/storage/devicelibs/lvm.py
> > @@ -236,6 +236,20 @@ def vginfo(vg_name):
> > d['pe_count'],d['pe_free'],d['pv_count']) = info
> > return d
> >
> > +def vgdetectednames():
> > + """ Will run vgs and return all the detected names.
> > +
> > + There is a change that there are vgnames that are recognized by lvm.
> > + It is important to know what these vgs are.
> > + """
> > + retval = []
> > + names = iutil.execWithCapture("lvm",
> > + ["vgs", "--noheadings", "-o", "vg_name"],
> > + stderr="/dev/tty5")
> > + for name in names.strip("
").split("
"):
> > + retval.append(name.strip())
> > + return retval
> > +
>
> I like, but how are you going to split on a newline if you've already
> stripped it off?

I strip the new lines at the beginning and end of the string to then
split with the newlines that are left inside the sting.

1. raw string:

asdf
wqer
sag
wer


2. stripted stirng
asdf
wqer
sag
wer
3. split string
["asdf", "nwqer", "sag", "wer"]

>
> - Chris
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

--
Joel Andres Granados
Brno, Czech Republic, Red Hat.

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-10-2009, 01:18 PM
Chris Lumens
 
Default Be more careful when selecting a vg name.

> I strip the new lines at the beginning and end of the string to then
> split with the newlines that are left inside the sting.
>
> 1. raw string:
>
asdf
wqer
sag
wer


> 2. stripted stirng
> asdf
wqer
sag
wer
> 3. split string
> ["asdf", "nwqer", "sag", "wer"]

Makes sense to me. Go with it!

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 04:57 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org