def get_canonical_path(dir_path, file_name): result = File(dir_path, file_name) try: result = result.getCanonicalFile() except IOException: result = result.getAbsoluteFile() return result
def __deployOsbCfg(configPrefix, componentProperties): configJarFilename = componentProperties.getProperty(configPrefix + PROPERTY_OSB_CFG_SUFFIX_FILE) customisationFilename = componentProperties.getProperty(configPrefix + PROPERTY_OSB_CFG_SUFFIX_CUSTOM) log.info("Deploying OSB configuration from file '" + configJarFilename + "'") if not customisationFilename is None and len(customisationFilename) > 0: log.info("Customising using file '" + customisationFilename + "'") domainRuntime() infile = File(configJarFilename) # TODO - verify file exists infile = infile.getAbsoluteFile() # enables server to find the file sessionMBean = findService("SessionManagement", OSB_SESSION_BEAN) sessionName = getNewSessionName() sessionMBean.createSession(sessionName) # obtain the ALSBConfigurationMBean instance that operates # on the session that has just been created. Notice that # the name of the mbean contains the session name. alsbSession = findService("ALSBConfiguration." + sessionName, OSB_CONFIG_BEAN) alsbSession.uploadJarFile(__readBytes(infile)) plan = alsbSession.getImportJarInfo().getDefaultImportPlan() plan.setPreserveExistingEnvValues(false) alsbSession.importUploaded(plan) if not customisationFilename is None and len(customisationFilename) > 0: customiseImport(alsbSession, customisationFilename) # activate changes performed in the session sessionMBean.activateSession(sessionName, "Imported new application via " + configJarFilename)
def savePreviousArguments(managedServerName): from java.io import File from java.io import FileOutputStream from java.util import Properties from java.util import Date from java.text import SimpleDateFormat import string startToEdit() # parameter on the wsdl ant task call fileLocation = sys.argv[1].replace("\\", "/") print "The backup file location is" print fileLocation try: dateFormat = SimpleDateFormat('_d_MMM_yyyy_HH_mm_ss') date = Date() formattedDate = dateFormat.format(date) print formattedDate except: print "The date cannot be created/formatted" try: propsFile = File(fileLocation + managedServerName + formattedDate + "_config.bkp") print propsFile.exists() if (propsFile.exists() == 0): propsFile.createNewFile() except: print "The file cannot be created on:" print propsFile.getAbsoluteFile() dumpStack() previousProperties = Properties() print '===> Saving the previous arguments - ' + managedServerName cd('/Servers/' + managedServerName) print "Getting the Classpath" classPath = cmo.getServerStart().getClassPath() print classPath if classPath == None: classPath = "" previousProperties.setProperty("classPath", classPath) print "Saving Arguments to file" previousProperties.store(FileOutputStream(propsFile), None) print '===> Saved arguments! Please verify the file on:' + fileLocation + "in" + managedServerName
def savePreviousArguments(managedServerName): from java.io import File from java.io import FileOutputStream from java.util import Properties from java.util import Date from java.text import SimpleDateFormat import string startToEdit() # parameter on the wsdl ant task call fileLocation = sys.argv[1].replace("\\","/") print "The backup file location is" print fileLocation try: dateFormat = SimpleDateFormat('_d_MMM_yyyy_HH_mm_ss') date = Date() formattedDate = dateFormat.format(date) print formattedDate except: print "The date cannot be created/formatted" try: propsFile = File(fileLocation+ managedServerName + formattedDate+"_config.bkp"); print propsFile.exists() if(propsFile.exists() == 0): propsFile.createNewFile() except: print "The file cannot be created on:" print propsFile.getAbsoluteFile() dumpStack() previousProperties = Properties() print '===> Saving the previous arguments - ' + managedServerName cd('/Servers/'+managedServerName) print "Getting the VMArgs" vmArgs = cmo.getServerStart().getArguments() print vmArgs if vmArgs == None: vmArgs = "" previousProperties.setProperty("vmArgs", vmArgs) print "Saving Arguments to file" previousProperties.store(FileOutputStream(propsFile),None) print '===> Saved arguments! Please verify the file on:'+ fileLocation + "in" + managedServerName
def lstat(path): """lstat(path) -> stat result Like stat(path), but do not follow symbolic links. """ abs_path = sys.getPath(path) try: return stat_result.from_jnastat(_posix.lstat(abs_path)) except NotImplementedError: pass except: raise f = File(sys.getPath(path)) # XXX: jna-posix implements similar link detection in # JavaFileStat.calculateSymlink, fallback to that instead when not # native abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: # root isn't a link return stat(path) can_parent = abs_parent.getCanonicalFile() if can_parent.getAbsolutePath() == abs_parent.getAbsolutePath(): # The parent directory's absolute path is canonical.. if f.getAbsolutePath() != f.getCanonicalPath(): # but the file's absolute and canonical paths differ (a # link) return stat_result((_stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) # The parent directory's path is not canonical (one of the parent # directories is a symlink). Build a new path with the parent's # canonical path and compare the files f = File(_path.join(can_parent.getAbsolutePath(), f.getName())) if f.getAbsolutePath() != f.getCanonicalPath(): return stat_result((_stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) # Not a link, only now can we determine if it exists (because # File.exists() returns False for dead links) if not f.exists(): raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) return stat(path)
def lstat(path): """lstat(path) -> stat result Like stat(path), but do not follow symbolic links. """ abs_path = sys.getPath(path) try: return stat_result.from_jnastat(_posix.lstat(abs_path)) except NotImplementedError: pass except: raise f = File(sys.getPath(path)) # XXX: jna-posix implements similar link detection in # JavaFileStat.calculateSymlink, fallback to that instead when not # native abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: # root isn't a link return stat(path) can_parent = abs_parent.getCanonicalFile() if can_parent.getAbsolutePath() == abs_parent.getAbsolutePath(): # The parent directory's absolute path is canonical.. if f.getAbsolutePath() != f.getCanonicalPath(): # but the file's absolute and canonical paths differ (a # link) return stat_result((_stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) # The parent directory's path is not canonical (one of the parent # directories is a symlink). Build a new path with the parent's # canonical path and compare the files f = File(_path.join(can_parent.getAbsolutePath(), f.getName())) if f.getAbsolutePath() != f.getCanonicalPath(): return stat_result((_stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0)) # Not a link, only now can we determine if it exists (because # File.exists() returns False for dead links) if not f.exists(): raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) return stat(path)
def __deployOsbCfg(configPrefix, componentProperties): configJarFilename = componentProperties.getProperty( configPrefix + PROPERTY_OSB_CFG_SUFFIX_FILE) customisationFilename = componentProperties.getProperty( configPrefix + PROPERTY_OSB_CFG_SUFFIX_CUSTOM) log.info("Deploying OSB configuration from file '" + configJarFilename + "'") if not customisationFilename is None and len(customisationFilename) > 0: log.info("Customising using file '" + customisationFilename + "'") domainRuntime() infile = File(configJarFilename) # TODO - verify file exists infile = infile.getAbsoluteFile() # enables server to find the file sessionMBean = findService("SessionManagement", OSB_SESSION_BEAN) sessionName = getNewSessionName() sessionMBean.createSession(sessionName) # obtain the ALSBConfigurationMBean instance that operates # on the session that has just been created. Notice that # the name of the mbean contains the session name. alsbSession = findService("ALSBConfiguration." + sessionName, OSB_CONFIG_BEAN) alsbSession.uploadJarFile(__readBytes(infile)) plan = alsbSession.getImportJarInfo().getDefaultImportPlan() plan.setPreserveExistingEnvValues(false) alsbSession.importUploaded(plan) if not customisationFilename is None and len(customisationFilename) > 0: customiseImport(alsbSession, customisationFilename) # activate changes performed in the session sessionMBean.activateSession( sessionName, "Imported new application via " + configJarFilename)