(vm_name, vif)
| 245 | |
| 246 | |
| 247 | def 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 | |
| 280 | def default_ebtables_rules(vm_name, vm_ip, vm_mac, vif, is_first_nic=False): |
no test coverage detected