Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/529#discussion_r98007567
  
    --- Diff: 
locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java
 ---
    @@ -752,58 +783,32 @@ protected MachineLocation obtainOnce(ConfigBag setup) 
throws NoMachinesAvailable
                     sshHostAndPortOverride = Optional.absent();
                 }
     
    -            LoginCredentials initialCredentials = node.getCredentials();
    +            ManagementAddressResolveOptions resolveOptions = 
getManagementAddressResolveOptions(
    +                    node, setup, sshHostAndPortOverride, 
Optional.fromNullable(userCredentials));
    +            LocationNetworkInfoCustomizer networkInfoCustomizer = 
getLocationNetworkInfoCustomizer(setup);
     
    -            final HostAndPort managementHostAndPort = 
resolveManagementHostAndPort(
    -                    node, Optional.fromNullable(userCredentials), 
sshHostAndPortOverride, setup,
    -                    new ResolveOptions()
    -                            .windows(windows)
    -                            .expectConnectable(waitForConnectable)
    -                            
.pollForFirstReachableAddress(!"false".equalsIgnoreCase(setup.get(POLL_FOR_FIRST_REACHABLE_ADDRESS)))
    -                            .propagatePollForReachableFailure(true));
    +            ManagementAddressResolveResult hapandc = 
networkInfoCustomizer.resolve(this, node, setup, resolveOptions);
    +            final HostAndPort managementHostAndPort = 
hapandc.hostAndPort();
    +            LoginCredentials creds = hapandc.credentials();
    +            LOG.info("Using host-and-port={} and user={} when connecting 
to {}",
    +                    new Object[]{managementHostAndPort, creds.getUser(), 
node});
     
    -            if (skipJcloudsSshing) {
    -                if (waitForConnectable) {
    -                    if (windows) {
    -                        // TODO Does jclouds support any windows user 
setup?
    -                        initialCredentials = 
waitForWinRmAvailable(initialCredentials, managementHostAndPort, setup);
    -                    } else {
    -                        initialCredentials = 
waitForSshable(computeService, node, managementHostAndPort, setup);
    -                    }
    -                    userCredentials = createUser(computeService, node, 
managementHostAndPort, initialCredentials, setup);
    +            if (skipJcloudsSshing && waitForConnectable) {
    +                LoginCredentials createdCredentials = 
createUser(computeService, node, managementHostAndPort, creds, setup);
    +                if (createdCredentials != null) {
    +                    userCredentials = createdCredentials;
                     }
                 }
    -
    -            // Figure out which login-credentials to use
    -            LoginCredentials customCredentials = 
setup.get(CUSTOM_CREDENTIALS);
    -            if (customCredentials != null) {
    -                userCredentials = customCredentials;
    -                //set userName and other data, from these credentials
    -                Object oldUsername = setup.put(USER, 
customCredentials.getUser());
    -                LOG.debug("node {} username {} / {} (customCredentials)", 
new Object[] { node, customCredentials.getUser(), oldUsername });
    -                if (customCredentials.getOptionalPassword().isPresent()) 
setup.put(PASSWORD, customCredentials.getOptionalPassword().get());
    -                if (customCredentials.getOptionalPrivateKey().isPresent()) 
setup.put(PRIVATE_KEY_DATA, customCredentials.getOptionalPrivateKey().get());
    -            }
    -            if (userCredentials == null || 
(!userCredentials.getOptionalPassword().isPresent() && 
!userCredentials.getOptionalPrivateKey().isPresent())) {
    -                // We either don't have any userCredentials, or it is 
missing both a password/key.
    -                // TODO See waitForSshable, which now handles if the 
node.getLoginCredentials has both a password+key
    -                userCredentials = extractVmCredentials(setup, node, 
initialCredentials);
    -            }
                 if (userCredentials == null) {
    -                // TODO See waitForSshable, which now handles if the 
node.getLoginCredentials has both a password+key
    -                userCredentials = extractVmCredentials(setup, node, 
initialCredentials);
    -            }
    -            if (userCredentials != null) {
    -                node = 
NodeMetadataBuilder.fromNodeMetadata(node).credentials(userCredentials).build();
    -            } else {
    -                // only happens if something broke above...
    -                userCredentials = 
LoginCredentials.fromCredentials(node.getCredentials());
    +                userCredentials = creds;
                 }
    +
                 // store the credentials, in case they have changed
                 putIfPresentButDifferent(setup, 
JcloudsLocationConfig.PASSWORD, userCredentials.getOptionalPassword().orNull());
                 putIfPresentButDifferent(setup, 
JcloudsLocationConfig.PRIVATE_KEY_DATA, 
userCredentials.getOptionalPrivateKey().orNull());
     
                 // Wait for the VM to be reachable over SSH
    +            // TODO: this has already been tested by 
locationnetworkinfocustomizer
    --- End diff --
    
    Guard it with with a `!CHECK_CREDENTIALS` then?


---
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.
---

Reply via email to