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

Function destroy_ebtables_rules

scripts/vm/network/security_group.py:247–277  ·  view source on GitHub ↗
(vm_name, vif)

Source from the content-addressed store, hash-verified

245
246
247def destroy_ebtables_rules(vm_name, vif):
248 eb_vm_chain = ebtables_chain_name(vm_name)
249 delcmd = "ebtables -t nat -L PREROUTING | grep " + eb_vm_chain
250 delcmds = []
251 try:
252 delcmds = [_f for _f in execute(delcmd).split('\n') if _f]
253 delcmds = ["-D PREROUTING " + x for x in delcmds ]
254 except:
255 pass
256 postcmds = []
257 try:
258 postcmd = "ebtables -t nat -L POSTROUTING | grep " + eb_vm_chain
259 postcmds = [_f for _f in execute(postcmd).split('\n') if _f]
260 postcmds = ["-D POSTROUTING " + x for x in postcmds]
261 except:
262 pass
263
264 delcmds += postcmds
265
266 for cmd in delcmds:
267 try:
268 execute("ebtables -t nat " + cmd)
269 except:
270 logging.debug("Ignoring failure to delete ebtables rules for vm " + vm_name)
271 chains = [eb_vm_chain+"-in", eb_vm_chain+"-out", eb_vm_chain+"-in-ips", eb_vm_chain+"-out-ips", eb_vm_chain+"-in-src", eb_vm_chain+"-out-dst"]
272 for chain in chains:
273 try:
274 execute("ebtables -t nat -F " + chain)
275 execute("ebtables -t nat -X " + chain)
276 except:
277 logging.debug("Ignoring failure to delete ebtables chain for vm " + vm_name)
278
279
280def default_ebtables_rules(vm_name, vm_ip, vm_mac, vif, is_first_nic=False):

Callers 4

default_ebtables_rulesFunction · 0.85
refactor_ebtable_rulesFunction · 0.85
default_network_rulesFunction · 0.85

Calls 3

ebtables_chain_nameFunction · 0.85
debugMethod · 0.80
executeFunction · 0.70

Tested by

no test coverage detected