demobox commented on this pull request.
> }
}
return deleted;
}
+ private void cleanupVirtualNetworks(String resourceGroupName) {
+ for (VirtualNetwork virtualNetwork :
api.getVirtualNetworkApi(resourceGroupName).list()) {
+ if (virtualNetwork.tags() != null &&
virtualNetwork.tags().containsKey("jclouds")) {
+ try {
+ // Virtual networks cannot be deleted if there are any
resources attached. It does not seem to be possible
+ // to list devices connected to a virtual network
+ //
https://docs.microsoft.com/en-us/azure/virtual-network/manage-virtual-network#delete-a-virtual-network
+ // We also check the tags to ensure that it's jclouds-created
+
api.getVirtualNetworkApi(resourceGroupName).delete(virtualNetwork.name());
+ resourceRemoved.apply(IdReference.create(virtualNetwork.id()));
+ } catch (IllegalArgumentException e) {
+ if (e.getMessage().contains("InUseSubnetCannotBeDeleted")) {
+ // Can be ignored as virtualNetwork is in use
Curious about this comment - does it mean we _can_ or we _have to_ try not to
delete it? Given that the intent here is to delete, as Ignasi points out,
should the log message be a `warn` instead?
If so, we can probably remove the comment, as the log message says pretty much
the same thing
--
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/pull/1240#pullrequestreview-156628711