def untarpersistent(self, tarname, iso): ''' Unpack a persistent template tar file to the mounted mount dir. Uses fsimage library to read from an ISO file. ''' tarname = tarname.replace('%h', self.name) # filename may use hostname if iso: try: fs = fsimage.open(self.isofile, 0) except IOError as e: self.warn("Failed to open ISO file: %s (%s)" % (self.isofile,e)) return try: tardata = fs.open_file(tarname).read(); except IOError as e: self.warn("Failed to open tar file: %s (%s)" % (tarname, e)) return finally: del fs; else: try: f = open(tarname) tardata = f.read() f.close() except IOError as e: self.warn("Failed to open tar file: %s (%s)" % (tarname, e)) return p = subprocess.Popen([TAR_PATH, '-C', self.mountdir, '--numeric-owner', '-xf', '-'], stdin=subprocess.PIPE) p.communicate(input=tardata) p.wait()
def untarpersistent(self, tarname, iso): """ Unpack a persistent template tar file to the mounted mount dir. Uses fsimage library to read from an ISO file. """ # filename may use hostname tarname = tarname.replace("%h", self.name) if iso: try: fs = fsimage.open(self.isofile, 0) except IOError: logger.exception("Failed to open ISO file: %s", self.isofile) return try: tardata = fs.open_file(tarname).read() except IOError: logger.exception("Failed to open tar file: %s", tarname) return finally: del fs else: try: f = open(tarname) tardata = f.read() f.close() except IOError: logger.exception("Failed to open tar file: %s", tarname) return p = subprocess.Popen( [TAR_PATH, "-C", self.mountdir, "--numeric-owner", "-xf", "-"], stdin=subprocess.PIPE) p.communicate(input=tardata) p.wait()
def untarpersistent(self, tarname, iso): ''' Unpack a persistent template tar file to the mounted mount dir. Uses fsimage library to read from an ISO file. ''' tarname = tarname.replace('%h', self.name) # filename may use hostname if iso: try: fs = fsimage.open(self.isofile, 0) except IOError, e: self.warn("Failed to open ISO file: %s (%s)" % (self.isofile,e)) return try: tardata = fs.open_file(tarname).read(); except IOError, e: self.warn("Failed to open tar file: %s (%s)" % (tarname, e)) return