def write(self): image = os.path.join(self.workDir, self.basefilename + '.hdd') outputFile = os.path.join(self.outputDir, self.basefilename + self.suffix) self.makeHDImage(image) self.status('Creating %s Image' % self.productName) workingDir = os.path.join(self.workDir, self.basefilename) if os.path.exists(workingDir): util.rmtree(workingDir) util.mkdirChain(workingDir) # pass just the basename, these functions handle the proper suffix self.createVHD(image, os.path.join(workingDir, self.basefilename)) self.createVMC(os.path.join(workingDir, self.basefilename)) self.status('Compressing Microsoft Virtual PC Image') self.gzip(workingDir, outputFile) self.outputFileList.append((outputFile, 'Virtual Server')) if self.buildOVF10: self.capacity = 10000 diskFileSize = imagegen.getFileSize(outputFile) self.ovfImage = ovf_image.XenOvfImage(self.basefilename, self.jobData['description'], constants.VHD, outputFile, diskFileSize, self.capacity, True, self.getBuildData('vmMemory'), workingDir, self.outputDir) self.ovfObj = self.ovfImage.createOvf() self.ovfXml = self.ovfImage.writeOvf() self.ovfImage.createManifest() self.ovaPath = self.ovfImage.createOva() self.outputFileList.append((self.ovaPath, '%s %s' % (self.productName, constants.OVFIMAGETAG))) self.postOutput(self.outputFileList)
def write(self): topDir = os.path.join(self.workDir, 'unified') tbdir = os.path.join(topDir, self.productDir, 'tarballs') baseDir = os.path.join(topDir, self.productDir, 'base') util.mkdirChain(tbdir) util.mkdirChain(baseDir) basePath = os.path.join(self.workDir, self.basefilename) if os.path.exists(basePath): util.rmtree(basePath) util.mkdirChain(basePath) outputDir = os.path.join(constants.finishedDir, self.UUID) util.mkdirChain(outputDir) tarball = os.path.join(self.workDir, self.basefilename + '.tar.gz') cwd = os.getcwd() try: self.installFileTree(basePath, no_mbr=True) self.status('Preparing to build ISOs') os.chdir(basePath) util.execute('tar -C %s -cpPsS --to-stdout ./ | gzip > %s' % \ (basePath, tarball)) ts = TarSplit(tarball) ts.splitFile(tbdir) ts.writeTbList(os.path.join(baseDir, 'tblist')) util.rmtree(basePath, ignore_errors = True) util.rmtree(tarball, ignore_errors = True) try: os.chdir(cwd) except: # block all errors so that real ones can get through pass self.callback = installable_iso.Callback(self.status) print >> sys.stderr, "Building ISOs of size: %d Mb" % \ (self.maxIsoSize / 1048576) sys.stderr.flush() # FIXME: hack to ensure we don't trigger overburns. # there are probably cleaner ways to do this. if self.maxIsoSize > 681574400: self.maxIsoSize -= 1024 * 1024 templateDir, clientVersion = self.retrieveTemplates() csdir = self.prepareTemplates(topDir, templateDir) util.rmtree(csdir, ignore_errors=True) if self.arch == 'x86': anacondaArch = 'i386' else: anacondaArch = self.arch # write .discinfo discInfoPath = os.path.join(topDir, ".discinfo") if os.path.exists(discInfoPath): os.unlink(discInfoPath) discInfoFile = open(discInfoPath, "w") print >> discInfoFile, time.time() print >> discInfoFile, self.jobData['name'] print >> discInfoFile, anacondaArch print >> discInfoFile, "1" for x in ["base", "tarballs", 'pixmaps']: print >> discInfoFile, "%s/%s" % (self.productDir, x) discInfoFile.close() self.extractMediaTemplate(topDir) self.setupKickstart(topDir) self.writeProductImage(topDir, installable_iso.getArchFlavor(self.baseFlavor).freeze()) self.status("Building ISOs") # Mostly copied from splitdistro current = os.path.join(self.workDir, 'disc1') discnum = 1 if os.path.isdir(current): print >> sys.stderr, 'removing stale', current util.rmtree(current) print >> sys.stderr, 'creating', current os.mkdir(current) splitdistro.lndir(topDir, current, excludes=('media-template',)) # lay 'disc1' before 'all' to ensure collisions are handled correctly for cDir in ('disc1', 'all'): if 'media-template' in os.listdir(topDir) and \ cDir in os.listdir(os.path.join(topDir, 'media-template')): splitdistro.lndir(os.path.join(topDir, 'media-template', cDir), current) for cDir in ('all', 'disc1'): srcDir = os.path.join(topDir, 'media-template2', cDir) if os.path.exists(srcDir): for src in os.listdir(srcDir): call('cp', '-R', '--no-dereference', os.path.join(srcDir, src), current) outputFileList = self.buildIsos(topDir) if self.buildOVF10: self.workingDir = os.path.join(self.workDir, self.basefilename) util.mkdirChain(self.workingDir) diskFileSize = imagegen.getFileSize(outputFileList[0][0]) self.ovfImage = ovf_image.ISOOvfImage(self.basefilename, self.jobData['description'], None, outputFileList[0][0], diskFileSize, self.maxIsoSize, False, self.getBuildData('vmMemory'), self.workingDir, self.outputDir) self.ovfObj = self.ovfImage.createOvf() self.ovfXml = self.ovfImage.writeOvf() self.ovfImage.createManifest() self.ovaPath = self.ovfImage.createOva() outputFileList.append((self.ovaPath, 'Appliance ISO OVF 1.0')) # notify client that images are ready self.postOutput(outputFileList) finally: util.rmtree(os.path.normpath(os.path.join(topDir, "..")), ignore_errors = True) util.rmtree(constants.cachePath, ignore_errors = True)
def write(self): self.callback = Callback(self.status) # set up the topdir topdir = os.path.join(self.workDir, "unified") util.mkdirChain(topdir) log.info("Building ISOs of size: %d Mb" % (self.maxIsoSize / 1048576)) # FIXME: hack to ensure we don't trigger overburns. # there are probably cleaner ways to do this. if self.maxIsoSize > 681574400: self.maxIsoSize -= 1024 * 1024 templateDir, clientVersion = self.retrieveTemplates() csdir = self.prepareTemplates(topdir, templateDir) tg = self.extractChangeSets(csdir, clientVersion) if self.arch == 'x86': anacondaArch = 'i386' else: anacondaArch = self.arch baseDir = os.path.join(topdir, self.productDir, 'base') # write the cslist tg.writeCsList(baseDir) # write the group.ccs tg.writeGroupCs(baseDir) # write .discinfo discInfoPath = os.path.join(topdir, ".discinfo") if os.path.exists(discInfoPath): os.unlink(discInfoPath) discInfoFile = open(discInfoPath, "w") print >> discInfoFile, time.time() print >> discInfoFile, self.jobData['name'] print >> discInfoFile, anacondaArch print >> discInfoFile, "1" for x in ["base", "changesets", "pixmaps"]: print >> discInfoFile, "%s/%s" % (self.productDir, x) discInfoFile.close() self.extractMediaTemplate(topdir) self.extractPublicKeys('public_keys', topdir, csdir) self.setupKickstart(topdir) self.writeProductImage(topdir, getArchFlavor(self.baseFlavor).freeze()) self.status("Building ISOs") splitdistro.splitDistro(topdir, self.baseTrove, self.maxIsoSize) outputFileList = self.buildIsos(topdir) if self.buildOVF10: self.workingDir = os.path.join(self.workDir, self.basefilename) util.mkdirChain(self.workingDir) diskFileSize = imagegen.getFileSize(outputFileList[0][0]) self.ovfImage = ovf_image.ISOOvfImage(self.basefilename, self.jobData['description'], None, outputFileList[0][0], diskFileSize, self.maxIsoSize, False, self.getBuildData('vmMemory'), self.workingDir, self.outputDir) self.ovfObj = self.ovfImage.createOvf() self.ovfXml = self.ovfImage.writeOvf() self.ovfImage.createManifest() self.ovaPath = self.ovfImage.createOva() outputFileList.append((self.ovaPath, 'Installable ISO OVF 1.0')) # notify client that images are ready self.postOutput(outputFileList)