brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #690: External ip config for winrm byon locatio...
Date Thu, 25 May 2017 09:31:30 GMT
Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/690#discussion_r118444720
  
    --- Diff: core/src/main/java/org/apache/brooklyn/location/byon/ByonLocationResolver.java
---
    @@ -152,49 +153,55 @@ protected ConfigBag extractConfig(Map<?,?> locationFlags,
String spec, LocationR
             
             String osFamily = (String) machineConfig.remove(OS_FAMILY.getName());
             String ssh = (String) machineConfig.remove("ssh");
    -        String winrm = (String) machineConfig.remove("winrm");
    -        Map<Integer, String> tcpPortMappings = (Map<Integer, String>) machineConfig.get("tcpPortMappings");
    -        
    -        checkArgument(ssh != null ^ winrm != null, "Must specify exactly one of 'ssh'
or 'winrm' for machine: %s", valSanitized);
    -        
    -        UserAndHostAndPort userAndHostAndPort;
    -        String host;
    -        int port;
    -        if (ssh != null) {
    -            userAndHostAndPort = parseUserAndHostAndPort(ssh, 22);
    +        if (machineConfig.containsKey("winrm") && !(machineConfig.get("winrm")
instanceof String)) {
    +            machineConfig.put("address", machineConfig.get("winrm"));
    +            machineConfig.remove("winrm");
             } else {
    -            // TODO set to null and rely on the MachineLocation. If not then make a dependency
to WinRmMachineLocation and use its config key name.
    -            userAndHostAndPort = parseUserAndHostAndPort(winrm, vals.get("winrm.useHttps")
!= null && (Boolean)vals.get("winrm.useHttps") ? 5986 : 5985);
    -        }
    -        
    -        // If there is a tcpPortMapping defined for the connection-port, then use that
for ssh/winrm machine
    -        port = userAndHostAndPort.getHostAndPort().getPort();
    -        if (tcpPortMappings != null && tcpPortMappings.containsKey(port)) {
    -            String override = tcpPortMappings.get(port);
    -            HostAndPort hostAndPortOverride = HostAndPort.fromString(override);
    -            if (!hostAndPortOverride.hasPort()) {
    -                throw new IllegalArgumentException("Invalid portMapping ('"+override+"')
for port "+port+" in "+specForErrMsg);
    +            String winrm = (String) machineConfig.remove("winrm");
    +
    +            Map<Integer, String> tcpPortMappings = (Map<Integer, String>)
machineConfig.get("tcpPortMappings");
    +
    +            checkArgument(ssh != null ^ winrm != null, "Must specify exactly one of 'ssh'
or 'winrm' for machine: %s", valSanitized);
    +
    +            UserAndHostAndPort userAndHostAndPort;
    +            String host;
    +            int port;
    +            if (ssh != null) {
    +                userAndHostAndPort = parseUserAndHostAndPort(ssh, 22);
    +            } else {
    +                // TODO set to null and rely on the MachineLocation. If not then make
a dependency to WinRmMachineLocation and use its config key name.
    +                userAndHostAndPort = parseUserAndHostAndPort(winrm, vals.get("winrm.useHttps")
!= null && (Boolean)vals.get("winrm.useHttps") ? 5986 : 5985);
    --- End diff --
    
    Use a variable here to store the result of the logical expression, it will make it a lot
easier to  read.
    
    The second clause should be `Boolean.parseBoolean(vals.get("winrm.useHttps").toString())`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message