Github user bostko commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/1087#discussion_r46672025 --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java --- @@ -2537,28 +2563,53 @@ protected LoginCredentials waitForWinRmAvailable(final ComputeService computeSer timeout = Duration.parse(WAIT_FOR_WINRM_AVAILABLE.getDefaultValue()); } - String user = expectedCredentials.getUser(); - String password = expectedCredentials.getOptionalPassword().orNull(); - int vmPort = hostAndPortOverride.isPresent() - ? hostAndPortOverride.get().getPortOrDefault(5985) - : 5985; // WinRM port - String vmIp = hostAndPortOverride.isPresent() - ? hostAndPortOverride.get().getHostText() - : getFirstReachableAddress(NodeMetadataBuilder.fromNodeMetadata(node).loginPort(vmPort).build(), setup); - - final Session session = WinRMFactory.INSTANCE.createSession(vmIp+":"+vmPort, user, password); - + Set<String> users = Sets.newLinkedHashSet(); + for (LoginCredentials creds : credentialsToTry) { + users.add(creds.getUser()); + } + String user = (users.size() == 1) ? Iterables.getOnlyElement(users) : "{" + Joiner.on(",").join(users) + "}"; + String vmIp = hostAndPortOverride.isPresent() ? hostAndPortOverride.get().getHostText() : getFirstReachableAddress(node, setup); if (vmIp==null) LOG.warn("Unable to extract IP for "+node+" ("+setup.getDescription()+"): subsequent connection attempt will likely fail"); + int vmPort = hostAndPortOverride.isPresent() ? hostAndPortOverride.get().getPortOrDefault(5985) : 5985; - Callable<Boolean> checker = new Callable<Boolean>() { - public Boolean call() { - return session.run_cmd("hostname").getStatusCode() == 0; - }}; String connectionDetails = user + "@" + vmIp + ":" + vmPort; + final HostAndPort hostAndPort = hostAndPortOverride.isPresent() ? hostAndPortOverride.get() : HostAndPort.fromParts(vmIp, vmPort); + final AtomicReference<LoginCredentials> credsSuccessful = new AtomicReference<LoginCredentials>(); - waitForReachable(checker, connectionDetails, ImmutableList.of(expectedCredentials), setup, timeout); - - return expectedCredentials; + // Don't use config that relates to the final user credentials (those have nothing to do + // with the initial credentials of the VM returned by the cloud provider). + // The createTemporaryWinRmMachineLocation deals with removing that. + ConfigBag winrmProps = ConfigBag.newInstanceCopying(setup); + + final Map<WinRmMachineLocation, LoginCredentials> machinesToTry = Maps.newLinkedHashMap(); + for (LoginCredentials creds : credentialsToTry) { + machinesToTry.put(createTemporaryWinRmMachineLocation(hostAndPort, creds, winrmProps), creds); + } + try { + Callable<Boolean> checker = new Callable<Boolean>() { + public Boolean call() { + for (Map.Entry<WinRmMachineLocation, LoginCredentials> entry : machinesToTry.entrySet()) { + WinRmMachineLocation machine = entry.getKey(); + WinRmToolResponse response = machine.executeScript( + ImmutableMap.of(WinRmTool.PROP_EXEC_TRIES.getName(), 1), + ImmutableList.of("echo testing")); + boolean success = (response.getStatusCode() == 0); + if (success) { + credsSuccessful.set(entry.getValue()); + return true; + } + } + return false; + }}; + + waitForReachable(checker, connectionDetails, credentialsToTry, setup, timeout); --- End diff -- I ment increase, sorry
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---