def removeSAPNAT(self, SAPSwitch):
SAPip = SAPSwitch.ip
SAPNet = str(ipaddress.IPv4Network(unicode(SAPip), strict=False))
# due to a bug with python-iptables, removing and finding rules does not succeed when the mininet CLI is running
# so we use the iptables tool
rule0_ = "iptables -t nat -D POSTROUTING ! -o {0} -s {1} -j MASQUERADE".format(SAPSwitch.deployed_name, SAPNet)
p = Popen(shlex.split(rule0_))
p.communicate()
rule1_ = "iptables -D FORWARD -o {0} -j ACCEPT".format(SAPSwitch.deployed_name)
p = Popen(shlex.split(rule1_))
p.communicate()
rule2_ = "iptables -D FORWARD -i {0} -j ACCEPT".format(SAPSwitch.deployed_name)
p = Popen(shlex.split(rule2_))
p.communicate()
info("remove SAP NAT rules for: {0} - {1}\n".format(SAPSwitch.name, SAPNet))
评论列表
文章目录