> + vm =
> client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports =
> Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for
> IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules =
> setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on
> IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for
> IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules =
> setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on
> IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to
> destroy the created VM");
> + destroyVirtualMachine(vm.getId());
The trouble with destroyNode is that it will rollback all actions at the
moment, without checking if it is needed. Say the static nat configuration get
implemented and the firewallrules fail. Then destroyNode should return an error
because the removal of the firewall rules fails (they are not there).
CloudStack will (should) clean the static nat bound to a VM when a virtual
machine is destroyed. The firewall rules might remain, will check that.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6995427