def __call__(self): grinder.logger.info( 'Checking grinder.agents to see if test needs to run') locationCount = len(helper.getLocationIds()) if locationCount > 0: grinder.logger.info( "Found %d locations for key %s" % (locationCount, helper.getLocationPropertyKey())) maxAgents = grinder.properties.getInt('grinder.agents', 100) if maxAgents <= grinder.agentNumber: grinder.logger.info( 'Not running agent %d because the max number of agents was %d' % (grinder.agentNumber, maxAgents)) return grinder.logger.info('Running agent') pullTest() pushTest() grinder.sleep( Long.parseLong(grinder.properties.get('time.between.sync.ms'))) else: grinder.logger.info('No location assigned to this agent: %s' % helper.getLocationPropertyKey())
def __activate__(self, context): self.velocityContext = context self.services = context["Services"] self.log = context["log"] self.sessionState = context["sessionState"] self.portalDir = context["portalDir"] self.__result = None self.__token = None self.__portalName = context["page"].getPortal().getName() self.__authors = [] self.__relatedResources = [] self.__enabledInAllViews = False self.__enabledInViews = [] self.__metadataPrefix = "" self.__sessionExpiry = Long.parseLong(JsonConfig().get("portal/oai-pmh/sessionExpiry")) self.__resumptionTokenList = self.sessionState.get("resumptionTokenList") if self.__resumptionTokenList == None: self.__resumptionTokenList = {} #Check if there's resumption token exist in the formData self.__currentToken = None resumptionToken = self.vc("formData").get("resumptionToken") if resumptionToken: if self.__resumptionTokenList.has_key(resumptionToken): self.__currentToken = self.__resumptionTokenList[resumptionToken] print " * oai.py: formData=%s" % self.vc("formData") self.vc("request").setAttribute("Content-Type", "text/xml") self.__request = OaiPmhVerb(self.vc("formData"), self.__currentToken, self.sessionState) if self.getError() is None and \ self.getVerb() in ["GetRecord", "ListIdentifiers", "ListRecords"]: ## Only list those data if the metadata format is enabled self.__metadataPrefix = self.vc("formData").get("metadataPrefix") if self.__metadataPrefix is None: self.__metadataPrefix = self.__currentToken.getMetadataPrefix() self.__enabledInAllViews = Boolean.parseBoolean(JsonConfig().get("portal/oai-pmh/metadataFormats/%s/enabledInAllViews" % self.__metadataPrefix, "false")) if self.__enabledInAllViews: self.__search() else: self.__enabledInViews = JsonConfig().getList("portal/oai-pmh/metadataFormats/%s/enabledViews" % self.__metadataPrefix) if self.__portalName in self.__enabledInViews: self.__search()
def __call__(self): grinder.logger.info('Checking grinder.agents to see if test needs to run') locationCount = len(helper.getLocationIds()) if locationCount > 0: grinder.logger.info("Found %d locations for key %s" % (locationCount, helper.getLocationPropertyKey())) maxAgents = grinder.properties.getInt('grinder.agents', 100) if maxAgents <= grinder.agentNumber: grinder.logger.info('Not running agent %d because the max number of agents was %d' % (grinder.agentNumber, maxAgents)) return grinder.logger.info('Running agent') pullTest() pushTest() grinder.sleep(Long.parseLong(grinder.properties.get('time.between.sync.ms'))) else: grinder.logger.info('No location assigned to this agent: %s' % helper.getLocationPropertyKey())
def DiscoveryMain(Framework): SV_TYPE_SERVER = 0x00000002L SV_TYPE_DOMAIN_CTRL = 0x00000008L SV_TYPE_DOMAIN_BAKCTRL = 0x00000010L SV_TYPE_DOMAIN_ENUM = 0x80000000L OSHVResult = ObjectStateHolderVector() probe_name = Framework.getDestinationAttribute('probe_name') try: netUtil = MsNetworkUtil() domainsOutput = netUtil.doNetServerEnum('NULL', SV_TYPE_DOMAIN_ENUM, 'NULL') if domainsOutput != None: MsDomainsList = getMsDomainNameList (Framework) netUtilGetServer = MsNetworkUtil() for domainInfo in domainsOutput: domainName = domainInfo[0] domainType = Long.parseLong(domainInfo[1]) #Check if the current domain is to be discovered (if not, just continue to the next domain) if (MsDomainsList != None) and (domainName not in MsDomainsList): continue oshMsDomain = ObjectStateHolder('msdomain') oshMsDomain.setStringAttribute('data_name', domainName) if (domainType & SV_TYPE_DOMAIN_CTRL) !=0: oshMsDomain.setStringAttribute('msdomain_type', 'PDC') elif (domainType & SV_TYPE_DOMAIN_BAKCTRL) != 0: oshMsDomain.setStringAttribute('msdomain_type', 'BDC') hostsOutput = netUtilGetServer.doNetServerEnum('NULL', SV_TYPE_SERVER, domainName) if hostsOutput != None: oshMsDomain.setStringAttribute('probe_name', probe_name) OSHVResult.add(oshMsDomain) except: errorMsg = str(sys.exc_info()[1]).strip() Framework.reportError('Failed to discovery MS Domains :' + errorMsg) logger.errorException('Failed to discovery MS Domains') return OSHVResult
def __init__(self, additionalVariables): " initialize oracle database" self.__hostname = "localhost"; try: self.__hostname = InetAddress.getLocalHost().getCanonicalHostName() except: type, value, traceback = sys.exc_info() logger.severe("Hostname error:" + `value`) additionalVariables.add(RuntimeContextVariable("ORACLE_HOSTNAME", self.__hostname, RuntimeContextVariable.ENVIRONMENT_TYPE)) dbPassword = getVariableValue("DB_PASSWORD_ALL") if dbPassword and dbPassword.strip(): self.__sysPassword = dbPassword additionalVariables.add(RuntimeContextVariable("SYS_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) additionalVariables.add(RuntimeContextVariable("DBSNMP_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)); additionalVariables.add(RuntimeContextVariable("SYSMAN_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) additionalVariables.add(RuntimeContextVariable("SYSTEM_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)); else: self.__sysPassword = getVariableValue("SYS_PWD") dbDataLocation = getVariableValue("DB_DATA_LOC") if dbDataLocation and os.path.isdir(dbDataLocation): dbName = getVariableValue("DB_NAME") dbDataDir = os.path.join(dbDataLocation, dbName) if os.path.isdir(dbDataDir): logger.info("DB Data directory already exists:" + dbDataDir + "; Setting DB_INSTALL_OPTION to INSTALL_DB_SWONLY") additionalVariables.add(RuntimeContextVariable( "DB_INSTALL_OPTION", "INSTALL_DB_SWONLY", RuntimeContextVariable.ENVIRONMENT_TYPE)) tcpPort = getVariableValue("TCP_PORT"); self.__serviceName = getVariableValue("DB_GLOBAL_NAME") sb = StringBuilder("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)") sb.append("(HOST=").append(self.__hostname).append(")") sb.append("(PORT=").append(tcpPort).append("))") sb.append("(CONNECT_DATA=(SERVICE_NAME=").append(self.__serviceName).append(")))") self.__oracleServiceUrl = sb.toString() logger.info("Oracle listener service URL:" + self.__oracleServiceUrl) self.__jdbcUrl = "jdbc:oracle:thin:@" + self.__hostname +":"+ tcpPort + ":" + self.__serviceName runtimeContext.addVariable(RuntimeContextVariable("JDBC_URL", self.__jdbcUrl, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver JDBC Url", True, RuntimeContextVariable.NO_INCREMENT)) oracleDriver = "oracle.jdbc.OracleDriver" runtimeContext.addVariable(RuntimeContextVariable("JDBC_DRIVER", oracleDriver, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver class", True, RuntimeContextVariable.NO_INCREMENT)) self.__dbControl = Boolean.parseBoolean(getVariableValue("CONFIG_DBCONTROL", "false")) if self.__dbControl: self.__dbCtrlPort = getVariableValue("DBCONTROL_HTTP_PORT") additionalVariables.add(RuntimeContextVariable( "HTTPS_PORT", self.__dbCtrlPort, RuntimeContextVariable.STRING_TYPE)) oracleDir = getVariableValue("ORACLE_DIR") self.__markerFilePath = os.path.join(oracleDir, ".#dsoracle") self.__maintFilePath = getVariableValue("ORACLE_MAINT_FILE") dbInstallOption = getVariableValue("DB_INSTALL_OPTION") if dbInstallOption == "INSTALL_DB_AND_CONFIG": globalLockString = "OracleEnabler-" + self.__hostname logger.info("Requesting Global Lock with name: " + globalLockString) domain = proxy.getContainer().getCurrentDomain() options = domain.getOptions() maxActivationTimeOut = options.getProperty(Options.MAX_ACTIVATION_TIME_IN_SECONDS) lockTimeOut = Long.parseLong(maxActivationTimeOut) * 1000 acquired = ContainerUtils.acquireGlobalLock(globalLockString, lockTimeOut , lockTimeOut) if acquired: logger.info("Acquired Global lock with name: " + globalLockString) else: logger.severe("Could not acquire Global lock with name: " + globalLockString) raise Exception("Could not acquire Global lock with name: " + globalLockString)
#print "parameters: ",parameters #end parameterScan #=============================================== # Get file path #=============================================== print "begin" message = container.getInputMessage(0) messageBody = message.getBodyContentAsString() #if inputPortNr == 0: print "input 0: ",messageBody file_path = messageBody message = container.getInputMessage(1) messageBody = Long.parseLong(message.getBodyContentAsString()) #if inputPortNr == 1: print "input 1: ",messageBody n_steps = messageBody message = container.getInputMessage(2) messageBody = Double.parseDouble(message.getBodyContentAsString()) print "input 2: ",messageBody integration_time = messageBody message = container.getInputMessage(3) messageBody = message.getBodyContentAsString() print "input 3: ",messageBody stringTable = messageBody.split(",") start_position_actuators_1D = []
def _getIndex(self, even, odd): mergePolicy = LogDocMergePolicy() mergePolicy.setMergeFactor(1000) directory = RAMDirectory() self.dirs.append(directory) writer = self.getWriter(directory=directory, analyzer=SimpleAnalyzer(Version.LUCENE_CURRENT), maxBufferedDocs=2, mergePolicy=mergePolicy) if self.dvStringSorted: # Index sorted stringDVType = FieldInfo.DocValuesType.SORTED elif self.notSorted: # Index non-sorted stringDVType = FieldInfo.DocValuesType.BINARY else: # sorted anyway stringDVType = FieldInfo.DocValuesType.SORTED ft1 = FieldType() ft1.setStored(True) ft2 = FieldType() ft2.setIndexed(True) for i in xrange(len(self.data)): if (i % 2 == 0 and even) or (i % 2 == 1 and odd): doc = Document() doc.add(Field("tracer", self.data[i][0], ft1)) doc.add(TextField("contents", self.data[i][1], Field.Store.NO)) if self.data[i][2] is not None: doc.add(StringField("int", self.data[i][2], Field.Store.NO)) if self.supportsDocValues: doc.add(NumericDocValuesField("int_dv", Long.parseLong(self.data[i][2]))) if self.data[i][3] is not None: doc.add(StringField("float", self.data[i][3], Field.Store.NO)) if self.supportsDocValues: doc.add(FloatDocValuesField("float_dv", Float.parseFloat(self.data[i][3]))) if self.data[i][4] is not None: doc.add(StringField("string", self.data[i][4], Field.Store.NO)) if self.supportsDocValues: if stringDVType == FieldInfo.DocValuesType.SORTED: doc.add(SortedDocValuesField("string_dv", BytesRef(self.data[i][4]))) elif stringDVType == FieldInfo.DocValuesType.BINARY: doc.add(BinaryDocValuesField("string_dv", BytesRef(self.data[i][4]))) else: raise ValueError("unknown type " + stringDVType) if self.data[i][5] is not None: doc.add(StringField("custom", self.data[i][5], Field.Store.NO)) if self.data[i][6] is not None: doc.add(StringField("i18n", self.data[i][6], Field.Store.NO)) if self.data[i][7] is not None: doc.add(StringField("long", self.data[i][7], Field.Store.NO)) if self.data[i][8] is not None: doc.add(StringField("double", self.data[i][8], Field.Store.NO)) if self.supportsDocValues: doc.add(NumericDocValuesField("double_dv", Double.doubleToRawLongBits(Double.parseDouble(self.data[i][8])))) if self.data[i][9] is not None: doc.add(StringField("short", self.data[i][9], Field.Store.NO)) if self.data[i][10] is not None: doc.add(StringField("byte", self.data[i][10], Field.Store.NO)) if self.data[i][11] is not None: doc.add(StringField("parser", self.data[i][11], Field.Store.NO)) for f in doc.getFields(): if f.fieldType().indexed() and not f.fieldType().omitNorms(): Field.cast_(f).setBoost(2.0) writer.addDocument(doc) reader = writer.getReader() writer.close() return self.getSearcher(reader=reader)
def __init__(self, additionalVariables): " initialize oracle database" self.__hostname = "localhost" try: self.__hostname = InetAddress.getLocalHost().getCanonicalHostName() except: type, value, traceback = sys.exc_info() logger.severe("Hostname error:" + ` value `) additionalVariables.add( RuntimeContextVariable("ORACLE_HOSTNAME", self.__hostname, RuntimeContextVariable.ENVIRONMENT_TYPE, "Oracle Hostname", True, RuntimeContextVariable.NO_INCREMENT)) listenAddress = getVariableValue("LISTEN_ADDRESS") additionalVariables.add( RuntimeContextVariable("ORACLE_LISTEN_ADDRESS", listenAddress, RuntimeContextVariable.ENVIRONMENT_TYPE, "Oracle Listen Address", True, RuntimeContextVariable.NO_INCREMENT)) dbPassword = getVariableValue("DB_PASSWORD_ALL") if dbPassword and dbPassword.strip(): self.__sysPassword = dbPassword additionalVariables.add( RuntimeContextVariable( "SYS_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) additionalVariables.add( RuntimeContextVariable( "DBSNMP_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) additionalVariables.add( RuntimeContextVariable( "SYSMAN_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) additionalVariables.add( RuntimeContextVariable( "SYSTEM_PWD", dbPassword, RuntimeContextVariable.ENVIRONMENT_TYPE)) else: self.__sysPassword = getVariableValue("SYS_PWD") dbDataLocation = getVariableValue("DB_DATA_LOC") if dbDataLocation and os.path.isdir(dbDataLocation): dbName = getVariableValue("DB_NAME") dbDataDir = os.path.join(dbDataLocation, dbName) if os.path.isdir(dbDataDir): logger.info("DB Data directory already exists:" + dbDataDir + "; Setting DB_INSTALL_OPTION to INSTALL_DB_SWONLY") additionalVariables.add( RuntimeContextVariable( "DB_INSTALL_OPTION", "INSTALL_DB_SWONLY", RuntimeContextVariable.ENVIRONMENT_TYPE)) tcpPort = getVariableValue("TCP_PORT") self.__serviceName = getVariableValue("DB_GLOBAL_NAME") sb = StringBuilder( "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)") sb.append("(HOST=").append(self.__hostname).append(")") sb.append("(PORT=").append(tcpPort).append("))") sb.append("(CONNECT_DATA=(SERVICE_NAME=").append( self.__serviceName).append(")))") self.__oracleServiceUrl = sb.toString() logger.info("Oracle listener service URL:" + self.__oracleServiceUrl) self.__jdbcUrl = "jdbc:oracle:thin:@" + self.__hostname + ":" + tcpPort + ":" + self.__serviceName additionalVariables.add( RuntimeContextVariable("JDBC_URL", self.__jdbcUrl, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver JDBC Url", True, RuntimeContextVariable.NO_INCREMENT)) oracleDriver = "oracle.jdbc.OracleDriver" additionalVariables.add( RuntimeContextVariable("JDBC_DRIVER", oracleDriver, RuntimeContextVariable.STRING_TYPE, "Oracle Thin Driver class", True, RuntimeContextVariable.NO_INCREMENT)) self.__dbControl = Boolean.parseBoolean( getVariableValue("CONFIG_DBCONTROL", "false")) if self.__dbControl: self.__dbCtrlPort = getVariableValue("DBCONTROL_HTTP_PORT") additionalVariables.add( RuntimeContextVariable("HTTPS_PORT", self.__dbCtrlPort, RuntimeContextVariable.STRING_TYPE)) oracleDir = getVariableValue("ORACLE_DIR") self.__markerFilePath = os.path.join(oracleDir, ".#dsoracle") self.__maintFilePath = getVariableValue("ORACLE_MAINT_FILE") dbInstallOption = getVariableValue("DB_INSTALL_OPTION") if dbInstallOption == "INSTALL_DB_AND_CONFIG": globalLockString = "OracleEnabler-" + self.__hostname logger.info("Requesting Global Lock with name: " + globalLockString) domain = proxy.getContainer().getCurrentDomain() options = domain.getOptions() maxActivationTimeOut = options.getProperty( Options.MAX_ACTIVATION_TIME_IN_SECONDS) lockTimeOut = Long.parseLong(maxActivationTimeOut) * 1000 acquired = ContainerUtils.acquireGlobalLock( globalLockString, lockTimeOut, lockTimeOut) if acquired: logger.info("Acquired Global lock with name: " + globalLockString) else: logger.severe("Could not acquire Global lock with name: " + globalLockString) raise Exception("Could not acquire Global lock with name: " + globalLockString)