def __buildTarFileForTransfer(self, gpEnv, masterSegment, sampleSegment, newSegments): """ Returns the file for the tarfile that should be transferred and used for building the blank segment """ masterDir = gpEnv.getMasterDataDir() # note that this tempdir will be left around on the system (this is what other scripts do currently) tempDir = gp.createTempDirectoryName(gpEnv.getMasterDataDir(), "gpbuildingsegment") unix.MakeDirectory("create temp directory for segment", tempDir).run(validateAfter=True) schemaDir = tempDir + "/schema" unix.MakeDirectory("create temp schema directory for segment", schemaDir).run(validateAfter=True) unix.Chmod.local('set permissions on schema dir', schemaDir, '0700') # set perms so postgres can start # # Copy remote files from the sample segment to the master # for toCopyFromRemote in ["postgresql.conf", "pg_hba.conf"]: cmd = gp.RemoteCopy('copying %s from a segment' % toCopyFromRemote, os.path.join( sampleSegment.getSegmentDataDirectory(), toCopyFromRemote), masterSegment.getSegmentHostName(), schemaDir, ctxt=base.REMOTE, remoteHost=sampleSegment.getSegmentAddress()) cmd.run(validateAfter=True) appendNewEntriesToHbaFile(schemaDir + "/pg_hba.conf", newSegments) # # Use the master's version of other files, and build # self.__createEmptyDirectories(schemaDir, gDatabaseDirectories) self.__createEmptyDirectories(schemaDir, gDatabaseSubDirectories) self.__copyFiles(masterDir, schemaDir, ["PG_VERSION", "pg_ident.conf"]) # # Build final tar # tarFileName = "gp_emptySegmentSchema.tar" tarFile = tempDir + "/" + tarFileName cmd = gp.CreateTar('gpbuildingmirrorsegment tar segment template', schemaDir, tarFile) cmd.run(validateAfter=True) return (tempDir, tarFile, tarFileName)
def __buildTarFileForTransfer(self, gpEnv, masterSegment, sampleSegment, newSegments): """ Returns the file for the tarfile that should be transferred and used for building the blank segment """ masterDir = gpEnv.getMasterDataDir() # note that this tempdir will be left around on the system (this is what other scripts do currently) tempDir = gp.createTempDirectoryName(gpEnv.getMasterDataDir(), "gpbuildingsegment") unix.MakeDirectory("create temp directory for segment", tempDir).run(validateAfter=True) schemaDir = tempDir + "/schema" unix.MakeDirectory("create temp schema directory for segment", schemaDir).run(validateAfter=True) unix.Chmod.local("set permissions on schema dir", schemaDir, "0700") # set perms so postgres can start # # Copy remote files from the sample segment to the master # for toCopyFromRemote in ["postgresql.conf", "pg_hba.conf"]: cmd = gp.RemoteCopy( "copying %s from a segment" % toCopyFromRemote, sampleSegment.getSegmentDataDirectory() + "/" + toCopyFromRemote, masterSegment.getSegmentHostName(), schemaDir, ctxt=base.REMOTE, remoteHost=sampleSegment.getSegmentAddress(), ) cmd.run(validateAfter=True) appendNewEntriesToHbaFile(schemaDir + "/pg_hba.conf", newSegments) # # Use the master's version of other files, and build # self.__createEmptyDirectories(schemaDir, gDatabaseDirectories) self.__createEmptyDirectories(schemaDir, gDatabaseSubDirectories) self.__copyFiles(masterDir, schemaDir, ["PG_VERSION", "pg_ident.conf"]) # # Build final tar # tarFileName = "gp_emptySegmentSchema.tar" tarFile = tempDir + "/" + tarFileName cmd = gp.CreateTar("gpbuildingmirrorsegment tar segment template", schemaDir, tarFile) cmd.run(validateAfter=True) return (tempDir, tarFile, tarFileName)