From 252dcb3c52fa6ff875a1eea2c3e6ffcb351b58a6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 4 Feb 2012 09:40:55 +0000 Subject: [PATCH] Move mount_disk code again. --- 2012-fosdem/500-auditing.term | 2 +- 2012-fosdem/500.d/audit.py | 31 ++++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/2012-fosdem/500-auditing.term b/2012-fosdem/500-auditing.term index 3996078..94c0df1 100755 --- a/2012-fosdem/500-auditing.term +++ b/2012-fosdem/500-auditing.term @@ -5,7 +5,7 @@ source functions echo "Example: Auditing" remember 'ls -l -h' -remember 'emacs -nw +27 audit.py' +remember 'emacs -nw audit.py' remember './audit.py win7.img' remember './audit.py rhel6.img' diff --git a/2012-fosdem/500.d/audit.py b/2012-fosdem/500.d/audit.py index 4be22f7..af1062e 100755 --- a/2012-fosdem/500.d/audit.py +++ b/2012-fosdem/500.d/audit.py @@ -4,22 +4,6 @@ import re import sys import guestfs -def mount_disk (g, root): - mps = g.inspect_get_mountpoints (root) - def compare (a, b): - if len(a[0]) > len(b[0]): - return 1 - elif len(a[0]) == len(b[0]): - return 0 - else: - return -1 - mps.sort (compare) - for mp_dev in mps: - try: - g.mount_ro (mp_dev[1], mp_dev[0]) - except RuntimeError as msg: - print "%s (ignored)" % msg - if len (sys.argv) != 2: raise (Error ("disk [image]")) disk = sys.argv[1] @@ -34,7 +18,20 @@ if len (roots) == 0: raise (Error ("inspect_vm: no operating systems found")) for root in roots: - mount_disk (g, root) + mps = g.inspect_get_mountpoints (root) + def compare (a, b): + if len(a[0]) > len(b[0]): + return 1 + elif len(a[0]) == len(b[0]): + return 0 + else: + return -1 + mps.sort (compare) + for mp_dev in mps: + try: + g.mount_ro (mp_dev[1], mp_dev[0]) + except RuntimeError as msg: + print "%s (ignored)" % msg apps = g.inspect_list_applications (root) for app in apps: -- 1.8.3.1