jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trevor Flanagan <notificati...@github.com>
Subject Re: [jclouds/jclouds-labs] Implementing BaseImageToHardware and CleanupServer functions. (#422)
Date Sat, 02 Dec 2017 09:03:39 GMT
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());

Makes sense to cleanup as much as possible without failing the full operation, I will update
to have this, but I am not sure about the need for a try/catch.

-- 
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_r154491834
Mime
View raw message