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 > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-09-2009, 04:08 PM
Mark Hamzy
 
Default display reIPL information before reboot

Display reIPL information before a reboot so that the user knows

which partition the 390 will reboot into. This can help diagnose

an error if the 390 will mistakenly reboot into a different partition

than expected. It also conveniently displays reboot information

rather than relying on the user know the correct place to get the

information out of.



---

anaconda | 2 ++

gui.py | 1 +

iutil.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++

3 files changed, 65 insertions(+), 0 deletions(-)



diff --git a/anaconda b/anaconda

index 746ce1f..f6a3059 100755

--- a/anaconda

+++ b/anaconda

@@ -977,4 +977,6 @@ if __name__ == "__main__":

log.info("attempting to eject %s" % drive.path)

drive.eject()



+ iutil.dumpReIPLFiles ()

+

del anaconda.intf

diff --git a/gui.py b/gui.py

index 4e65362..bfeb65c 100755

--- a/gui.py

+++ b/gui.py

@@ -1330,6 +1330,7 @@ class InstallControlWindow:

takeScreenShot()



def _doExit (self, *args):

+ iutil.dumpReIPLFiles ()

gtk.main_quit()

os._exit(0)



diff --git a/iutil.py b/iutil.py

index f83b002..ef2de33 100644

--- a/iutil.py

+++ b/iutil.py

@@ -39,6 +39,11 @@ _ = lambda x: gettext.ldgettext("anaconda", x)

import logging

log = logging.getLogger("anaconda")



+tty3_handler = logging.FileHandler("/dev/tty3")

+reIPL_log = logging.getLogger("reIPL")

+reIPL_log.addHandler(tty3_handler)

+reIPL_log.setLevel(logging.INFO)

+

#Python reimplementation of the shell tee process, so we can

#feed the pipe output into two places at the same time

class tee(threading.Thread):

@@ -1015,6 +1020,63 @@ def reIPL(anaconda, loader_pid):

# or a two-item list with errorMessage and rebootInstr (=> shutdown)

return message



+def stringFileContents (filename):

+ try:

+ data = "">
+

+ fp = open (filename)

+

+ data = "" ().strip ()

+

+ fp.close ()

+

+ dataContents = ""

+

+ for ch in data:

+ if ch in string.printable:

+ dataContents += ch

+ else:

+ dataContents = None

+ break

+

+ if dataContents is not None:

+ return dataContents

+

+ dataContents = ""

+

+ for ch in data:

+ dataContents += hex (ord (ch)) + " "

+

+ return dataContents

+

+ except Excception, e:

+

+ return "ERROR"

+

+def dumpReIPLFiles ():

+ try:

+ filename = "/sys/firmware/reipl/reipl_type"

+

+ if not os.path.isfile (filename):

+ return

+

+ type = stringFileContents (filename)

+

+ reIPL_log.info ("%s = %s" % (filename, type,))

+

+ directory = "/sys/firmware/reipl/%s" % (type,)

+

+ if not os.path.exists (directory):

+ return

+

+ for directoryFile in os.listdir (directory):

+ contents = stringFileContents ("%s/%s" % (directory, directoryFile,))

+

+ reIPL_log.info ("%s/%s = %s" % (directory, directoryFile, contents,))

+

+ except Exception, e:

+ log.info("dumpReIPLFiles: Caught exception %s", (e,))

+

def resetRpmDb(rootdir):

for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootdir):

try:

--

1.6.4.4





--

Mark



You must be the change you wish to see in the world. -- Mahatma Gandhi

Worrying is praying for that you do not wish to happen.___________________________________________ ____
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-09-2009, 10:24 PM
Mark Hamzy
 
Default display reIPL information before reboot

Display reIPL information before a reboot so that the user knows

which partition the 390 will reboot into. This can help diagnose

an error if the 390 will mistakenly reboot into a different partition

than expected. It also conveniently displays reboot information

