Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete network if network creation (subnet and router) fails #60

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,17 @@ private void attachToRouter(OSClient os, String subnetExtId, BaseVimInstance vim
.attachInterface(router.getId(), AttachInterfaceType.SUBNET, subnetExtId);
} else {
Router router = createRouter(os, vimInstance);
if (null == router) {
throw new VimDriverException("Unable to create router");
}
iface =
os.networking()
.router()
.attachInterface(router.getId(), AttachInterfaceType.SUBNET, subnetExtId);
if (null == iface) {
// failed to attach router, delete the router
os.networking().router().delete(router.getId());
}
}
if (iface == null) {
throw new VimDriverException("Not Able to attach to router the new subnet");
Expand Down Expand Up @@ -1648,6 +1655,14 @@ public Subnet createSubnet(BaseVimInstance vimInstance, BaseNetwork createdNetwo
attachToRouter(os, sn.getExtId(), vimInstance);
} catch (VimDriverException e) {
log.error(e.getMessage());

// if we could not attach the router to the delete the subnet
try {
deleteSubnet(vimInstance, sn.getExtId());
} catch (VimDriverException e2) {
log.error(e.getMessage());
}
throw new VimDriverException("Deleted subnet");
}
return sn;
}
Expand Down