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

Function verify_ipset_for_vm

scripts/vm/network/security_group.py:1412–1445  ·  view source on GitHub ↗
(vm_name, vm_id, vm_ips, vm_ip6)

Source from the content-addressed store, hash-verified

1410 sys.exit(0)
1411
1412def verify_ipset_for_vm(vm_name, vm_id, vm_ips, vm_ip6):
1413 vmipsetName = ipset_chain_name(vm_name)
1414 vmipsetName6 = vmipsetName + '-6'
1415
1416 rules = []
1417 for rule in execute("ipset list %s" % vmipsetName).split('\n'):
1418 rules.append(rule)
1419
1420 # Check if all vm ips and ip6 exist
1421 for vm_ip in vm_ips:
1422 found = False
1423 for rule in rules:
1424 if rule == vm_ip:
1425 found = True
1426 break
1427 if not found:
1428 print("vm ip %s is not found" % vm_ip)
1429 return False
1430
1431 rules = []
1432 for rule in execute("ipset list %s" % vmipsetName6).split('\n'):
1433 rules.append(rule)
1434
1435 if vm_ip6 is not None:
1436 found = False
1437 for rule in rules:
1438 if rule == vm_ip6:
1439 found = True
1440 break
1441 if not found:
1442 print("vm ipv6 %s is not found" % vm_ip6)
1443 return False
1444
1445 return True
1446
1447def verify_iptables_rules_for_bridge(brname):
1448 brfw = get_br_fw(brname)

Callers 1

verify_network_rulesFunction · 0.85

Calls 3

ipset_chain_nameFunction · 0.85
executeFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected