added message to NPE when vdc isn't found

This commit is contained in:
Adrian Cole 2011-06-01 12:07:27 -07:00
parent 69a1b7a6aa
commit 281109dfc4
1 changed files with 32 additions and 34 deletions

View File

@ -18,15 +18,16 @@
*/ */
package org.jclouds.vcloud.terremark.compute; package org.jclouds.vcloud.terremark.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.getLast;
import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.withDescription; import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.withDescription;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
@ -142,16 +143,12 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
} else { } else {
logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port); logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
is = client.addInternetServiceToExistingIp( is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port,
ip.getId(),
vApp.getName() + "-" + port,
protocol,
port,
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
vApp.getName()))); vApp.getName())));
} }
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(), logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(), is
is.getProtocol(), is.getPort()); .getProtocol(), is.getPort());
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(), logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
privateAddress, port); privateAddress, port);
Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port); Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
@ -161,6 +158,7 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
} }
private Set<PublicIpAddress> deleteInternetServicesAndNodesAssociatedWithVApp(VCloudExpressVApp vApp) { private Set<PublicIpAddress> deleteInternetServicesAndNodesAssociatedWithVApp(VCloudExpressVApp vApp) {
checkNotNull(vApp.getVDC(), "VDC reference missing for vApp(%s)", vApp.getName());
Set<PublicIpAddress> ipAddresses = Sets.newHashSet(); Set<PublicIpAddress> ipAddresses = Sets.newHashSet();
SERVICE: for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getHref())) { SERVICE: for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getHref())) {
for (Node node : client.getNodes(service.getId())) { for (Node node : client.getNodes(service.getId())) {