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

    https://github.com/apache/incubator-brooklyn/pull/685#discussion_r32292331
  
    --- Diff: 
locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java 
---
    @@ -1026,7 +1057,33 @@ public void apply(TemplateOptions t, ConfigBag 
props, Object v) {
                             } else if (t instanceof SoftLayerTemplateOptions) {
                                 
((SoftLayerTemplateOptions)t).userData(Strings.toString(v));
                             } else {
    -                            LOG.info("ignoring userDataString({}) in VM 
creation because not supported for cloud/type ({})", v, t.getClass());
    +                            // Try reflection: userData(String), or 
guestCustomizationScript(String);
    +                            // the latter is used by vCloud Director.
    +                            Class<? extends TemplateOptions> clazz = 
t.getClass();
    +                            Method userDataMethod = null;
    +                            try {
    +                                userDataMethod = 
clazz.getMethod("userData", String.class);
    +                            } catch (SecurityException e) {
    +                                LOG.info("Problem reflectively inspecting 
methods of "+t.getClass()+" for setting userData", e);
    +                            } catch (NoSuchMethodException e) {
    +                                try {
    +                                    // For vCloud Director
    +                                    userDataMethod = 
clazz.getMethod("guestCustomizationScript", String.class);
    +                                } catch (NoSuchMethodException e2) {
    +                                    // expected on various other clouds
    +                                }
    +                            }
    +                            if (userDataMethod != null) {
    +                                try {
    +                                    
userDataMethod.invoke(Strings.toString(v));
    --- End diff --
    
    `userDataMethod.invoke(t, Strings.toString(v));`


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