Skip to content
Permalink
Browse files
JCLOUDS-1254 Filters storage account by current available locations
  • Loading branch information
danielestevez authored and nacx committed Mar 28, 2017
1 parent 84ebe3d commit 76353e75a548269654633825761972e612feee8f
Showing 1 changed file with 24 additions and 18 deletions.
@@ -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.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 @@ private List<VMImage> listImagesByLocation(String location) {
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 Iterable<VMImage> listImages() {
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);

0 comments on commit 76353e7

Please sign in to comment.