brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (BROOKLYN-257) Can't replace imageId with imageNameRegex in jcloudsLocation.obtain(Map)
Date Sat, 16 Apr 2016 20:27:25 GMT

    [ https://issues.apache.org/jira/browse/BROOKLYN-257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15244375#comment-15244375
] 

ASF GitHub Bot commented on BROOKLYN-257:
-----------------------------------------

GitHub user aledsage opened a pull request:

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

    BROOKLYN-257: allow nulling imageId in jcloudsLocation.obtain()

    Fixes https://issues.apache.org/jira/browse/BROOKLYN-257.
    
    To fix this, I was tempted to instead change `JcloudsLocation.buildTemplate` so that it
ignored all null values, changing the code below:
    
    ```
            for (Map.Entry<ConfigKey<?>, CustomizeTemplateBuilder> entry : SUPPORTED_TEMPLATE_BUILDER_PROPERTIES.entrySet())
{
                ConfigKey<?> name = entry.getKey();
                CustomizeTemplateBuilder code = entry.getValue();
                if (config.containsKey(name))
                    code.apply(templateBuilder, config, config.get(name));
            }
    ```
    
    to:
    
    ```
            for (Map.Entry<ConfigKey<?>, CustomizeTemplateBuilder> entry : SUPPORTED_TEMPLATE_BUILDER_PROPERTIES.entrySet())
{
                ConfigKey<?> name = entry.getKey();
                CustomizeTemplateBuilder code = entry.getValue();
                if (config.containsKey(name) && config.get(name) != null)
                    code.apply(templateBuilder, config, config.get(name));
            }
    ```
    
    But is that risky? Do we rely for any config keys on `null` meaning something other than
"use the jclouds default"?

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

    $ git pull https://github.com/aledsage/brooklyn-server fix/imageId-overriding

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

    https://github.com/apache/brooklyn-server/pull/115.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 #115
    
----
commit d5a01b23ec38b7f6e3faba9b7b6ef45257113d55
Author: Aled Sage <aled.sage@gmail.com>
Date:   2016-04-16T20:19:12Z

    BROOKLYN-257: allow nulling imageId in jcloudsLocation.obtain()

----


> Can't replace imageId with imageNameRegex in jcloudsLocation.obtain(Map)
> ------------------------------------------------------------------------
>
>                 Key: BROOKLYN-257
>                 URL: https://issues.apache.org/jira/browse/BROOKLYN-257
>             Project: Brooklyn
>          Issue Type: Bug
>            Reporter: Aled Sage
>             Fix For: 0.9.0
>
>
> A customer has a pre-defined AWS location (which could be a named location in brooklyn.properties,
or a location added to the catalog) that defines a imageId. When calling {{location.obtain(Map)}},
they want to override the image choice by passing in an imageNameRegex instead. However, the
imageId always takes precedence.
> If they try to pass in a map of {{ {imageId: null, imageNameRegex: myval} }}, then it
gives an error like:
> {noformat}
> java.lang.NullPointerException
> 	at org.apache.brooklyn.location.jclouds.JcloudsLocation$6.apply(JcloudsLocation.java:1153)
> 	at org.apache.brooklyn.location.jclouds.JcloudsLocation.buildTemplate(JcloudsLocation.java:1493)
> 	at org.apache.brooklyn.location.jclouds.JcloudsLocation.obtainOnce(JcloudsLocation.java:682)
> 	at org.apache.brooklyn.location.jclouds.JcloudsLocation.obtain(JcloudsLocation.java:614)
> 	at org.apache.brooklyn.location.jclouds.AbstractJcloudsLiveTest.obtainMachine(AbstractJcloudsLiveTest.java:141)
> 	at org.apache.brooklyn.location.jclouds.JcloudsImageChoiceStubbedLiveTest.testJcloudsCreateWithImageDescriptionRegex(JcloudsImageChoiceStubbedLiveTest.java:80)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message