@Bean @ConditionalOnMissingBean public CloudFoundryClient cloudFoundryClient(CloudCredentials cc) throws MalformedURLException { URI uri = URI.create(this.loggregatorSourceProperties.getCloudFoundryApi()); CloudFoundryClient cloudFoundryClient = new CloudFoundryClient(cc, uri.toURL()); cloudFoundryClient.login(); return cloudFoundryClient; }
public static CloudApplication getTunnelAppInfo(CloudFoundryClient client) { return client.getApplication(TunnelHelper.getTunnelAppName()); }
@Override protected void doStart() { this.cloudFoundryClient.streamLogs(this.applicationName, new LoggregatorApplicationLogListener()); }
public static void deployTunnelApp(CloudFoundryClient client) { ClassPathResource cpr = new ClassPathResource("caldecott_helper.zip"); try { File temp = copyCaldecottZipFile(cpr); client.createApplication(TUNNEL_APP_NAME, new Staging("ruby19", "sinatra"), 64, Arrays.asList(new String[]{getRandomUrl(client, TUNNEL_APP_NAME)}), Arrays.asList(new String[] {}), false); client.uploadApplication(TUNNEL_APP_NAME, temp); client.updateApplicationEnv(TUNNEL_APP_NAME, Collections.singletonMap("CALDECOTT_AUTH", UUID.randomUUID().toString())); client.startApplication(TUNNEL_APP_NAME); temp.delete(); } catch (IOException e) { throw new TunnelException("Unable to deploy the Caldecott server application", e); } }
public CloudFoundryOperations getCloudFoundryOperations(String cloudControllerUrl, boolean selfSigned) throws MalformedURLException { URL url = new URL(cloudControllerUrl); // Proxies are always updated on each client call by the // CloudFoundryServerBehaviour Request as well as the client login // handler // therefore it is not critical to set the proxy in the client on client // creation HttpProxyConfiguration proxyConfiguration = getProxy(url); return new CloudFoundryClient(url, proxyConfiguration, selfSigned); }
public static void bindServiceToTunnelApp(CloudFoundryClient client, String serviceName) { if (getTunnelAppInfo(client).getServices().contains(serviceName)) { return; } client.stopApplication(getTunnelAppName()); client.bindService(getTunnelAppName(), serviceName); client.startApplication(getTunnelAppName()); }
public static String getRandomUrl(CloudFoundryClient client, String appname) { int range = 0x01000000; int r = new Random().nextInt(range - 1); StringBuilder url = new StringBuilder(); url.append(appname); url.append("-"); url.append(Integer.toHexString((r))); String domain = client.getCloudControllerUrl().getHost(); if (domain.startsWith("api.")) { domain = domain.substring(3); } else { url.append("-"); } url.append(domain); return url.toString(); }
public CloudFoundryOperations getCloudFoundryOperations(CloudCredentials credentials, URL url, CloudSpace session, boolean selfSigned) { // Proxies are always updated on each client call by the // CloudFoundryServerBehaviour Request as well as the client login // handler // therefore it is not critical to set the proxy in the client on // client // creation HttpProxyConfiguration proxyConfiguration = getProxy(url); return session != null ? new CloudFoundryClient(credentials, url, session, selfSigned) : new CloudFoundryClient(credentials, url, proxyConfiguration, selfSigned); }
@Bean @ConditionalOnMissingBean public CloudFoundryClient cloudFoundryClient(CloudCredentials cc) throws MalformedURLException { URI uri = URI.create(this.loggregatorSourceProperties.getCloudFoundryApi()); CloudFoundryClient cloudFoundryClient = new CloudFoundryClient(cc, uri.toURL()); cloudFoundryClient.login(); return cloudFoundryClient; }
public CloudFoundryOperations getCloudFoundryOperations(CloudCredentials credentials, URL url, String orgName, String spaceName, boolean selfsigned) { // Proxies are always updated on each client call by the // CloudFoundryServerBehaviour Request as well as the client login // handler // therefore it is not critical to set the proxy in the client on // client // creation HttpProxyConfiguration proxyConfiguration = getProxy(url); return new CloudFoundryClient(credentials, url, orgName, spaceName, proxyConfiguration, selfsigned); }
public static String getTunnelUri(CloudFoundryClient client) { String uriAuthority = client.getApplication(TunnelHelper.getTunnelAppName()).getUris().get(0); if (TUNNEL_URI_CACHE.containsKey(uriAuthority)) { return TUNNEL_URI_CACHE.get(uriAuthority); } String uriScheme = testUriSchemes(client, TUNNEL_URI_SCHEMES, uriAuthority); String uri = uriScheme + "//" + uriAuthority; TUNNEL_URI_CACHE.put(uriAuthority, uri); return uri; }
@Override protected void doStart() { this.cloudFoundryClient.streamLogs(this.applicationName, new LoggregatorApplicationLogListener()); }
/** * given the username and password, get the UAA token * @param username * @param password * @param targetAPI * @return * @throws MalformedURLException * @throws CloudFoundryException */ public static String getBluemixToken(String username, String password, String targetAPI, PrintStream printStream) throws MalformedURLException, CloudFoundryException { CloudCredentials cloudCredentials = new CloudCredentials(username, password); URL url = new URL(targetAPI); HttpProxyConfiguration configuration = buildProxyConfiguration(url); CloudFoundryClient client = new CloudFoundryClient(cloudCredentials, url, configuration, true); if (printStream != null) { printStream.println(getMessageWithPrefix(USERNAME_PASSWORD_DEPRECATED)); printStream.println(getMessageWithPrefix(LOGIN_IN_SUCCEED)); } return "bearer " + client.login().toString(); }
public static String getTunnelAuth(CloudFoundryClient client) { String auth = client.getApplication(TunnelHelper.getTunnelAppName()).getEnvAsMap().get(TUNNEL_AUTH_KEY); return auth; }