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

Implements: #1579 #1580

Merged
merged 2 commits into from
Jun 26, 2024
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
11 changes: 9 additions & 2 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ def get_router_public(self, driver, radl, inf_id, create=False):
# try to create a router
if create and pub_nets:
try:
self.log_debug("Creating public router.")
gateway_info = {'network_id': list(pub_nets.keys())[0]}
name = "im-%s" % (inf_id)
return driver.ex_create_router(name, description="IM created router",
Expand Down Expand Up @@ -1033,7 +1034,7 @@ def create_networks(self, driver, radl, inf):
"""
try:
i = 0
router = self.get_router_public(driver, radl, inf.id, create=True)
router = self.get_router_public(driver, radl, inf.id, create=False)

while radl.systems[0].getValue("net_interface." + str(i) + ".connection"):
net_name = radl.systems[0].getValue("net_interface." + str(i) + ".connection")
Expand Down Expand Up @@ -1090,8 +1091,14 @@ def create_networks(self, driver, radl, inf):
raise Exception("Error creating ost subnet for net %s: %s" % (net_name,
get_ex_error(ex)))

# There are no routers in the site
if router is None:
self.log_warn("No public router found.")
self.log_debug("No public router found.")
# Try to create one
router = self.get_router_public(driver, radl, inf.id, create=True)

if router is None:
self.log_warn("No public router found and cannot be created.")
else:
self.log_info("Adding subnet %s to the router %s" % (ost_subnet.name, router.name))
try:
Expand Down