MCPcopy Create free account
hub / github.com/apache/cloudstack / set_route

Method set_route

systemvm/debian/opt/cloud/bin/cs/CsRoute.py:77–96  ·  view source on GitHub ↗

Add a route if it is not already defined

(self, cmd, method="add")

Source from the content-addressed store, hash-verified

75 self.set_route(cmd)
76
77 def set_route(self, cmd, method="add"):
78 """ Add a route if it is not already defined """
79 found = False
80 search = cmd
81 if "throw" in search:
82 search = search.replace("throw", "")
83 for i in CsHelper.execute("ip route show " + search):
84 found = True
85 if not found and method == "add":
86 logging.info("Add " + cmd)
87 cmd = "ip route add " + cmd
88 elif not found and method == "change":
89 logging.info("Change " + cmd)
90 cmd = "ip route change " + cmd
91 elif found and method == "delete":
92 logging.info("Delete " + cmd)
93 cmd = "ip route delete " + cmd
94 else:
95 return
96 CsHelper.execute(cmd)
97
98 def add_defaultroute(self, gateway):
99 """ Add a default route

Callers 6

mainFunction · 0.95
post_config_changeMethod · 0.95
add_routeMethod · 0.95
add_network_routeMethod · 0.95
add_defaultrouteMethod · 0.95

Calls 3

replaceMethod · 0.80
executeMethod · 0.65
infoMethod · 0.45

Tested by

no test coverage detected