mirror of https://github.com/apache/jclouds.git
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:
parent
e6eaa2e192
commit
1261a4c9b0
|
@ -52,7 +52,7 @@ public class AdvancedNetworkOptionsConverter implements OptionsConverter {
|
|||
checkArgument(!networks.isEmpty(), "please setup a network for zone: " + zoneId);
|
||||
Network defaultNetworkInZone = Iterables.getFirst(filter(networks.values(), and(defaultNetworkInZone(zoneId), supportsStaticNAT())), 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) {
|
||||
throw new IllegalArgumentException("please choose a specific network in zone " + zoneId + ": " + networks);
|
||||
|
|
|
@ -329,14 +329,17 @@ public class CloudStackComputeServiceAdapter implements
|
|||
// immutable doesn't permit duplicates
|
||||
Set<String> ipAddresses = Sets.newLinkedHashSet();
|
||||
|
||||
Set<FirewallRule> firewallRules = client.getFirewallClient()
|
||||
.listFirewallRules(ListFirewallRulesOptions.Builder.ipAddressId(client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId()));
|
||||
|
||||
for (FirewallRule rule : firewallRules) {
|
||||
if (!FirewallRule.State.fromValue("DELETEING").equals(rule.getState())) {
|
||||
ipAddresses.add(rule.getIpAddressId());
|
||||
client.getFirewallClient().deleteFirewallRule(rule.getId());
|
||||
logger.debug(">> deleting FirewallRule(%s)", rule.getId());
|
||||
String publicIpId = client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId();
|
||||
if (publicIpId != null) {
|
||||
Set<FirewallRule> firewallRules = client.getFirewallClient()
|
||||
.listFirewallRules(ListFirewallRulesOptions.Builder.ipAddressId(client.getVirtualMachineClient().getVirtualMachine(virtualMachineId).getPublicIPId()));
|
||||
|
||||
for (FirewallRule rule : firewallRules) {
|
||||
if (!FirewallRule.State.fromValue("DELETEING").equals(rule.getState())) {
|
||||
ipAddresses.add(rule.getIpAddressId());
|
||||
client.getFirewallClient().deleteFirewallRule(rule.getId());
|
||||
logger.debug(">> deleting FirewallRule(%s)", rule.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return ipAddresses;
|
||||
|
|
Loading…
Reference in New Issue