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

Function ebtables_rules_vmip

scripts/vm/network/security_group.py:490–506  ·  view source on GitHub ↗
(vmname, vmmac, ips, action)

Source from the content-addressed store, hash-verified

488 return True
489
490def ebtables_rules_vmip (vmname, vmmac, ips, action):
491 eb_vm_chain=ebtables_chain_name(vmname)
492 vmchain_inips = eb_vm_chain + "-in-ips"
493 vmchain_outips = eb_vm_chain + "-out-ips"
494
495 if action and action.strip() == "-A":
496 action = "-I"
497
498 for ip in [_f for _f in ips if _f]:
499 logging.debug("ip = " + ip)
500 if ip == 0 or ip == "0":
501 continue
502 try:
503 execute("ebtables -t nat " + action + " " + vmchain_inips + " -p ARP -s " + vmmac + " --arp-mac-src " + vmmac + " --arp-ip-src " + ip + " -j RETURN")
504 execute("ebtables -t nat " + action + " " + vmchain_outips + " -p ARP --arp-ip-dst " + ip + " -j RETURN")
505 except:
506 logging.debug("Failed to program ebtables rules for secondary ip %s for vm %s with action %s" % (ip, vmname, action))
507
508def check_default_network_rules(vm_name, vm_id, vm_ip, vm_ip6, vm_mac, vif, brname, sec_ips, is_first_nic=False):
509 brfw = get_br_fw(brname)

Callers 5

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