trevorflanagan commented on this pull request.


> +         String networkDomainId = server.networkInfo().networkDomainId();
+         final String internalIp = 
server.networkInfo().primaryNic().privateIpv4();
+
+         // delete nat rules associated to the server, if any
+         final NetworkApi networkApi = api.getNetworkApi();
+         List<NatRule> natRulesToBeDeleted = 
networkApi.listNatRules(networkDomainId).concat()
+               .filter(new Predicate<NatRule>() {
+                  @Override
+                  public boolean apply(NatRule natRule) {
+                     return natRule.internalIp().equals(internalIp);
+                  }
+               }).toList();
+
+         for (final NatRule natRule : natRulesToBeDeleted) {
+            if (natRule.state().isNormal()) {
+               networkApi.deleteNatRule(natRule.id());

Understood, thanks for clarifying. I will make that change.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/422#discussion_r154627697

Reply via email to