brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [16/50] brooklyn-server git commit: if listing images fails, still throw original error
Date Mon, 01 Feb 2016 17:48:46 GMT
if listing images fails, still throw original error


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/d7afcded
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/d7afcded
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/d7afcded

Branch: refs/heads/0.4.0
Commit: d7afcded9fd85d3d5fcb41d5ce6bbd8d8e75814b
Parents: 2cfa451
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Sep 28 13:42:46 2012 -0400
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Sep 28 13:42:46 2012 -0400

----------------------------------------------------------------------
 .../location/basic/jclouds/JcloudsLocation.java | 36 +++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d7afcded/core/src/main/java/brooklyn/location/basic/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/jclouds/JcloudsLocation.java b/core/src/main/java/brooklyn/location/basic/jclouds/JcloudsLocation.java
index 7c97a9e..c17c8e0 100644
--- a/core/src/main/java/brooklyn/location/basic/jclouds/JcloudsLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/jclouds/JcloudsLocation.java
@@ -801,25 +801,29 @@ public class JcloudsLocation extends AbstractLocation implements MachineProvisio
                 }
             }
         } catch (Exception e) {
-            synchronized (this) {
-                // delay subsequent log.warns (put in synch block) so the "Loading..." message
is obvious
-                LOG.warn("Unable to match required VM template constraints "+templateBuilder+"
when trying to provision VM in "+this+" (rethrowing): "+e);
-                if (!listedAvailableTemplatesOnNoSuchTemplate) {
-                    listedAvailableTemplatesOnNoSuchTemplate = true;
-                    LOG.info("Loading available images at "+this+" for reference...");
-                    Map m1 = new LinkedHashMap(setup.allconf);
-                    if (m1.remove("imageId")!=null)
-                        // don't apply default filters if user has tried to specify an image
ID
-                        m1.put("anyOwner", true);
-                    ComputeService computeServiceLessRestrictive = JcloudsUtil.buildOrFindComputeService(m1,
new MutableMap());
-                    Set<? extends Image> imgs = computeServiceLessRestrictive.listImages();
-                    LOG.info(""+imgs.size()+" available images at "+this);
-                    for (Image img: imgs) {
-                        LOG.info(" Image: "+img);
+            try {
+                synchronized (this) {
+                    // delay subsequent log.warns (put in synch block) so the "Loading..."
message is obvious
+                    LOG.warn("Unable to match required VM template constraints "+templateBuilder+"
when trying to provision VM in "+this+" (rethrowing): "+e);
+                    if (!listedAvailableTemplatesOnNoSuchTemplate) {
+                        listedAvailableTemplatesOnNoSuchTemplate = true;
+                        LOG.info("Loading available images at "+this+" for reference...");
+                        Map m1 = new LinkedHashMap(setup.allconf);
+                        if (m1.remove("imageId")!=null)
+                            // don't apply default filters if user has tried to specify an
image ID
+                            m1.put("anyOwner", true);
+                        ComputeService computeServiceLessRestrictive = JcloudsUtil.buildOrFindComputeService(m1,
new MutableMap());
+                        Set<? extends Image> imgs = computeServiceLessRestrictive.listImages();
+                        LOG.info(""+imgs.size()+" available images at "+this);
+                        for (Image img: imgs) {
+                            LOG.info(" Image: "+img);
+                        }
                     }
                 }
+            } catch (Exception e2) {
+                LOG.warn("Error loading available images to report (following original error
matching template which will be rethrown): "+e2, e2);
             }
-            throw new IllegalStateException("Unable to match required VM template constraints
"+templateBuilder+" when trying to provision VM in "+this+". See list of images in log.");
+            throw new IllegalStateException("Unable to match required VM template constraints
"+templateBuilder+" when trying to provision VM in "+this+". See list of images in log.",
e);
         }
         TemplateOptions options = template.getOptions();
         


Mime
View raw message