1 # Script for checking whether a mapping exists in the vpp's map-cache
4 # vat_exec - VAT executable
5 # vpp_prefix - shared vpp memory prefix
6 # mapping - mapping to verify
12 def has_mapping(json, mapping):
17 if obj['eid'] == mapping:
22 def verify_mapping(vat_exec, prefix, mapping, vat_path):
23 vat_file = vat_path + '/' + 'dump_remote_mappings.tpl'
24 out = subprocess.Popen([vat_exec, "chroot", "prefix", prefix, "json", "script",
25 "in", vat_file], stdout=subprocess.PIPE).communicate()[0]
28 return has_mapping(o, mapping)
30 if __name__ == "__main__":
32 raise Exception('expected 4 parameters: VAT executable, shared prefix '
33 + ' name, mapping expected, path to vat templates!')
35 if verify_mapping(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]):