You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2016/04/20 02:17:06 UTC

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/116

    Fix JcloudsLocation.resumeMachine when password supplied

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server fix/jcloudsLocation-resumeMachine

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/116.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #116
    
----
commit bee832d139bdaffffb859278ef6eeddd93085838
Author: Aled Sage <al...@gmail.com>
Date:   2016-04-20T00:16:10Z

    Fix JcloudsLocation.resumeMachine when password supplied

----


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:

    https://github.com/apache/brooklyn-server/pull/116#issuecomment-217226272
  
    Thanks @andreaturli - merging 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on the pull request:

    https://github.com/apache/brooklyn-server/pull/116#issuecomment-212297931
  
    jenkins failure doesn't seem related to this PR
    `Build timed out (after 40 minutes). Marking the build as aborted.`


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/116#discussion_r62226135
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2133,11 +2133,17 @@ protected NodeMetadata findNodeOrThrow(ConfigBag config) {
             }
             NodeMetadata node = Iterables.getOnlyElement(candidateNodes);
     
    -        String pkd = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings().getPrivateKeyData();
    +        OsCredential osCredentials = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings();
    +        String pkd = osCredentials.getPrivateKeyData();
    +        String password = osCredentials.getPassword();
             if (Strings.isNonBlank(pkd)) {
                 LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, pkd));
                 //override credentials
                 node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    +        } else if (Strings.isNonBlank(password)) {
    +            LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, password));
    +            //override credentials
    +            node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
             }
     
             return node;
    --- End diff --
    
    I'm going to leave as-is because there is an implicit third case (where neither if block matches). In that case, we don't override the node's credentials (so use whatever the compute-service gave us). I suspect that will not have credentials at all.


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/116#discussion_r61380655
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2133,11 +2133,17 @@ protected NodeMetadata findNodeOrThrow(ConfigBag config) {
             }
             NodeMetadata node = Iterables.getOnlyElement(candidateNodes);
     
    -        String pkd = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings().getPrivateKeyData();
    +        OsCredential osCredentials = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings();
    +        String pkd = osCredentials.getPrivateKeyData();
    +        String password = osCredentials.getPassword();
             if (Strings.isNonBlank(pkd)) {
                 LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, pkd));
                 //override credentials
                 node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    +        } else if (Strings.isNonBlank(password)) {
    +            LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, password));
    +            //override credentials
    +            node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
             }
     
             return node;
    --- End diff --
    
    @aledsage it was a minor suggestion. I guess, we can just return the node:
    ```
    return NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    ```
    and remove lines 2145-2146 and 2141-2142, maybe.
    if we pulled it out from the if-else and you can 


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/116


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/116#discussion_r60356719
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2133,11 +2133,17 @@ protected NodeMetadata findNodeOrThrow(ConfigBag config) {
             }
             NodeMetadata node = Iterables.getOnlyElement(candidateNodes);
     
    -        String pkd = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings().getPrivateKeyData();
    +        OsCredential osCredentials = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings();
    +        String pkd = osCredentials.getPrivateKeyData();
    +        String password = osCredentials.getPassword();
             if (Strings.isNonBlank(pkd)) {
                 LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, pkd));
                 //override credentials
                 node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    +        } else if (Strings.isNonBlank(password)) {
    +            LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, password));
    +            //override credentials
    +            node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    --- End diff --
    
    maybe you could move this out of the 'else' (and of the 'if' as well) 


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by andreaturli <gi...@git.apache.org>.
Github user andreaturli commented on the pull request:

    https://github.com/apache/brooklyn-server/pull/116#issuecomment-212283708
  
    @aledsage, code looks sensible just a minor comment. do we have a test that capture this behavior?


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

[GitHub] brooklyn-server pull request: Fix JcloudsLocation.resumeMachine wh...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/116#discussion_r61377260
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsLocation.java ---
    @@ -2133,11 +2133,17 @@ protected NodeMetadata findNodeOrThrow(ConfigBag config) {
             }
             NodeMetadata node = Iterables.getOnlyElement(candidateNodes);
     
    -        String pkd = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings().getPrivateKeyData();
    +        OsCredential osCredentials = LocationConfigUtils.getOsCredential(config).checkNoErrors().logAnyWarnings();
    +        String pkd = osCredentials.getPrivateKeyData();
    +        String password = osCredentials.getPassword();
             if (Strings.isNonBlank(pkd)) {
                 LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, pkd));
                 //override credentials
                 node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    +        } else if (Strings.isNonBlank(password)) {
    +            LoginCredentials expectedCredentials = LoginCredentials.fromCredentials(new Credentials(user, password));
    +            //override credentials
    +            node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(expectedCredentials).build();
    --- End diff --
    
    @andreaturli not sure I follow. The if-else means that it preserves previous behaviour when there is privateKeyData. If someone supplies both privateKeyData and a password, then the privateKeyData takes precedence. If I moved this out of the else/if, then it would overwrite the credentials set at lines 2138-2140.


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