You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2018/01/08 14:52:23 UTC
[02/50] [abbrv] jclouds git commit: JCLOUDS-1254 Filters storage
account by current available locations
JCLOUDS-1254 Filters storage account by current available locations
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/c45728e0
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/c45728e0
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/c45728e0
Branch: refs/heads/master
Commit: c45728e085797fe3fca8e4a7bc53f7143fef5133
Parents: 894be79
Author: Dani Estevez <co...@danielestevez.com>
Authored: Tue Mar 14 10:59:57 2017 -0400
Committer: Ignasi Barrera <na...@apache.org>
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/blob/c45728e0/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java
index f510109..572e2be 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceAdapter.java
+++ b/providers/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);