本文整理汇总了Python中CsRoute.CsRoute.add_table方法的典型用法代码示例。如果您正苦于以下问题:Python CsRoute.add_table方法的具体用法?Python CsRoute.add_table怎么用?Python CsRoute.add_table使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsRoute.CsRoute
的用法示例。
在下文中一共展示了CsRoute.add_table方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_config_change
# 需要导入模块: from CsRoute import CsRoute [as 别名]
# 或者: from CsRoute.CsRoute import add_table [as 别名]
def post_config_change(self, method):
route = CsRoute()
if method == "add":
route.add_table(self.dev)
route.add_route(self.dev, str(self.address["network"]))
elif method == "delete":
logging.warn("delete route not implemented")
self.fw_router()
self.fw_vpcrouter()
# On deletion nw_type will no longer be known
if self.get_type() in ["guest"] and self.config.is_vpc():
CsDevice(self.dev, self.config).configure_rp()
logging.error(
"Not able to setup source-nat for a regular router yet")
dns = CsDnsmasq(self)
dns.add_firewall_rules()
app = CsApache(self)
app.setup()
cmdline = self.config.cmdline()
# If redundant then this is dealt with by the master backup functions
if self.get_type() in ["guest"] and not cmdline.is_redundant():
pwdsvc = CsPasswdSvc(self.address['public_ip']).start()
if self.get_type() == "public" and self.config.is_vpc():
if self.address["source_nat"]:
vpccidr = cmdline.get_vpccidr()
self.fw.append(
["filter", "", "-A FORWARD -s %s ! -d %s -j ACCEPT" % (vpccidr, vpccidr)])
self.fw.append(
["nat", "", "-A POSTROUTING -j SNAT -o %s --to-source %s" % (self.dev, self.address['public_ip'])])
示例2: post_configure
# 需要导入模块: from CsRoute import CsRoute [as 别名]
# 或者: from CsRoute.CsRoute import add_table [as 别名]
def post_configure(self, address):
""" The steps that must be done after a device is configured """
route = CsRoute()
if not self.get_type() in ["control"]:
route.add_table(self.dev)
CsRule(self.dev).addMark()
self.check_is_up()
self.set_mark()
self.arpPing()
CsRpsrfs(self.dev).enable()
self.post_config_change("add")
'''For isolated/redundant and dhcpsrvr routers, call this method after the post_config is complete '''
if not self.config.is_vpc():
self.setup_router_control()
if self.config.is_vpc() or self.cl.is_redundant():
# The code looks redundant here, but we actually have to cater for routers and
# VPC routers in a different manner. Please do not remove this block otherwise
# The VPC default route will be broken.
if self.get_type() in ["public"]:
gateway = str(address["gateway"])
route.add_defaultroute(gateway)
else:
# once we start processing public ip's we need to verify there
# is a default route and add if needed
if(self.cl.get_gateway()):
route.add_defaultroute(self.cl.get_gateway())
示例3: post_configure
# 需要导入模块: from CsRoute import CsRoute [as 别名]
# 或者: from CsRoute.CsRoute import add_table [as 别名]
def post_configure(self):
""" The steps that must be done after a device is configured """
if not self.get_type() in ["control"]:
route = CsRoute()
route.add_table(self.dev)
CsRule(self.dev).addMark()
self.check_is_up()
self.set_mark()
self.arpPing()
CsRpsrfs(self.dev).enable()
self.post_config_change("add")
示例4: post_configure
# 需要导入模块: from CsRoute import CsRoute [as 别名]
# 或者: from CsRoute.CsRoute import add_table [as 别名]
def post_configure(self):
""" The steps that must be done after a device is configured """
if not self.get_type() in ["control"]:
route = CsRoute()
route.add_table(self.dev)
CsRule(self.dev).addMark()
self.check_is_up()
self.set_mark()
self.arpPing()
CsRpsrfs(self.dev).enable()
self.post_config_change("add")
'''For isolated/redundant and dhcpsrvr routers, call this method after the post_config is complete '''
if not self.config.is_vpc():
self.setup_router_control()
示例5: post_config_change
# 需要导入模块: from CsRoute import CsRoute [as 别名]
# 或者: from CsRoute.CsRoute import add_table [as 别名]
def post_config_change(self, method):
route = CsRoute()
if method == "add":
route.add_table(self.dev)
route.add_route(self.dev, str(self.address["network"]))
elif method == "delete":
logging.warn("delete route not implemented")
self.fw_router()
self.fw_vpcrouter()
# On deletion nw_type will no longer be known
if self.get_type() in ["guest"] and self.config.is_vpc():
CsDevice(self.dev, self.config).configure_rp()
logging.error("Not able to setup source-nat for a regular router yet")
dns = CsDnsmasq(self)
dns.add_firewall_rules()
app = CsApache(self)
app.setup()
cmdline = self.config.cmdline()
# Start passwd server on non-redundant routers and on the master router of redundant pairs
# CsRedundant will handle fail-over.
if self.get_type() in ["guest"] and (not self.cl.is_redundant() or self.cl.is_master()):
CsPasswdSvc(self.address["public_ip"]).start()
elif self.get_type() in ["guest"]:
# Or else make sure it's stopped
CsPasswdSvc(self.address["public_ip"]).stop()
if self.get_type() == "public" and self.config.is_vpc():
if self.address["source_nat"]:
vpccidr = cmdline.get_vpccidr()
self.fw.append(["filter", "", "-A FORWARD -s %s ! -d %s -j ACCEPT" % (vpccidr, vpccidr)])
self.fw.append(
["nat", "", "-A POSTROUTING -j SNAT -o %s --to-source %s" % (self.dev, self.address["public_ip"])]
)