From 7be16999270ec4883bae836f67d361973bde2bf5 Mon Sep 17 00:00:00 2001 From: Pontus Rydin Date: Tue, 30 Aug 2022 11:29:02 -0400 Subject: [PATCH] Added support for vRealize Operations Cloud (#53) * Added support for vR Ops Cloud * Bumped version. Added documentation --- README.md | 40 +++- pom.xml | 2 +- src/bin/exporttool.bat | 2 +- src/bin/exporttool.sh | 2 +- .../java/com/vmware/vropsexport/Client.java | 122 ++++++++----- .../java/com/vmware/vropsexport/Exporter.java | 62 ++----- .../java/com/vmware/vropsexport/Main.java | 171 ++++++------------ .../vropsexport/models/TokenAuthResponse.java | 70 +++++++ vrops-export.iml | 6 +- 9 files changed, 261 insertions(+), 216 deletions(-) create mode 100644 src/main/java/com/vmware/vropsexport/models/TokenAuthResponse.java diff --git a/README.md b/README.md index be7ba60..d3eb267 100644 --- a/README.md +++ b/README.md @@ -101,27 +101,35 @@ chmod +x exporttool.sh ## Command syntax ``` -usage: exporttool [-d ] [-e ] [-F ] [-H ] [-h] [-i] - [-l ] [-m ] [-n ] [-o ] [-P ] [-p ] - [-q] [-R ] [-s ] [-S] [-t ] [-T ] [--trustpass - ] [-u ] [-v] - +usage: exporttool [-d ] [--dumprest] [-e ] [-F ] [-G ] + [-H ] [-h] [-i] [-l ] [-m ] [-n ] + [--no-sniextension] [-o ] [-P ] [-p ] [-q] [-r + ] [-R ] [--resfetch ] [-s ] [-S] [-t ] [-T + ] [--trustpass ] [-u ] [-v] +Exports vRealize Operations Metrics -d,--definition Path to definition file + --dumprest Dump rest calls to output -e,--end Time period end (date format in definition file) -F,--list-fields Print name and keys of all fields to stdout + -G,--generate Generate template definition for resource + type -H,--host URL to vRealize Operations Host -h,--help Print a short help text -i,--ignore-cert Trust any cert (DEPRECATED!) -l,--lookback Lookback time - -m,--max-rows Maximum number of rows to fetch + -m,--max-rows Maximum number of rows to fetch (default=1000*thread count) -n,--namequery Name query + --no-sniextension Disable SNI extension. May be needed for very + old SSL implementations -o,--output Output file -P,--parent Parent resource (ResourceKind:resourceName) -p,--password Password -q,--quiet Quiet mode (no progress counter) + -r,--refreshtoken Refresh token -R,--resource-kinds List resource kinds + --resfetch Resource fetch count (default=1000) -s,--start Time period start (date format in definition file) -S,--streaming True streaming processing. Faster but less @@ -141,12 +149,32 @@ it encounters an untrusted certificate. If the user chooses to trust the certifi truststore and reused next time the tool is executed against that host. By default, the trusted certs are stored in $HOME/.vropsexport/truststore, but the location can be overridden using the -T flag. +### TLS handshake issues + +In some cases, especially with very old SSL/TLS implementations, you may see name verification errors. To remedy this, +please try the --no-sniextension command-line argument. + ### Authentication The vrops-export tool uses the local authentication source by default. Other sources can be specified by using the " username@source" syntax. Be aware that in the case of e.g. Active Directory, the string after the @-sign should be the name of the *authentication source* and not that of the Active Directory domain. +### Support for vRealize Operations Cloud + +As of version 3.2.0, vRealize Operations Cloud is supported. To export data from a cloud instance, use the following API +endpoind URLs as arguments to the `-H` option: + +United States: +`https://www.mgmt.cloud.vmware.com/vrops-cloud/suite-api` + +All other countries: +`https://.www.mgmt.cloud.vmware.com/vrops-cloud/suite-api` +Where `country` is the country code of your API endpoint. Should match the country code in your browser URL when +interacting with vRealize Operations Cloud. + +Use the `-r` option to log in using a refresh token/API token. + ### Notes: * Start and end dates will use the date format specified in the definition file. Since dates tend to contain spaces and diff --git a/pom.xml b/pom.xml index 1b8d62e..e965414 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ - 3.0.1 + 3.2.0 1.8 1.8 diff --git a/src/bin/exporttool.bat b/src/bin/exporttool.bat index c11ac89..53fcf25 100644 --- a/src/bin/exporttool.bat +++ b/src/bin/exporttool.bat @@ -25,4 +25,4 @@ SET CP=%DIR%\vrops-export-%VERSION%.jar IF [%JDBC_JAR%] == [] GOTO :NO_JDBC_JAR SET CP=%CP%;%JDBC_JAR% :NO_JDBC_JAR -JAVA -cp %CP% -Djsse.enableSNIExtension=false com.vmware.vropsexport.Main %* +JAVA -cp %CP% com.vmware.vropsexport.Main %* diff --git a/src/bin/exporttool.sh b/src/bin/exporttool.sh index a714600..538f10f 100644 --- a/src/bin/exporttool.sh +++ b/src/bin/exporttool.sh @@ -28,4 +28,4 @@ if [ -n "$JDBC_JAR" ] then CP=$CP:$JDBC_JAR fi -$JAVA -cp $CP -Djsse.enableSNIExtension=false com.vmware.vropsexport.Main "$@" +$JAVA -cp $CP com.vmware.vropsexport.Main "$@" diff --git a/src/main/java/com/vmware/vropsexport/Client.java b/src/main/java/com/vmware/vropsexport/Client.java index fcfac5f..905e082 100644 --- a/src/main/java/com/vmware/vropsexport/Client.java +++ b/src/main/java/com/vmware/vropsexport/Client.java @@ -22,23 +22,14 @@ import com.vmware.vropsexport.exceptions.ExporterException; import com.vmware.vropsexport.models.AuthRequest; import com.vmware.vropsexport.models.AuthResponse; +import com.vmware.vropsexport.models.TokenAuthResponse; import com.vmware.vropsexport.security.ExtendableTrustStrategy; import com.vmware.vropsexport.security.RecoverableCertificateException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.List; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLHandshakeException; import org.apache.commons.io.IOUtils; import org.apache.http.HttpException; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.http.client.config.CookieSpecs; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; @@ -54,6 +45,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLHandshakeException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.List; + @SuppressWarnings("WeakerAccess") public class Client { private static final Logger log = LogManager.getLogger(Client.class); @@ -68,16 +71,15 @@ public class Client { private final String urlBase; - private final String authToken; + private String authToken; private final boolean dumpRest; - public Client( - final String urlBase, - String username, - final String password, - final KeyStore extendedTrust, - final boolean dumpRest) + private String tokenPrefix; + + private final ExtendableTrustStrategy trustStrategy; + + public Client(final String urlBase, final KeyStore extendedTrust, final boolean dumpRest) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException, HttpException, ExporterException { this.urlBase = urlBase; @@ -89,12 +91,12 @@ public Client( .setConnectTimeout(CONNTECTION_TIMEOUT_MS) .setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT_MS) .setSocketTimeout(SOCKET_TIMEOUT_MS) + .setCookieSpec(CookieSpecs.STANDARD) .build(); - final ExtendableTrustStrategy extendedTrustStrategy = - new ExtendableTrustStrategy(extendedTrust); + trustStrategy = new ExtendableTrustStrategy(extendedTrust); final SSLContext sslContext = - SSLContexts.custom().loadTrustMaterial(null, extendedTrustStrategy).build(); + SSLContexts.custom().loadTrustMaterial(null, trustStrategy).build(); final SSLConnectionSocketFactory sslf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); final Registry socketFactoryRegistry = @@ -108,41 +110,67 @@ public Client( .setSSLSocketFactory(sslf) .setConnectionManager(cm) .setDefaultRequestConfig(requestConfig) - . - // setRetryHandler(new DefaultHttpRequestRetryHandler(3, false)). - setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) .build(); - // Authenticate - // try { - // User may be in a non-local auth source. - // - int p = username.indexOf('\\'); - String authSource = null; - if (p != -1) { - authSource = username.substring(0, p); - username = username.substring(p + 1); - } else { - p = username.indexOf('@'); - if (p != -1) { - authSource = username.substring(p + 1); - username = username.substring(0, p); - } - } - final AuthRequest rq = new AuthRequest(authSource, username, password); - final AuthResponse response = - postJsonReturnJson("/suite-api/api/auth/token/acquire", rq, AuthResponse.class); - authToken = response.getToken(); + // Make a dummy API call to make sure we have our certs in order + log.debug("Hitting dummy URL to get certs"); + getStream("/suite-api/api/resources"); } catch (final SSLHandshakeException e) { // If we captured a cert, it's recoverable by asking the user to trust it. // - final X509Certificate[] cc = extendedTrustStrategy.getCapturedCerts(); + final X509Certificate[] cc = trustStrategy.getCapturedCerts(); if (cc == null) { throw e; } throw new RecoverableCertificateException(cc, e); + } catch (final HttpException e) { + // Ignore all other exceptions. We'll probably get a 401 here. + } + } + + public Client login(final String apiToken) throws HttpException, IOException { + final HttpPost post = + new HttpPost( + "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize"); + post.addHeader("Accept", "application/json"); + post.addHeader("Accept-Encoding", "gzip"); + post.addHeader("Content-Type", "application/x-www-form-urlencoded"); + post.setEntity(new StringEntity("refresh_token=" + apiToken)); + + final HttpResponse resp = client.execute(post); + checkResponse(resp); + final TokenAuthResponse tokenResp = + getObjectMapper().readValue(resp.getEntity().getContent(), TokenAuthResponse.class); + authToken = tokenResp.getAccess_token(); + tokenPrefix = "CSPToken "; + return this; + } + + public Client login(String username, final String password) + throws HttpException, IOException, RecoverableCertificateException { + + // User may be in a non-local auth source. + // + int p = username.indexOf('\\'); + String authSource = null; + if (p != -1) { + authSource = username.substring(0, p); + username = username.substring(p + 1); + } else { + p = username.indexOf('@'); + if (p != -1) { + authSource = username.substring(p + 1); + username = username.substring(0, p); + } } + final AuthRequest rq = new AuthRequest(authSource, username, password); + final AuthResponse response = + postJsonReturnJson("/suite-api/api/auth/token/acquire", rq, AuthResponse.class); + authToken = response.getToken(); + tokenPrefix = "vRealizeOpsToken "; + return this; } public T getJson(final String uri, final Class responseClass, final String... queries) @@ -168,7 +196,7 @@ private HttpResponse innerGet(String uri, final String... queries) get.addHeader("Accept", "application/json"); get.addHeader("Accept-Encoding", "gzip"); if (authToken != null) { - get.addHeader("Authorization", "vRealizeOpsToken " + authToken + ""); + get.addHeader("Authorization", tokenPrefix + authToken); } final HttpResponse resp = client.execute(get); checkResponse(resp); @@ -183,7 +211,7 @@ public InputStream postJsonReturnStream(final String uri, final Object payload) post.addHeader("Content-Type", "application/json"); post.addHeader("Accept-Encoding", "gzip"); if (authToken != null) { - post.addHeader("Authorization", "vRealizeOpsToken " + authToken + ""); + post.addHeader("Authorization", tokenPrefix + authToken + ""); } if (dumpRest) { log.debug("POST " + urlBase + uri); diff --git a/src/main/java/com/vmware/vropsexport/Exporter.java b/src/main/java/com/vmware/vropsexport/Exporter.java index 0ec0f4e..38171aa 100644 --- a/src/main/java/com/vmware/vropsexport/Exporter.java +++ b/src/main/java/com/vmware/vropsexport/Exporter.java @@ -18,43 +18,8 @@ package com.vmware.vropsexport; import com.vmware.vropsexport.exceptions.ExporterException; -import com.vmware.vropsexport.models.MetricsRequest; -import com.vmware.vropsexport.models.NamedResource; -import com.vmware.vropsexport.models.PageOfResources; -import com.vmware.vropsexport.models.PropertiesResponse; -import com.vmware.vropsexport.models.ResourceKind; -import com.vmware.vropsexport.models.ResourceKindResponse; -import com.vmware.vropsexport.models.ResourceStatKeysResponse; -import com.vmware.vropsexport.models.StatKeysResponse; -import com.vmware.vropsexport.processors.CSVPrinter; -import com.vmware.vropsexport.processors.ElasticSearchIndexer; -import com.vmware.vropsexport.processors.JsonPrinter; -import com.vmware.vropsexport.processors.SQLDumper; -import com.vmware.vropsexport.processors.WavefrontPusher; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.stream.Collectors; +import com.vmware.vropsexport.models.*; +import com.vmware.vropsexport.processors.*; import org.apache.commons.io.IOUtils; import org.apache.http.HttpException; import org.apache.http.NoHttpResponseException; @@ -67,6 +32,16 @@ import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.representer.Representer; +import java.io.*; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.stream.Collectors; + @SuppressWarnings("SameParameterValue") public class Exporter implements DataProvider { private static class Progress implements ProgressMonitor { @@ -131,19 +106,14 @@ public static boolean isProducingOutput(final Config conf) { } public Exporter( - final String urlBase, - final String username, - final String password, + final Client client, final int threads, final Config conf, final boolean verbose, - final boolean dumpRest, final boolean useTempFile, final int maxRows, - final int maxResourceFetch, - final KeyStore extendedTrust) - throws IOException, HttpException, KeyStoreException, NoSuchAlgorithmException, - KeyManagementException, ExporterException { + final int maxResourceFetch) + throws ExporterException { if (conf != null) { rspFactory = rspFactories.get(conf.getOutputFormat()); if (rspFactory == null) { @@ -156,7 +126,7 @@ public Exporter( this.conf = conf; this.maxRows = maxRows; this.maxResourceFetch = maxResourceFetch; - client = new Client(urlBase, username, password, extendedTrust, dumpRest); + this.client = client; executor = new ThreadPoolExecutor( diff --git a/src/main/java/com/vmware/vropsexport/Main.java b/src/main/java/com/vmware/vropsexport/Main.java index 418877b..6b7f1b9 100644 --- a/src/main/java/com/vmware/vropsexport/Main.java +++ b/src/main/java/com/vmware/vropsexport/Main.java @@ -22,12 +22,14 @@ import com.vmware.vropsexport.security.CertUtils; import com.vmware.vropsexport.security.RecoverableCertificateException; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; +import org.apache.commons.cli.*; +import org.apache.http.HttpException; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.builder.api.*; +import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration; + +import java.io.*; import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStore; @@ -38,21 +40,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Scanner; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.apache.http.HttpException; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.config.Configurator; -import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder; -import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder; -import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory; -import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder; -import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder; -import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration; public class Main { static { @@ -72,8 +59,8 @@ public class Main { private static final int DEFAULT_ROWS_PER_THREAD = 1000; public static void main(final String[] args) throws Exception { + // Parse command line - // final CommandLineParser parser = new DefaultParser(); final Options opts = defineOptions(); CommandLine commandLine = null; @@ -84,8 +71,8 @@ public static void main(final String[] args) throws Exception { "Error parsing command. Use -h option for help. Details: " + e.getMessage()); System.exit(1); } + // Help requested? - // if (commandLine.hasOption('h')) { final HelpFormatter hf = new HelpFormatter(); final String head = "Exports vRealize Operations Metrics"; @@ -95,20 +82,26 @@ public static void main(final String[] args) throws Exception { } try { // Extract command options and do sanity checks. - // int threads = 10; + + // Using refresh token + final String refreshToken = commandLine.getOptionValue('r'); final String username = commandLine.getOptionValue('u'); - if (username == null) { - throw new ExporterException("Username must be specified"); - } String password = commandLine.getOptionValue('p'); + if (refreshToken != null && username != null) { + throw new ExporterException("Refresh token and user name are mutually exclusive"); + } + if (refreshToken == null) { + if (username == null) { + throw new ExporterException("Username must be specified"); + } - // Prompt for password if not specified. - // - if (password == null) { - System.err.print("Password: "); - final char[] chp = System.console().readPassword(); - password = new String(chp); + // Prompt for password if not specified. + if (password == null) { + System.err.print("Password: "); + final char[] chp = System.console().readPassword(); + password = new String(chp); + } } final String host = commandLine.getOptionValue('H'); if (host == null) { @@ -127,58 +120,34 @@ public static void main(final String[] args) throws Exception { final String trustPass = commandLine.getOptionValue("trustpass"); final boolean dumpRest = commandLine.hasOption("dumprest"); + // Disable SNIExtensions if specified. Only needed for very old SSL implementations + if (commandLine.hasOption("no-sniextension")) { + System.setProperty("jsse.enableSNIExtension", "false"); + } + + // Create the vR Ops client + final Client client = createClient(host, trustStore, trustPass, dumpRest); + if (refreshToken != null) { + client.login(refreshToken); + } else { + client.login(username, password); + } + // If we're just printing field names, we have enough parameters at this point. - // final String resourceKind = commandLine.getOptionValue('F'); if (resourceKind != null) { final Exporter exporter = - createExporter( - host, - username, - password, - threads, - null, - verbose, - dumpRest, - useTmpFile, - 5000, - 1000, - trustStore, - trustPass); + createExporter(client, threads, null, verbose, useTmpFile, 5000, 1000); exporter.printResourceMetadata(resourceKind, System.out); } else if (commandLine.hasOption('R')) { final String adapterKind = commandLine.getOptionValue('R'); final Exporter exporter = - createExporter( - host, - username, - password, - threads, - null, - verbose, - dumpRest, - useTmpFile, - 5000, - 1000, - trustStore, - trustPass); + createExporter(client, threads, null, verbose, useTmpFile, 5000, 1000); exporter.printResourceKinds(adapterKind, System.out); } else if (commandLine.hasOption('G')) { final String rk = commandLine.getOptionValue('G'); final Exporter exporter = - createExporter( - host, - username, - password, - threads, - null, - verbose, - dumpRest, - useTmpFile, - 5000, - 1000, - trustStore, - trustPass); + createExporter(client, threads, null, verbose, useTmpFile, 5000, 1000); exporter.generateExportDefinition(rk, System.out); } else { final String defFile = commandLine.getOptionValue('d'); @@ -189,7 +158,6 @@ public static void main(final String[] args) throws Exception { int maxRows = mrS != null ? Integer.parseInt(mrS) : 0; // Deal with lookback/time period - // final String lb = commandLine.getOptionValue('l'); final String startS = commandLine.getOptionValue('s'); final String endS = commandLine.getOptionValue('e'); @@ -236,7 +204,6 @@ public static void main(final String[] args) throws Exception { } // Read definition and run it! - // try (final Reader fr = new InputStreamReader(new FileInputStream(defFile), StandardCharsets.UTF_8)) { final Config conf = ConfigLoader.parse(fr); @@ -246,13 +213,11 @@ public static void main(final String[] args) throws Exception { // If we're outputting to a textual format that can dump to stdout, we supress the // progress counter, but // if we're dumping to e.g. SQL, we keep it on. This is a bit kludgy.. TODO: Revisit - // if (output == null && Exporter.isProducingOutput(conf) || verbose) { quiet = true; } // Deal with start and end dates - // long end = System.currentTimeMillis(); final long lbMs = lb != null ? parseLookback(lb) : 1000L * 60L * 60L * 24L; long begin = end - lbMs; @@ -270,19 +235,7 @@ public static void main(final String[] args) throws Exception { } } final Exporter exporter = - createExporter( - host, - username, - password, - threads, - conf, - verbose, - dumpRest, - useTmpFile, - maxRows, - maxRes, - trustStore, - trustPass); + createExporter(client, threads, conf, verbose, useTmpFile, maxRows, maxRes); if (output == null) { exporter.exportTo(System.out, begin, end, namePattern, parentSpec, quiet); } else { @@ -304,35 +257,25 @@ public static void main(final String[] args) throws Exception { } private static Exporter createExporter( - final String urlBase, - final String username, - final String password, + final Client client, final int threads, final Config conf, final boolean verbose, - final boolean dumpRest, final boolean useTempFile, final int maxRows, - final int maxRes, - final String trustStore, - final String trustPass) - throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, - KeyManagementException, HttpException, ExporterException { + final int maxRes) + throws ExporterException { + return new Exporter(client, threads, conf, verbose, useTempFile, maxRows, maxRes); + } + + private static Client createClient( + final String host, final String trustStore, final String trustPass, final boolean dumpRest) + throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException, + ExporterException, HttpException, KeyManagementException { for (; ; ) { final KeyStore ks = CertUtils.loadExtendedTrust(trustStore, trustPass); try { - return new Exporter( - urlBase, - username, - password, - threads, - conf, - verbose, - dumpRest, - useTempFile, - maxRows, - maxRes, - ks); + return new Client(host, ks, dumpRest); } catch (final RecoverableCertificateException e) { final boolean retry = promptForTrust(e.getCapturedCerts()[0], trustStore, trustPass); if (!retry) { @@ -372,6 +315,7 @@ private static Options defineOptions() { opts.addOption("P", "parent", true, "Parent resource (ResourceKind:resourceName)"); opts.addOption("u", "username", true, "Username"); opts.addOption("p", "password", true, "Password"); + opts.addOption("r", "refreshtoken", true, "Refresh token"); opts.addOption("o", "output", true, "Output file"); opts.addOption("H", "host", true, "URL to vRealize Operations Host"); opts.addOption("q", "quiet", false, "Quiet mode (no progress counter)"); @@ -387,6 +331,11 @@ private static Options defineOptions() { opts.addOption(null, "trustpass", true, "Truststore password (default=changeit)"); opts.addOption(null, "resfetch", true, "Resource fetch count (default=1000)"); opts.addOption(null, "dumprest", false, "Dump rest calls to output"); + opts.addOption( + null, + "no-sniextension", + false, + "Disable SNI extension. May be needed for very old SSL implementations"); opts.addOption("h", "help", false, "Print a short help text"); return opts; } diff --git a/src/main/java/com/vmware/vropsexport/models/TokenAuthResponse.java b/src/main/java/com/vmware/vropsexport/models/TokenAuthResponse.java new file mode 100644 index 0000000..1a37ba1 --- /dev/null +++ b/src/main/java/com/vmware/vropsexport/models/TokenAuthResponse.java @@ -0,0 +1,70 @@ +/* + * Copyright 2017-2021 VMware, Inc. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.vmware.vropsexport.models; + +public class TokenAuthResponse { + private String id_token; + + private String expires_in; + + private String scope; + + private String access_token; + + private String refresh_token; + + public String getId_token() { + return id_token; + } + + public void setId_token(final String id_token) { + this.id_token = id_token; + } + + public String getExpires_in() { + return expires_in; + } + + public void setExpires_in(final String expires_in) { + this.expires_in = expires_in; + } + + public String getScope() { + return scope; + } + + public void setScope(final String scope) { + this.scope = scope; + } + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(final String access_token) { + this.access_token = access_token; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(final String refresh_token) { + this.refresh_token = refresh_token; + } +} diff --git a/vrops-export.iml b/vrops-export.iml index 3aba31d..1c34170 100644 --- a/vrops-export.iml +++ b/vrops-export.iml @@ -17,9 +17,9 @@ - - - + + +