lbs-util: Add a command for dumping a flattened metadata log file.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 30 Oct 2007 20:43:29 +0000 (13:43 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Tue, 30 Oct 2007 20:43:29 +0000 (13:43 -0700)
lbs-util

index 267c955..24db4d6 100755 (executable)
--- a/lbs-util
+++ b/lbs-util
@@ -103,6 +103,17 @@ def cmd_read_snapshots(snapshots):
         print d['Segments'].split()
     store.cleanup()
 
+# Produce a flattened metadata dump from a snapshot
+def cmd_read_metadata(snapshot):
+    get_passphrase()
+    lowlevel = lbs.LowlevelDataStore(options.store)
+    store = lbs.ObjectStore(lowlevel)
+    d = lbs.parse_full(store.load_snapshot(snapshot))
+    metadata = lbs.read_metadata(store, d['Root'])
+    for l in metadata:
+        sys.stdout.write(l)
+    store.cleanup()
+
 # Verify snapshot integrity
 def cmd_verify_snapshots(snapshots):
     get_passphrase()
@@ -230,6 +241,8 @@ elif cmd == 'object-sums':
     cmd_object_checksums(args)
 elif cmd == 'read-snapshots':
     cmd_read_snapshots(args)
+elif cmd == 'read-metadata':
+    cmd_read_metadata(args[0])
 elif cmd == 'list-snapshot-sizes':
     cmd_list_snapshot_sizes()
 elif cmd == 'verify-snapshots':