rather than relying on the user know the correct place to get the

information out of.



---

anaconda | 2 ++

gui.py | 1 +

iutil.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++

3 files changed, 65 insertions(+), 0 deletions(-)



diff --git a/anaconda b/anaconda

index 78e5fd1..1b2cf64 100755

--- a/anaconda

+++ b/anaconda

@@ -1052,6 +1052,8 @@ if __name__ == "__main__":

log.info("attempting to eject %s" % drive.path)

drive.eject()



+ iutil.dumpReIPLFiles ()

+

del anaconda.intf



# vim:tw=78:ts=4:et:sw=4

diff --git a/gui.py b/gui.py

index 4379bec..e1753e3 100755

--- a/gui.py

+++ b/gui.py

@@ -1324,6 +1324,7 @@ class InstallControlWindow:

takeScreenShot()



def _doExit (self, *args):

+ iutil.dumpReIPLFiles ()

gtk.main_quit()

os._exit(0)



diff --git a/iutil.py b/iutil.py

index 39d398a..da97256 100644

--- a/iutil.py

+++ b/iutil.py

@@ -38,6 +38,11 @@ _ = lambda x: gettext.ldgettext("anaconda", x)

import logging

log = logging.getLogger("anaconda")



+tty3_handler = logging.FileHandler("/dev/tty3")

+reIPL_log = logging.getLogger("reIPL")

+reIPL_log.addHandler(tty3_handler)

+reIPL_log.setLevel(logging.INFO)

+

#Python reimplementation of the shell tee process, so we can

#feed the pipe output into two places at the same time

class tee(threading.Thread):

@@ -1014,6 +1019,63 @@ def reIPL(anaconda, loader_pid):

# or a two-item list with errorMessage and rebootInstr (=> shutdown)

return message



+def stringFileContents (filename):

+ try:

+ data = "">
+

+ fp = open (filename)

+

+ data = "" ().strip ()

+

+ fp.close ()

+

+ dataContents = ""

+

+ for ch in data:

+ if ch in string.printable:

+ dataContents += ch

+ else:

+ dataContents = None

+ break

+

+ if dataContents is not None:

+ return dataContents

+

+ dataContents = ""

+

+ for ch in data:

+ dataContents += hex (ord (ch)) + " "

+

+ return dataContents

+

+ except Excception, e:

+

+ return "ERROR"

+

+def dumpReIPLFiles ():

+ try:

+ filename = "/sys/firmware/reipl/reipl_type"

+

+ if not os.path.isfile (filename):

+ return

+

+ type = stringFileContents (filename)

+

+ reIPL_log.info ("%s = %s" % (filename, type,))

+

+ directory = "/sys/firmware/reipl/%s" % (type,)

+

+ if not os.path.exists (directory):

+ return

+

+ for directoryFile in os.listdir (directory):

+ contents = stringFileContents ("%s/%s" % (directory, directoryFile,))

+

+ reIPL_log.info ("%s/%s = %s" % (directory, directoryFile, contents,))

+

+ except Exception, e:

+ log.info("dumpReIPLFiles: Caught exception %s", (e,))

+

def resetRpmDb(rootdir):

for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootdir):

try:

--

1.6.4.4



--

Mark



You must be the change you wish to see in the world. -- Mahatma Gandhi

Worrying is praying for that you do not wish to happen.___________________________________________ ____
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-10-2009, 12:11 AM
Chris Lumens
 
Default display reIPL information before reboot

> diff --git a/iutil.py b/iutil.py
> index 39d398a..da97256 100644
> --- a/iutil.py
> +++ b/iutil.py
> @@ -1014,6 +1019,63 @@ def reIPL(anaconda, loader_pid):
> # or a two-item list with errorMessage and rebootInstr (=> shutdown)
> return message
>
> +def stringFileContents (filename):
> + try:
> + data = None
> +
> + fp = open (filename)
> +
> + data = fp.read ().strip ()
> +
> + fp.close ()
> +
> + dataContents = ""
> +
> + for ch in data:
> + if ch in string.printable:
> + dataContents += ch
> + else:
> + dataContents = None
> + break
> +
> + if dataContents is not None:
> + return dataContents
> +
> + dataContents = ""
> +
> + for ch in data:
> + dataContents += hex (ord (ch)) + " "
> +
> + return dataContents
> +
> + except Excception, e:
> +
> + return "ERROR"

