+ routes = _get_routes(iface)
+
if config["dpdk"]:
fs = os.path.realpath("/sys/class/net/" + iface).split("/")
# NOTE: why it's not an error?
@@ -154,6 +177,8 @@ render("agent_param", "/etc/contrail/agent_param", {"interface": iface})
+ _set_routes(routes)
+
def drop_caches():
"""Clears OS pagecache"""
@@ -184,8 +209,7 @@
ready = ( config.get("api_port")
and (config.get("api_ip") or config.get("api_vip"))
- and config.get("analytics_servers")
- and info.get("cloud_orchestrator"))
+ and config.get("analytics_servers"))
if config.get("vrouter-expected-provision-state"):
if ready and not config.get("vrouter-provisioned"):
try:
to solve vourter provisioning in a multi-interface setup with specific routes I did the following hacks which leads to a working vrouter:
--- ../contrail_ agent_utils. py.orig 2018-06-13 12:11:10.645817961 +0000 charms/ contrail- agent/hooks/ contrail_ agent_utils. py 2018-06-15 12:22:05.564341326 +0000
+++ contrail-
@@ -102,12 +102,33 @@
def _get_iface_ gateway_ ip(iface) : gateways( )["default" ][netifaces. AF_INET] ["route" , "-n"]). splitlines( )[2:]: ["route" , "-n"]). splitlines( )[2:]: append( route) routes) : route[0] , route[2], route[1], str(e)))
- if hasattr(netifaces, "gateways"):
- data = netifaces.
- return data[0] if data[1] == iface else None
-
- data = check_output("ip route | grep ^default", shell=True).split()
- return data[2] if data[4] == iface else None
+ for line in check_output(
+ l = line.split()
+ if "G" in l[3] and ( l[7] == VROUTER_INTERFACE or l[7] == iface ):
+ log("Found gateway {} for interface {}".format(l[1], l[7]))
+ return l[1]
+ log("No gateway could be determined from routing table")
+ return None
+
+
+def _get_routes(iface):
+ routes = []
+ for line in check_output(
+ route = []
+ l = line.split()
+ if "G" in l[3] and ( l[7] == VROUTER_INTERFACE or l[7] == iface ):
+ log("Found route {} {} via gw {} for interface {}".format(l[0], l[2], l[1], l[7]))
+ route = [ l[0], l[1], l[2] ]
+ routes.
+ return routes
+
+def _set_routes(
+ for route in routes:
+ args = [ "route", "add", "-net", route[0], "netmask", route[2], "gw", route[1] ]
+ try:
+ check_call(args)
+ except Exception as e:
+ log("Could not add route {} {} via {}, error: {}".format(
def _vhost_cidr(iface): gateway_ ip(iface) "vhost- gateway- ip"] = gateway_ip
@@ -139,6 +160,8 @@
gateway_ip = _get_iface_
config[
+ routes = _get_routes(iface) realpath( "/sys/class/ net/" + iface).split("/")
render( "agent_ param", "/etc/contrail/ agent_param" ,
{"interface" : iface})
+
if config["dpdk"]:
fs = os.path.
# NOTE: why it's not an error?
@@ -154,6 +177,8 @@
+ _set_routes(routes)
+
def drop_caches():
config. get("api_ port") get("api_ ip") or config. get("api_ vip")) get("analytics_ servers" ) "cloud_ orchestrator" )) get("analytics_ servers" )) get("vrouter- expected- provision- state") : get("vrouter- provisioned" ):
"""Clears OS pagecache"""
@@ -184,8 +209,7 @@
ready = (
and (config.
- and config.
- and info.get(
+ and config.
if config.
if ready and not config.
try: