From c377c6da015224ffb03af3a5244b61f7c02a34eb Mon Sep 17 00:00:00 2001 From: Andrei Savu Date: Tue, 20 Mar 2012 11:53:53 +0200 Subject: [PATCH] CloudStack image location is Zone, and the part of the zone is the provider location --- .../compute/domain/internal/LocationPredicate.java | 10 ++++++---- .../compute/domain/internal/TemplateBuilderImpl.java | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java b/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java index afb13aff78..206f1325aa 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/LocationPredicate.java @@ -61,10 +61,12 @@ public class LocationPredicate implements Predicate { input.getLocation().getParent() != null || input.getLocation().getScope() == LocationScope.PROVIDER, "only locations of scope PROVIDER can have a null parent; input: %s", input.getLocation()); - - return location.equals(input.getLocation()) || location.getParent() != null - && location.getParent().equals(input.getLocation()) || location.getParent().getParent() != null - && location.getParent().getParent().equals(input.getLocation()); + + return location.equals(input.getLocation()) || + (input.getLocation().getParent() != null && location.equals(input.getLocation().getParent())) || + (location.getParent() != null && location.getParent().equals(input.getLocation())) || + (location.getParent() != null && location.getParent().getParent() != null && + location.getParent().getParent().equals(input.getLocation())); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index c451825e5d..88cb13c99a 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -614,7 +614,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { location = defaultLocation.get(); Predicate imagePredicate = buildImagePredicate(); - Iterable supportedImages = filter(images, buildImagePredicate()); + Iterable supportedImages = filter(images, imagePredicate); if (size(supportedImages) == 0) { if (imagePredicate == idPredicate) { throw new NoSuchElementException(format("%s not found", idPredicate));