Note the "Excception" typo above. Speaking of exceptions, I don't
really care for the style of just catching the top-level exception, as
this tends to have the unintended consequence of hiding unrelated
errors. Since this is a library function, I'd prefer to not handle
exceptions in it and let the caller deal with that.

Can you show me what the sample output from this function would be? I
find the two loops over data a little odd.

> +def dumpReIPLFiles ():
> + try:
> + filename = "/sys/firmware/reipl/reipl_type"
> +
> + if not os.path.isfile (filename):
> + return
> +
> + type = stringFileContents (filename)
> +
> + reIPL_log.info ("%s = %s" % (filename, type,))
> +
> + directory = "/sys/firmware/reipl/%s" % (type,)
> +
> + if not os.path.exists (directory):
> + return
> +
> + for directoryFile in os.listdir (directory):
> + contents = stringFileContents ("%s/%s" % (directory, directoryFile,))
> +
> + reIPL_log.info ("%s/%s = %s" % (directory, directoryFile, contents,))
> +
> + except Exception, e:
> + log.info("dumpReIPLFiles: Caught exception %s", (e,))

The same comment about catching Exception applies here. Also I think
that you're really only going to have an exception coming up from
stringFileContents, since you check os.path.{isfile,exists} already.
Otherwise, this method looks fine.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-10-2009, 04:13 PM
Steffen Maier
 
Default display reIPL information before reboot

On 12/10/2009 12:24 AM, Mark Hamzy wrote:
> Display reIPL information before a reboot so that the user knows
> which partition the 390 will reboot into. This can help diagnose
> an error if the 390 will mistakenly reboot into a different partition
> than expected. It also conveniently displays reboot information
> rather than relying on the user know the correct place to get the
> information out of.
>
> ---
> anaconda | 2 ++
> gui.py | 1 +
> iutil.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
> 3 files changed, 65 insertions(+), 0 deletions(-)
>
> diff --git a/anaconda b/anaconda
> index 78e5fd1..1b2cf64 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -1052,6 +1052,8 @@ if __name__ == "__main__":
> log.info("attempting to eject %s" % drive.path)
> drive.eject()
>
> + iutil.dumpReIPLFiles ()
> +
> del anaconda.intf
>
> # vim:tw=78:ts=4:et:sw=4
> diff --git a/gui.py b/gui.py
> index 4379bec..e1753e3 100755
> --- a/gui.py
> +++ b/gui.py
> @@ -1324,6 +1324,7 @@ class InstallControlWindow:
> takeScreenShot()
>
> def _doExit (self, *args):
> + iutil.dumpReIPLFiles ()
> gtk.main_quit()
> os._exit(0)
>

Can anyone please confirm that those two places are really the only ones
where anaconda may exit for a (successful) installation?
If there will be a global exit handler with Chris' reboot rework, then
we could trigger an lsreipl there.

> diff --git a/iutil.py b/iutil.py
> index 39d398a..da97256 100644
> --- a/iutil.py
> +++ b/iutil.py
> @@ -38,6 +38,11 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
> import logging
> log = logging.getLogger("anaconda")
>
> +tty3_handler = logging.FileHandler("/dev/tty3")
> +reIPL_log = logging.getLogger("reIPL")
> +reIPL_log.addHandler(tty3_handler)
> +reIPL_log.setLevel(logging.INFO)
> +
> #Python reimplementation of the shell tee process, so we can
> #feed the pipe output into two places at the same time
> class tee(threading.Thread):
> @@ -1014,6 +1019,63 @@ def reIPL(anaconda, loader_pid):
> # or a two-item list with errorMessage and rebootInstr (=> shutdown)
> return message
>
> +def stringFileContents (filename):

