def PreInstall(self): TmpResponse = self.installDependences() if TmpResponse['ret_code'] != 0: print('failed to install %s ,because of dependency failuere' % (self.AppInfo['AppName'], )) return { 'ret_code': 1, 'result': 'failed to install %s ,because of dependency failuere' % (self.AppInfo['AppName'], ) } ### export mysql SQL ## print('import Mysql SQL file....') self.generateValues() if not os.path.isdir(os.path.join(self.BaseDIRPath, 'tmp')): os.mkdir(os.path.join(self.BaseDIRPath, 'tmp')) with open(os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'), mode='wb', encoding='utf-8') as f: f.write('root root ' + self.DependencyDict['MariaDBPassword'] + '\n') f.write('%s %s %s' % (self.AppInfo['PaperReviewDBName'], self.AppInfo['PaperReviewDBUser'], self.AppInfo['PaperReviewDBPassword']) + '\n') TmpSQLToolAccountPath = '-'.join( [self.AppInfo['Namespace'], 'sqltool-pv-account']) TmpSQLToolAccountPath = os.path.realpath( os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolAccountPath)) TmpSQLToolSQLPath = '-'.join( [self.AppInfo['Namespace'], 'sqltool-pv-sql']) TmpSQLToolSQLPath = os.path.realpath( os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolSQLPath)) print(TmpSQLToolAccountPath) print(TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolSQLPath) print(os.path.join(self.BaseDIRPath, 'tmp', 'account.txt')) #print (os.path.join(self.BaseDIRPath, 'downloads', 'mty_wcm.sql')) self.DataStorageObj.uploadFile( localpath=os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'), remotepath=os.path.join(TmpSQLToolAccountPath, 'account.txt')) '''self.DataStorageObj.uploadFile(localpath=os.path.join(self.BaseDIRPath, 'downloads', 'mty_wcm.sql'), remotepath=os.path.join(TmpSQLToolSQLPath, 'mty_wcm.sql') )''' TmpSQLToolObj = sqltool.SQLTool(**self.kwargs) TmpResponse = TmpSQLToolObj.start() if TmpResponse['ret_code'] != 0: print('Error occured while running SQL Tool') return { 'ret_code': 1, 'result': 'Error occured while running SQL Tool' } print('import Nacos configuration.....') self.generateValues() if not os.path.isdir(os.path.join(self.BaseDIRPath, 'tmp')): os.mkdir(os.path.join(self.BaseDIRPath, 'tmp')) with open(os.path.join(self.BaseDIRPath, 'tmp', 'namespace.txt'), mode='wb', encoding='utf-8') as f: f.write('bigdata %s' % (self.AppInfo['PaperReviewNacosID'], ) + '\n') TmpNacosToolDataPath = '-'.join( [self.AppInfo['Namespace'], 'nacostool']) TmpNacosToolDataPath = os.path.realpath( os.path.join(self.AppInfo['DataStorageBasePath'], TmpNacosToolDataPath)) print(TmpNacosToolDataPath) self.DataStorageObj.createSubFolder(TmpNacosToolDataPath) self.DataStorageObj.cleanSubFolder(TmpNacosToolDataPath) print(os.path.join(self.BaseDIRPath, 'tmp', 'namespace.txt')) #print (os.path.join(self.BaseDIRPath, 'downloads', 'mty_wcm.sql')) self.DataStorageObj.uploadFile( localpath=os.path.join(self.BaseDIRPath, 'tmp', 'namespace.txt'), remotepath=os.path.join(TmpNacosToolDataPath, 'namespace.txt')) self.DataStorageObj.uploadFile( localpath=os.path.join(self.BaseDIRPath, 'downloads', 'nacos.tar.gz'), remotepath=os.path.join(TmpNacosToolDataPath, 'nacos.tar.gz')) #self.DataStorageObj.ExecCmd('cd %s;tar -xvzf nacos.tar.gz'%(self.DataStorageObj.generateRealPath(TmpNacosToolDataPath), )) self.DataStorageObj.unTarFile( os.path.join(TmpNacosToolDataPath, 'nacos.tar.gz')) TmpNacosToolObj = nacostool.NacosTool(**self.kwargs) TmpResponse = TmpNacosToolObj.start() if TmpResponse['ret_code'] != 0: print('Error occured while running Nacos Tool') return { 'ret_code': 1, 'result': 'Error occured while running Nacos Tool' } ##### end ### return { 'ret_code': 0, 'result': '', }
def PreInstall(self): TmpResponse = self.installDependences() if TmpResponse['ret_code'] != 0: print ('failed to install %s ,because of dependency failuere'%(self.AppInfo['AppName'], )) return { 'ret_code': 1, 'result': 'failed to install %s ,because of dependency failuere'%(self.AppInfo['AppName'], ) } ### export mysql SQL ## print ('import Mysql SQL file....') self.generateValues() if not os.path.isdir(os.path.join(self.BaseDIRPath, 'tmp')): os.mkdir(os.path.join(self.BaseDIRPath, 'tmp')) with open(os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'),mode='wb',encoding='utf-8') as f: f.write('root root '+self.DependencyDict['MariaDBPassword']+'\n') f.write('%s %s %s'%(self.AppInfo['TransferVideoPrimaryDBName'], self.AppInfo['TransferVideoPrimaryDBUser'], self.AppInfo['TransferVideoPrimaryDBPassword'])+'\n') TmpSQLToolAccountPath = '-'.join([self.AppInfo['Namespace'], 'sqltool-pv-account']) TmpSQLToolAccountPath = os.path.realpath(os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolAccountPath)) TmpSQLToolSQLPath = '-'.join([self.AppInfo['Namespace'], 'sqltool-pv-sql']) TmpSQLToolSQLPath = os.path.realpath(os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolSQLPath)) print (TmpSQLToolAccountPath) print (TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolSQLPath) print (os.path.join(self.BaseDIRPath, 'tmp', 'account.txt')) #print (os.path.join(self.BaseDIRPath, 'downloads', 'tmy_decision_center.sql')) self.DataStorageObj.uploadFile(localpath=os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'), remotepath=os.path.join(TmpSQLToolAccountPath, 'account.txt') ) ''' self.DataStorageObj.uploadFile(localpath=os.path.join(self.BaseDIRPath, 'downloads', 'tmy_decision_center.sql'), remotepath=os.path.join(TmpSQLToolSQLPath, 'tmy_decision_center.sql') ) ''' TmpSQLToolObj = sqltool.SQLTool(**self.kwargs) TmpResponse = TmpSQLToolObj.start() if TmpResponse['ret_code'] != 0: print ('Error occured while running SQL Tool') return { 'ret_code': 1, 'result': 'Error occured while running SQL Tool' } ##### end ### return { 'ret_code': 0, 'result': '', }
def PreInstall(self): TmpResponse = self.installDependences() if TmpResponse['ret_code'] != 0: print('failed to install %s ,because of dependency failuere' % (self.AppInfo['AppName'], )) return { 'ret_code': 1, 'result': 'failed to install %s ,because of dependency failuere' % (self.AppInfo['AppName'], ) } if not self.AppInfo['PrivateURLHost']: TmpIP = raw_input('input private IP: ') self.AppInfo['PrivateURLHost'] = TmpIP self.AppInfo['PublishURLHost'] = TmpIP ### export mysql SQL ## print('import Mysql SQL file....') self.generateValues() if not os.path.isdir(os.path.join(self.BaseDIRPath, 'tmp')): os.mkdir(os.path.join(self.BaseDIRPath, 'tmp')) with open(os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'), mode='wb', encoding='utf-8') as f: f.write('root root ' + self.DependencyDict['MariaDBPassword'] + '\n') f.write( '%s %s %s' % (self.AppInfo['TRSWCMDBName'], self.AppInfo['TRSWCMDBUser'], self.AppInfo['TRSWCMDBPassword']) + '\n') TmpSQLToolAccountPath = '-'.join( [self.AppInfo['Namespace'], 'sqltool-pv-account']) TmpSQLToolAccountPath = os.path.realpath( os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolAccountPath)) TmpSQLToolSQLPath = '-'.join( [self.AppInfo['Namespace'], 'sqltool-pv-sql']) TmpSQLToolSQLPath = os.path.realpath( os.path.join(self.AppInfo['DataStorageBasePath'], TmpSQLToolSQLPath)) print(TmpSQLToolAccountPath) print(TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolSQLPath) self.DataStorageObj.createSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolAccountPath) self.DataStorageObj.cleanSubFolder(TmpSQLToolSQLPath) print(os.path.join(self.BaseDIRPath, 'tmp', 'account.txt')) ##### 20210202 ### with open(os.path.join(self.BaseDIRPath, 'downloads', 'mty_wcm.sql'), mode='rb', encoding='utf-8') as f: TmpContent = f.read() TmpContent = jinja2.Template(TmpContent).render(self.AppInfo) with open(os.path.join(self.BaseDIRPath, 'tmp', 'mty_wcm.sql'), mode='wb', encoding='utf-8') as f: f.write(TmpContent) ##### END ### print(os.path.join(self.BaseDIRPath, 'tmp', 'mty_wcm.sql')) self.DataStorageObj.uploadFile( localpath=os.path.join(self.BaseDIRPath, 'tmp', 'account.txt'), remotepath=os.path.join(TmpSQLToolAccountPath, 'account.txt')) self.DataStorageObj.uploadFile( localpath=os.path.join(self.BaseDIRPath, 'tmp', 'mty_wcm.sql'), remotepath=os.path.join(TmpSQLToolSQLPath, 'mty_wcm.sql')) TmpSQLToolObj = sqltool.SQLTool(**self.kwargs) TmpResponse = TmpSQLToolObj.start() if TmpResponse['ret_code'] != 0: print('Error occured while running SQL Tool') return { 'ret_code': 1, 'result': 'Error occured while running SQL Tool' } ##### end ### return { 'ret_code': 0, 'result': '', }