Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions systemvm/debian/opt/cloud/bin/cs/CsAddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,16 @@ def post_config_change(self, method):
CsHelper.execute("sudo ip route add throw " + self.config.address().dbag['eth1'][0]['network'] + " table " + tableName + " proto static")

# add 'defaul via gateway' rule in the device specific routing table
if "gateway" in self.address and self.address["gateway"] != "None":
if "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there a '!= None` missing in this expression? (x != None and x != "None") just paranoia, i guess

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we check here on "None" as a String? And not None as you should in Python?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because somewhere the python None is stringyfied and gets in the way, @wido

route.add_route(self.dev, self.address["gateway"])
route.add_network_route(self.dev, str(self.address["network"]))
if "network" in self.address and self.address["network"]:
route.add_network_route(self.dev, str(self.address["network"]))

if self.get_type() in ["public"]:
CsRule(self.dev).addRule("from " + str(self.address["network"]))

if self.config.is_vpc():
if self.get_type() in ["public"] and "gateway" in self.address and self.address["gateway"] != "None":
if self.get_type() in ["public"] and "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
route.add_route(self.dev, self.address["gateway"])
for inf, addresses in self.config.address().dbag.iteritems():
if not inf.startswith("eth"):
Expand Down
27 changes: 18 additions & 9 deletions systemvm/debian/opt/cloud/bin/cs/CsRoute.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,29 @@ def add_route(self, dev, address):
""" Wrapper method that adds table name and device to route statement """
# ip route add dev eth1 table Table_eth1 10.0.2.0/24
table = self.get_tablename(dev)
logging.info("Adding route: dev " + dev + " table: " +
table + " network: " + address + " if not present")
cmd = "dev %s table %s %s" % (dev, table, address)
cmd = "default via %s table %s proto static" % (address, table)
self.set_route(cmd)

if not table or not address:
empty_param = "table" if not table else "address"
logging.info("Empty parameter received %s while trying to add route, skipping" % empty_param)
else:
logging.info("Adding route: dev " + dev + " table: " +
table + " network: " + address + " if not present")
cmd = "default via %s table %s proto static" % (address, table)
self.set_route(cmd)

def add_network_route(self, dev, address):
""" Wrapper method that adds table name and device to route statement """
# ip route add dev eth1 table Table_eth1 10.0.2.0/24
table = self.get_tablename(dev)
logging.info("Adding route: dev " + dev + " table: " +
table + " network: " + address + " if not present")
cmd = "throw %s table %s proto static" % (address, table)
self.set_route(cmd)

if not table or not address:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By your changes, I am assuming that it is ok if we do not receive a routing table to be configured.
Do you know in which cases this situation might happen?

Copy link
Copy Markdown
Contributor Author

@nvazquez nvazquez Nov 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could detect it each time we deploy a VR on 4.11.2 RC4

empty_param = "table" if not table else "address"
logging.info("Empty parameter received %s while trying to add network route, skipping" % empty_param)
else:
logging.info("Adding route: dev " + dev + " table: " +
table + " network: " + address + " if not present")
cmd = "throw %s table %s proto static" % (address, table)
self.set_route(cmd)

def set_route(self, cmd, method="add"):
""" Add a route if it is not already defined """
Expand Down