> + PublicIPAddress ip =
> staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> + logger.trace("<< static NATed IPAddress(%s) to
> virtualMachine(%s)", ip.getId(), vm.getId());
> + 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) {
I'm not disagreeing with you on that. The expected behaviour should be
transparent to the end user. If a call that creates a vm throws an exception
the vm shouldn't be created. That means implementing some form of rollback or
state keeping to ensure that when multiple tasks are needed to make it happen
those tasks are rollback when it fails. (Either that or give the api user fair
warning that an exception could indicate that the job is partially completed,
but i wouldn't be in favor of this).
There is probably a better way of doing this, but it would require a deeper
understanding of jclouds than what i currently have.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7004105