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

Function refactor_ebtable_rules

scripts/vm/network/security_group.py:351–372  ·  view source on GitHub ↗
(vm_name)

Source from the content-addressed store, hash-verified

349 return False
350
351def refactor_ebtable_rules(vm_name):
352 vmchain_in = vm_name + "-in"
353 vmchain_in_ips = vm_name + "-in-ips"
354 vmchain_in_src = vm_name + "-in-src"
355
356 try:
357 execute("ebtables -t nat -L " + vmchain_in_src)
358 logging.debug("Chain '" + vmchain_in_src + "' exists, ebtables rules have newer version, skip refactoring")
359 return True
360 except:
361 logging.debug("Chain '" + vmchain_in_src + "' does not exist, ebtables rules have old version, start refactoring")
362
363 vif = execute("ebtables -t nat -L PREROUTING | grep " + vmchain_in + " | awk '{print $2}'").strip()
364 vm_mac = execute("ebtables -t nat -L " + vmchain_in + " | grep arp-mac-src | awk '{print $5}'").strip()
365 vm_ips = execute("ebtables -t nat -L " + vmchain_in_ips + " | grep arp-ip-src | awk '{print $4}'").split('\n')
366
367 destroy_ebtables_rules(vm_name, vif)
368 default_ebtables_rules(vm_name, None, vm_mac, vif, True)
369 ebtables_rules_vmip(vm_name, vm_mac, vm_ips, "-A")
370
371 logging.debug("Refactoring ebtables rules for vm " + vm_name + " is done")
372 return True
373
374def default_network_rules_systemvm(vm_name, localbrname):
375 bridges = get_bridges(vm_name)

Callers 1

Calls 5

destroy_ebtables_rulesFunction · 0.85
default_ebtables_rulesFunction · 0.85
ebtables_rules_vmipFunction · 0.85
debugMethod · 0.80
executeFunction · 0.70

Tested by

no test coverage detected