Skip to content

Commit

Permalink
Merge pull request #1580 from grycap/devel
Browse files Browse the repository at this point in the history
Implements: #1579
  • Loading branch information
micafer authored Jun 26, 2024
2 parents f745a0c + c2ad29e commit 794bc3e
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 794bc3e

Please sign in to comment.