> +def dumpReIPLFiles ():

Instead of letting anaconda interpret the current reipl settings, I now
realized that we have lsreipl from s390utils in stage2 (and even stage1
since dae98456cac25415bb05464138a52b583aaebb2b). This tool gets
maintained and will be adapted should the reipl interface change.
Calling this existing tool might make life easier, if it provides all
the output you intended to get.

> def resetRpmDb(rootdir):
> for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootdir):
> try:
> --
> 1.6.4.4

Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-14-2009, 02:45 AM
Mark Hamzy
 
Default display reIPL information before reboot

maier@linux.vnet.ibm.com@redhat.com wrote on 12/11/2009 08:13:51 AM:



> > diff --git a/gui.py b/gui.py

> > index 4379bec..e1753e3 100755

> > --- a/gui.py

> > +++ b/gui.py

> > @@ -1324,6 +1324,7 @@ class InstallControlWindow:

> > * * * * * * *takeScreenShot()

> >

> > * * *def _doExit (self, *args):

> > + * * * *iutil.dumpReIPLFiles ()

> > * * * * *gtk.main_quit()

> > * * * * *os._exit(0)

> >

>

> Can anyone please confirm that those two places are really the only ones

> where anaconda may exit for a (successful) installation?

> If there will be a global exit handler with Chris' reboot rework, then

> we could trigger an lsreipl there.



Ditto. *Can anyone please confirm that those two places are really the only ones

where anaconda may exit for a (successful) installation?



> Instead of letting anaconda interpret the current reipl settings, I now

> realized that we have lsreipl from s390utils in stage2 (and even stage1

> since dae98456cac25415bb05464138a52b583aaebb2b). This tool gets

> maintained and will be adapted should the reipl interface change.

> Calling this existing tool might make life easier, if it provides all

> the output you intended to get.



That is a good idea. *Unfortunately, lsreipl is NOT on the root image

when anaconda is run. *I do see that it is in scripts/upd-instroot and

scripts/mk-images. *But it is not in initrd.img or install.img. *So what

am I missing?



--

Mark



You must be the change you wish to see in the world. -- Mahatma Gandhi

Worrying is praying for that you do not wish to happen.___________________________________________ ____
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-14-2009, 07:17 PM
Chris Lumens
 
Default display reIPL information before reboot

> > Can anyone please confirm that those two places are really the only ones
> > where anaconda may exit for a (successful) installation?
> > If there will be a global exit handler with Chris' reboot rework, then
> > we could trigger an lsreipl there.
>
> Ditto. Can anyone please confirm that those two places are really the only
> ones
> where anaconda may exit for a (successful) installation?

Yes, I *think* those are the only places a successful installation will
exit. Everywhere else we call sys.exit is from an exception handler, or
you pressed "Reboot"/"Exit", or something like that. You can't just
tell from the return codes, though.

> > Instead of letting anaconda interpret the current reipl settings, I now
> > realized that we have lsreipl from s390utils in stage2 (and even stage1
> > since dae98456cac25415bb05464138a52b583aaebb2b). This tool gets
> > maintained and will be adapted should the reipl interface change.
> > Calling this existing tool might make life easier, if it provides all
> > the output you intended to get.
>
> That is a good idea. Unfortunately, lsreipl is NOT on the root image
> when anaconda is run. I do see that it is in scripts/upd-instroot and
> scripts/mk-images. But it is not in initrd.img or install.img. So what
> am I missing?

Looks like scripts/upd-instroot refers to sbin/lsreipl, whereas it's
in /usr/sbin/lsreipl in the package. Basically, all these commands
should be audited to make sure we're referring to the right locations.

- 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 09:02 AM.

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