From 7cc010e449836de67ba303b159c07951fab83b80 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 16 Oct 2011 03:06:13 -0700 Subject: [PATCH] better error message when out of IPs --- ...udInternetServiceAndPublicIpAddressSupplier.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java index c52e189368..c7472ccc7c 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java @@ -21,8 +21,8 @@ package org.jclouds.trmk.ecloud.suppliers; import static org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.Builder.withDescription; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.annotation.Resource; import javax.inject.Inject; @@ -60,8 +60,7 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements } @Override - public Entry getNewInternetServiceAndIp(VApp vApp, int port, - Protocol protocol) { + public Entry getNewInternetServiceAndIp(VApp vApp, int port, Protocol protocol) { logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port); InternetService is = null; PublicIpAddress ip = null; @@ -69,7 +68,8 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements ip = client.activatePublicIpInVDC(vApp.getVDC().getHref()); } catch (InsufficientResourcesException e) { logger.warn(">> no more ip addresses available, looking for one to re-use"); - for (PublicIpAddress existingIp : client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref())) { + Set publicIps = client.getPublicIpsAssociatedWithVDC(vApp.getVDC().getHref()); + for (PublicIpAddress existingIp : publicIps) { Set services = client.getInternetServicesOnPublicIp(existingIp.getId()); if (services.size() == 0) { ip = existingIp; @@ -77,8 +77,9 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements } } if (ip == null) - throw e; - + throw new InsufficientResourcesException( + "no more ip addresses available and existing ips all have services attached: " + publicIps, e + .getCause()); } is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port, withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), vApp