def putPartition(self, exchangeDesc, compress): number = exchangeDesc.number cfg = exchangeDesc.config loc = exchangeDesc.exchangeloc if cfg['storage'] == 'block': support.dd(count=cfg['size'], seek=cfg['start'], infile=loc, \ outfile=self.node, bs=512) #TODO - Do you need to restore the disk label byte for a block put if cfg['storage'] == 'tarball': #TODO - Migrage the partition creation code here #support.createFS() self.mountDir = os.path.join(self.exchangeDir, \ "mount" + str(number)) os.mkdir(self.mountDir) support.mount(device=self.node + str(number), dest=self.mountDir) #Extract the exchange file to the new partition efd = open(loc, 'r') #tarp = support.tarExtract_Process(self.mountDir) #subprocess.call(compress.getDecompressOpts(), # stdin=efd, stdout=tarp.stdin) q = subprocess.Popen(compress.getDecompressOpts(), stdin=efd, stdout=subprocess.PIPE) p = support.tarExtract_Process(self.mountDir, stdin=q.stdout) p.wait() q.wait() efd.close() #support.tar(tarfile=loc, target='', options='xzf', \ # cwd=self.mountDir) support.umount(self.mountDir) support.writePartID(self.node, number, int(cfg['label']))
def getTarball(self, compress): self.exchangeFile = os.path.join(self.exchangeDir, \ "p" + str(self.number)) self.mountDir = os.path.join(self.exchangeDir, \ "mount" + str(self.number)) os.mkdir(self.mountDir) support.mount(device=self.device + str(self.number), dest=self.mountDir) efd = open(self.exchangeFile, 'w+b') tarp = support.tarCreate_Process(srcdir=self.mountDir) p = subprocess.call(compress.getCompressOpts(), stdin=tarp.stdout, stdout=efd) efd.close() #support.tar(tarfile=self.exchangeFile, target='.', options='czf', \ # cwd=self.mountDir) support.umount(self.mountDir) return PartExchangeDescriptor(self.number, self.buildConfig(), self.exchangeFile)