@@ -0,0 +1,1630 @@
+#!/usr/bin/env python%0A#%0A# Copyright (C) Citrix Inc%0A#%0A# Permission to use, copy, modify, and distribute this software for any%0A# purpose with or without fee is hereby granted, provided that the above%0A# copyright notice and this permission notice appear in all copies.%0A#%0A# THE SOFTWARE IS PROVIDED %22AS IS%22 AND THE AUTHOR DISCLAIMS ALL WARRANTIES%0A# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF%0A# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR%0A# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES%0A# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN%0A# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF%0A# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.%0A%0Aimport os%0Aimport util%0Aimport errno%0A%0AMOUNT_NFS = %22/sbin/mount.nfs%22%0AUMOUNT = %22/bin/umount%22%0AMTAB = %22/etc/mtab%22%0A%0Aclass Mount:%0A    def __init__(self, remote, local):%0A        self.remote = remote%0A        self.local = local%0A%0A    def mount(self):%0A        cmd = %5B MOUNT_NFS, self.remote, self.local %5D%0A        util.pread2(cmd)%0A%0A    def umount(self):%0A        cmd = %5B UMOUNT, self.local %5D%0A        util.pread2(cmd)%0A%0Adef list(root):%0A    %22%22%22Return a list of Mount instances with local mounts in%0A    the filesystem tree rooted at %5Broot%5D%22%22%22%0A    f = open(MTAB, %22r%22)%0A    try:%0A        results = %5B%5D%0A        for line in f.readlines():%0A            # remote local nfs options 0 0%0A            bits = line.split()%0A            if bits%5B2%5D == %22nfs%22 and bits%5B1%5D.startswith(root):%0A                results.append(Mount(bits%5B0%5D, bits%5B1%5D))%0A        return results%0A    finally:%0A        f.close()%0A%0A

add "mount.nfs", "umount" wrapper for NFS mounting