List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:com.ibm.watson.WatsonTranslate.java
private static void processVCAP_Services() { logger.info("Processing VCAP_SERVICES"); JSONObject sysEnv = getVcapServices(); logger.info("Looking for: " + translationService); if (sysEnv != null && sysEnv.containsKey(translationService)) { JSONArray services = (JSONArray) sysEnv.get(translationService); JSONObject service = (JSONObject) services.get(0); JSONObject credentials = (JSONObject) service.get("credentials"); baseURLTranslation = (String) credentials.get("url"); usernameTranslation = (String) credentials.get("username"); passwordTranslation = (String) credentials.get("password"); logger.info("baseURL = " + baseURLTranslation); logger.info("username = " + usernameTranslation); logger.info("password = " + passwordTranslation); } else {/*from www .j a v a 2 s. co m*/ logger.info("Attempting to use locally defined service credentials"); baseURLTranslation = System.getenv("WATSON_URL"); usernameTranslation = System.getenv("WATSON_USERNAME"); passwordTranslation = System.getenv("WATSON_PASSWORD"); logger.debug("Watson url {} username {} and password {}", baseURLTranslation, usernameTranslation, passwordTranslation); } }
From source file:com.elasticbox.jenkins.k8s.cfg.PluginInitializer.java
@Initializer(after = InitMilestone.JOB_LOADED) public static void checkLocalKubernetesCloud() { LOGGER.info(NAME_PREFIX + "Checking if running inside a Kubernetes Cloud (Auto-discovery)..."); final String kubernetesAddr = System.getenv(KUBERNETES_API_SERVER_ADDR); final String kubernetesAddrPort = System.getenv(KUBERNETES_API_SERVER_PORT); if (PluginHelper.anyOfThemIsBlank(kubernetesAddr, kubernetesAddrPort)) { LOGGER.info(NAME_PREFIX + "Not running inside a Kubernetes Cloud."); return;// w ww . j a v a 2s.c o m } String kubernetesUri = "https://" + kubernetesAddr + ":" + kubernetesAddrPort; LOGGER.info(NAME_PREFIX + "Kubernetes Cloud found! Checking if local Kubernetes cloud is configured at: " + kubernetesUri); final Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { return; } if (jenkins.getCloud(LOCAL_CLOUD_NAME) != null) { LOGGER.info(NAME_PREFIX + "Local Kubernetes Cloud already configured."); return; } try { if (!kubeRepository.testConnection(kubernetesUri)) { LOGGER.warning(NAME_PREFIX + "No valid Local Kubernetes Cloud connection obtained."); return; } final ChartRepositoryConfig chartRepositoryConfig = new ChartRepositoryConfig(DEFAULT_HELM_CHART_REPO, DEFAULT_HELM_CHART_REPO_URL, StringUtils.EMPTY); final PodSlaveConfig defaultPodSlaveConfig = getDefaultPodSlaveConfig(); String credentialsId = checkLocalKubernetesToken(); final KubernetesCloud cloud = new KubernetesCloud(LOCAL_CLOUD_NAME, LOCAL_CLOUD_NAME, kubernetesUri, DEFAULT_NAMESPACE, MAX_SLAVES, credentialsId, StringUtils.EMPTY, Collections.singletonList(chartRepositoryConfig), (defaultPodSlaveConfig != null) ? Collections.singletonList(defaultPodSlaveConfig) : Collections.EMPTY_LIST); LOGGER.info(NAME_PREFIX + "Adding local Kubernetes Cloud configuration: " + cloud); jenkins.clouds.add(cloud); jenkins.setNumExecutors(0); } catch (RepositoryException exception) { LOGGER.log(Level.SEVERE, NAME_PREFIX + exception.getCausedByMessages(), exception); } catch (IOException excep) { LOGGER.log(Level.SEVERE, NAME_PREFIX + "Error setting number of executors in master to 0.", excep); } }
From source file:com.github.lynxdb.server.common.CassandraConfig.java
@Override protected AuthProvider getAuthProvider() { return new PlainTextAuthProvider(System.getenv("cassandra_username"), System.getenv("cassandra_password")); }
From source file:com.ecsteam.cloudlaunch.services.statistics.CloudFoundryStatisticsProvider.java
@Override public ApplicationStatistics getCurrentStatistics() throws IOException { String vcapApplicationString = System.getenv("VCAP_APPLICATION"); application = (new ObjectMapper()).readValue(vcapApplicationString, VcapApplication.class); CloudFoundryOperations client = cloudFoundryClient(); ApplicationStats cfAppStats = client.getApplicationStats(application.getApplicationName()); Limits limits = application.getLimits(); if (limits == null) { limits = new Limits(); limits.setDisk(-1);/* w ww . j a va 2 s .c o m*/ limits.setFds(-1); limits.setMem(-1); } ApplicationStatistics stats = new ApplicationStatistics(); stats.setName(application.getApplicationName()); stats.setId(application.getApplicationId()); stats.setDiskLimit(limits.getDisk() * MEGS_TO_BYTES); stats.setRamLimit(limits.getMem() * MEGS_TO_BYTES); stats.setHost(application.getHost()); stats.setPort(application.getPort()); stats.setActiveInstance(application.getActiveInstanceIndex()); addInstanceInfo(stats, cfAppStats); return stats; }
From source file:com.netscape.cms.tomcat.PKIListener.java
@Override public void lifecycleEvent(LifecycleEvent event) { String type = event.getType(); logger.info("PKIListener: " + event.getLifecycle().getClass().getName() + " [" + type + "]"); if (type.equals(Lifecycle.BEFORE_INIT_EVENT)) { String wdPipeName = System.getenv("WD_PIPE_NAME"); if (StringUtils.isNotEmpty(wdPipeName)) { startedByWD = true;//from w w w .j ava 2 s .co m logger.info("PKIListener: Initializing the watchdog"); WatchdogClient.init(); } logger.info("PKIListener: Initializing TomcatJSS"); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); String catalinaBase = System.getProperty("catalina.base"); File file = new File(catalinaBase + "/conf/server.xml"); Document doc = builder.parse(file); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); Element connector = (Element) xpath.evaluate( "/Server/Service[@name='Catalina']/Connector[@name='Secure']", doc, XPathConstants.NODE); TomcatJSS tomcatjss = TomcatJSS.getInstance(); String certDb = connector.getAttribute("certdbDir"); if (certDb != null) tomcatjss.setCertdbDir(certDb); String passwordClass = connector.getAttribute("passwordClass"); if (passwordClass != null) tomcatjss.setPasswordClass(passwordClass); String passwordFile = connector.getAttribute("passwordFile"); if (passwordFile != null) tomcatjss.setPasswordFile(passwordFile); String serverCertNickFile = connector.getAttribute("serverCertNickFile"); if (serverCertNickFile != null) tomcatjss.setServerCertNickFile(serverCertNickFile); String enableOCSP = connector.getAttribute("enableOCSP"); if (enableOCSP != null) tomcatjss.setEnableOCSP(Boolean.parseBoolean(enableOCSP)); String ocspResponderURL = connector.getAttribute("ocspResponderURL"); if (ocspResponderURL != null) tomcatjss.setOcspResponderURL(ocspResponderURL); String ocspResponderCertNickname = connector.getAttribute("ocspResponderCertNickname"); if (ocspResponderCertNickname != null) tomcatjss.setOcspResponderCertNickname(ocspResponderCertNickname); String ocspCacheSize = connector.getAttribute("ocspCacheSize"); if (ocspCacheSize != null) tomcatjss.setOcspCacheSize(Integer.parseInt(ocspCacheSize)); String ocspMinCacheEntryDuration = connector.getAttribute("ocspMinCacheEntryDuration"); if (ocspMinCacheEntryDuration != null) tomcatjss.setOcspMinCacheEntryDuration(Integer.parseInt(ocspMinCacheEntryDuration)); String ocspMaxCacheEntryDuration = connector.getAttribute("ocspMaxCacheEntryDuration"); if (ocspMaxCacheEntryDuration != null) tomcatjss.setOcspMaxCacheEntryDuration(Integer.parseInt(ocspMaxCacheEntryDuration)); String ocspTimeout = connector.getAttribute("ocspTimeout"); if (ocspTimeout != null) tomcatjss.setOcspTimeout(Integer.parseInt(ocspTimeout)); String strictCiphers = connector.getAttribute("strictCiphers"); if (strictCiphers != null) tomcatjss.setStrictCiphers(strictCiphers); String sslVersionRangeStream = connector.getAttribute("sslVersionRangeStream"); if (sslVersionRangeStream != null) tomcatjss.setSslVersionRangeStream(sslVersionRangeStream); String sslVersionRangeDatagram = connector.getAttribute("sslVersionRangeDatagram"); if (sslVersionRangeDatagram != null) tomcatjss.setSslVersionRangeDatagram(sslVersionRangeDatagram); String sslRangeCiphers = connector.getAttribute("sslRangeCiphers"); if (sslRangeCiphers != null) tomcatjss.setSslRangeCiphers(sslRangeCiphers); String sslOptions = connector.getAttribute("sslOptions"); if (sslOptions != null) tomcatjss.setSslOptions(sslOptions); String ssl2Ciphers = connector.getAttribute("ssl2Ciphers"); if (ssl2Ciphers != null) tomcatjss.setSsl2Ciphers(ssl2Ciphers); String ssl3Ciphers = connector.getAttribute("ssl3Ciphers"); if (ssl3Ciphers != null) tomcatjss.setSsl3Ciphers(ssl3Ciphers); String tlsCiphers = connector.getAttribute("tlsCiphers"); if (tlsCiphers != null) tomcatjss.setTlsCiphers(tlsCiphers); tomcatjss.init(); } catch (Exception e) { throw new RuntimeException(e); } } else if (type.equals(Lifecycle.AFTER_START_EVENT)) { if (startedByWD) { logger.info("PKIListener: Sending endInit to the watchdog"); WatchdogClient.sendEndInit(0); } verifySubsystems((Server) event.getLifecycle()); } }
From source file:com.twosigma.beaker.cpp.utils.CppKernel.java
public int execute(String mainCell, String type, ArrayList<String> otherCells) { String tmpDir = System.getenv("beaker_tmp_dir"); for (String cell : otherCells) { cLoad(tmpDir + "/lib" + cell + ".so"); }// ww w .ja v a 2s . c o m Object ret = cLoadAndRun(tmpDir + "/lib" + mainCell + ".so", type); try { FileOutputStream file = new FileOutputStream(tmpDir + "/" + mainCell + ".result"); BufferedOutputStream buffer = new BufferedOutputStream(file); ObjectOutputStream output = new ObjectOutputStream(buffer); output.writeObject(ret); output.close(); } catch (IOException ex) { logger.warn("Could not load file"); return 1; } return 0; }
From source file:com.handcraftedbits.bamboo.plugin.go.task.common.AbstractGoExecutableTaskConfigurator.java
@NotNull private String determineGoRoot() { final String goPath; final String goRootEnv = System.getenv(Constants.EnvironmentVariable.GOROOT); // Best case scenario: GOROOT is already defined in the environment. if (goRootEnv != null) { return goRootEnv.trim(); }//from w ww. java 2 s .c om // See if the Go capability has been defined. If so, we can use <path_to_go_executable>/.. as a best guess // for the correct GOROOT path. goPath = getTaskHelper().getCapabilityValue(GoCapabilityTypeModule.CAPABILITY_KEY_GO); if (!StringUtils.isEmpty(goPath)) { File goFile = new File(goPath).getParentFile(); if (goFile != null) { goFile = goFile.getParentFile(); if (goFile != null) { return goFile.getAbsolutePath(); } } } // Just return an empty string since we can't tell what GOROOT should be. return ""; }
From source file:com.redhat.developers.msa.hola.TracingConfiguration.java
@Produces @Singleton// w ww. j a v a 2s . c o m public Tracer tracer() { String jaegerURL = System.getenv("JAEGER_SERVER_HOSTNAME"); if (jaegerURL != null) { log.info("Using Jaeger tracer"); return jaegerTracer(jaegerURL); } log.info("Using Noop tracer"); return NoopTracerFactory.create(); }
From source file:com.mobilecashout.osprey.remote.RemoteClient.java
public RemoteClient(Environment environment, DeploymentContext context, Logger logger) throws RemoteClientException { RemoteClient instance = this; Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { instance.tryDisconnect();/*from ww w. ja v a 2s . co m*/ } }); this.logger = logger; try { JSch shellClient = new JSch(); shellClient.setKnownHosts(new FileInputStream(new File(System.getenv("HOME") + "/.ssh/known_hosts"))); ConnectorFactory connectorFactory = ConnectorFactory.getDefault(); Connector connector = connectorFactory.createConnector(); Properties config = new java.util.Properties(); config.put("PreferredAuthentications", "publickey"); if (context.project().options().containsKey("check_host_keys")) { String option = (boolean) context.project().options().get("check_host_keys") ? "yes" : "no"; JSch.setConfig("StrictHostKeyChecking", option); if (option.equals("no")) { logger.warn("WARNING: host key check is disabled!"); } } if (connector != null) { IdentityRepository remoteIdentityRepository = new RemoteIdentityRepository(connector); shellClient.setIdentityRepository(remoteIdentityRepository); } for (Target target : environment.targets()) { sessions.add(new RemoteTarget(connect(shellClient, target, context, config), target, context, environment)); } } catch (AgentProxyException | FileNotFoundException | JSchException e) { throw new RemoteClientException(e.getMessage()); } }
From source file:org.geowebcache.util.ApplicationContextProvider.java
public String getSystemVar(String varName, String defaultValue) { if (ctx == null) { String msg = "Application context was not set yet! Damn you Spring Framework :( "; log.error(msg);// w w w . j a v a2s .c om throw new RuntimeException(msg); } String tmpVar = ctx.getServletContext().getInitParameter(varName); if (tmpVar != null && tmpVar.length() > 7) { log.info("Using servlet init context parameter to configure " + varName + " to " + tmpVar); return tmpVar; } tmpVar = System.getProperty(varName); if (tmpVar != null && tmpVar.length() > 7) { log.info("Using Java environment variable to configure " + varName + " to " + tmpVar); return tmpVar; } tmpVar = System.getenv(varName); if (tmpVar != null && tmpVar.length() > 7) { log.info("Using System environment variable to configure " + varName + " to " + tmpVar); return tmpVar; } //tmpVar = ; log.info("No context parameter, system or Java environment variables found for " + varName); log.info("Reverting to " + defaultValue); return defaultValue; }