Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/529#discussion_r97370289
--- Diff:
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
---
@@ -1738,97 +1740,6 @@ protected LoginCredentials
initTemplateForCreateUser(Template template, ConfigBa
return userCreation.credentials();
}
- private static class ResolveOptions {
- boolean pollForFirstReachableAddress;
- boolean expectConnectable;
- boolean isWindows;
- boolean propagatePollForReachableFailure;
-
- ResolveOptions pollForFirstReachableAddress(boolean val) {
- pollForFirstReachableAddress = val;
- return this;
- }
- ResolveOptions expectConnectable(boolean val) {
- expectConnectable = val;
- return this;
- }
- ResolveOptions windows(boolean val) {
- isWindows = val;
- return this;
- }
- public ResolveOptions propagatePollForReachableFailure(boolean
val) {
- this.propagatePollForReachableFailure = val;
- return this;
- }
- }
-
- /**
- * Infers the hostAndPort to use for subsequent creation of the
- * {@link JcloudsSshMachineLocation} or {@link
JcloudsWinRmMachineLocation}.
- * This is expected to be the login host:port, for connecting to the VM
- * via ssh or WinRM.
- *
- * However, some VMs provisioned will not be sshable or reachable at
all.
- * In such cases, this method will likely return the first address
returned by
- * jclouds.
- *
- * For AWS, if we are allowed to SSH to the VM to find out its DNS
name, then we'll
- * return that fully qualified name (which we expect to be reachable
from inside
- * and outside the AWS region).
- */
- private HostAndPort resolveManagementHostAndPort(
- NodeMetadata node, Optional<LoginCredentials> userCredentials,
- Optional<HostAndPort> hostAndPortOverride, ConfigBag config,
ResolveOptions options) {
- boolean lookupAwsHostname =
Boolean.TRUE.equals(config.get(LOOKUP_AWS_HOSTNAME));
- String provider = config.get(CLOUD_PROVIDER);
- if (provider == null) provider= getProvider();
- int defaultPort;
- if (options.isWindows) {
- defaultPort = config.get(WinRmMachineLocation.USE_HTTPS_WINRM)
? 5986 : 5985;
- } else {
- defaultPort = node.getLoginPort();
- }
-
- if (hostAndPortOverride.isPresent()) {
- // Don't try to resolve it; just use it
- int port = hostAndPortOverride.get().hasPort() ?
hostAndPortOverride.get().getPort() : defaultPort;
- return
HostAndPort.fromParts(hostAndPortOverride.get().getHostText(), port);
- }
- if (options.expectConnectable && userCredentials.isPresent() &&
"aws-ec2".equals(provider) && lookupAwsHostname) {
- // Treat AWS as a special case because the DNS fully qualified
hostname in AWS is
- // (normally?!) a good way to refer to the VM from both inside
and outside of the
- // region.
- Maybe<String> result = getHostnameAws(node,
hostAndPortOverride, Suppliers.ofInstance(userCredentials.get()), config);
- if (result.isPresent()) {
- return HostAndPort.fromParts(result.get(), defaultPort);
- }
- }
- if (options.expectConnectable &&
options.pollForFirstReachableAddress) {
- try {
- String firstReachableAddress =
getFirstReachableAddress(node, config);
- return HostAndPort.fromParts(firstReachableAddress,
defaultPort);
- } catch (RuntimeException e) {
- if (options.propagatePollForReachableFailure) {
- throw Exceptions.propagate(e);
- } else {
- LOG.warn("No reachable address ({}/{}); falling back
to any advertised address; may cause future failures",
- getCreationString(config), node);
- }
- }
- }
-
- Iterable<String> addresses =
Iterables.concat(node.getPublicAddresses(), node.getPrivateAddresses());
- for (String address : addresses) {
- if (isAddressResolvable(address)) {
- return HostAndPort.fromParts(address, defaultPort);
- }
- }
- LOG.warn("No resolvable address in {} ({}/{}); using first; may
cause future failures",
- new Object[]{addresses, getCreationString(config), node});
- String host = Iterables.get(addresses, 0);
- return HostAndPort.fromParts(host, defaultPort);
- }
-
private boolean isAddressResolvable(String addr) {
--- End diff --
This can be deleted now.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---