I think I got AdvancedNetworkOptionsConverter figured out.

Also made sure not to try to remove FirewallRules unless there's a
public IP in the first place.
This commit is contained in:
Andrew Bayer 2012-05-23 10:15:34 -07:00 committed by Andrei Savu
parent e6eaa2e192
commit 1261a4c9b0
2 changed files with 12 additions and 9 deletions

View File

@ -52,7 +52,7 @@ public class AdvancedNetworkOptionsConverter implements OptionsConverter {
checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId); checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId);
Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null); Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), null);
if(defaultNetworkInZone == null) { if(defaultNetworkInZone == null) {
defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(isIsolatedNetwork(), not(supportsStaticNAT()))), null); defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), isIsolatedNetwork()), null);
} }
if (defaultNetworkInZone == null) { if (defaultNetworkInZone == null) {
throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks); throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks);

View File

@ -329,6 +329,8 @@ public class CloudStackComputeServiceAdapter implements
// immutable doesn't permit duplicates // immutable doesn't permit duplicates
Set<String> ipAddresses = Sets.newLinkedHashSet(); Set<String> ipAddresses = Sets.newLinkedHashSet();
String publicIpId = client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId();
if (publicIpId != null) {
Set<FirewallRule> firewallRules = client.getFirewallClient() Set<FirewallRule> firewallRules = client.getFirewallClient()
.listFirewallRules(ListFirewallRulesOptions.Builder.ipAddressId(client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId())); .listFirewallRules(ListFirewallRulesOptions.Builder.ipAddressId(client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId()));
@ -339,6 +341,7 @@ public class CloudStackComputeServiceAdapter implements
logger.debug(">> deleting FirewallRule(%s)", rule.getId()); logger.debug(">> deleting FirewallRule(%s)", rule.getId());
} }
} }
}
return ipAddresses; return ipAddresses;
} }