+
+
+class Stash(file):
+ mntpnt = '/tmp/stash'
+ def __init__(self, vars, mode):
+ utils.makedirs(self.mntpnt)
+ try:
+ utils.sysexec('mount -t auto -U %s %s' % (vars['DISCONNECTED_OPERATION'], self.mntpnt))
+ # make sure it's not read-only
+ f = file('%s/api.cache' % self.mntpnt, 'a')
+ f.close()
+ file.__init__(self, '%s/api.cache' % self.mntpnt, mode)
+ except:
+ utils.sysexec_noerr('umount %s' % self.mntpnt)
+ raise BootManagerException, "Couldn't find API-cache for disconnected operation"
+
+ def close(self):
+ file.close(self)
+ utils.sysexec_noerr('umount %s' % self.mntpnt)
+
+def load(vars):
+ global stash
+ s = Stash(vars, 'r')
+ stash = cPickle.load(s)
+ s.close()
+
+def save(vars):
+ global stash
+ if vars['DISCONNECTED_OPERATION']:
+ s = Stash(vars, 'w')
+ cPickle.dump(stash, s)
+ s.close()