Repository: jclouds-labs Updated Branches: refs/heads/master 84ebe3d33 -> 35c968e94
JCLOUDS-1254 Filters storage account by current available locations Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/76353e75 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/76353e75 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/76353e75 Branch: refs/heads/master Commit: 76353e75a548269654633825761972e612feee8f Parents: 84ebe3d Author: Dani Estevez <[email protected]> Authored: Tue Mar 14 10:59:57 2017 -0400 Committer: Ignasi Barrera <[email protected]> Committed: Tue Mar 28 08:23:46 2017 +0200 ---------------------------------------------------------------------- .../arm/compute/AzureComputeServiceAdapter.java | 42 +++++++++++--------- 1 file changed, 24 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/76353e75/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java index f510109..572e2be 100644 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java +++ b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java @@ -16,10 +16,23 @@ */ package org.jclouds.azurecompute.arm.compute; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.collect.Iterables.contains; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.find; +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension.CONTAINER_NAME; +import static org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension.CUSTOM_IMAGE_OFFER; +import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.decodeFieldsFromUniqueId; +import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.encodeFieldsToUniqueIdCustom; +import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.getMarketplacePlanFromImageMetadata; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; +import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue; +import static org.jclouds.util.Closeables2.closeQuietly; + import java.util.List; import java.util.Map; import java.util.Set; - import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; @@ -84,20 +97,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.contains; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension.CONTAINER_NAME; -import static org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension.CUSTOM_IMAGE_OFFER; -import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.decodeFieldsFromUniqueId; -import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.encodeFieldsToUniqueIdCustom; -import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.getMarketplacePlanFromImageMetadata; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS; -import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue; -import static org.jclouds.util.Closeables2.closeQuietly; - /** * Defines the connection between the {@link AzureComputeApi} implementation and * the jclouds {@link org.jclouds.compute.ComputeService}. @@ -226,8 +225,15 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual public Iterable<VMImage> listImages() { final List<VMImage> osImages = Lists.newArrayList(); - for (Location location : listLocations()) { - osImages.addAll(listImagesByLocation(location.name())); + final List<String> availableLocationNames = FluentIterable.from(listLocations()) + .transform(new Function<Location, String>() { + @Override public String apply(Location location) { + return location.name(); + } + }).toList(); + + for (String locationName : availableLocationNames) { + osImages.addAll(listImagesByLocation(locationName)); } // list custom images @@ -239,7 +245,7 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual try { String name = storage.name(); StorageService storageService = api.getStorageAccountApi(azureGroup).get(name); - if (storageService != null + if (storageService != null && availableLocationNames.contains(storageService.location()) && Status.Succeeded == storageService.storageServiceProperties().provisioningState()) { String key = api.getStorageAccountApi(azureGroup).getKeys(name).key1(); BlobHelper blobHelper = new BlobHelper(storage.name(), key);
