7 vsys_config_dir = "/etc/planetlab/vsys-attributes"
9 port_config=os.path.join(vsys_config_dir,slicename,"vsys_portreservation")
11 ports = open(port_config).read().rstrip()
12 (low,high) = map(lambda n:int(n),ports.split('-'))
14 arglines = map(string.strip, sys.stdin.readlines())
16 print >>sys.stderr, "Insufficient argument lines."
19 port = int(arglines[0]) # interface name
23 slice_info = os.popen('chcontext --ctx 1 cat /proc/%s/vinfo'%p).readlines()
24 xid_info = slice_info[0]
25 slice_id = xid_info.split()[1]
26 os.system("vkill %s"%p)
27 slice = os.popen('getent passwd %s'%slice_id).read().split(':')[0]
28 mail_cmd = 'mail -s "PlanetLab notification" %s@slices.planet-lab.org -c %s@slices.planet-lab.org'%(slice,slicename)
29 f = os.popen(mail_cmd,'w')
30 f.write('Hi,\nOne of your processes on PlanetLab was terminated because you were using port %s, which is assigned to %s.'%(port,slicename))
35 fuser_cmd = "ncontext --nid 1 --migrate -- chcontext --ctx 1 fuser -n tcp %d 2> /dev/null"%port
36 process_udp = os.popen(fuser_cmd).read().rstrip()
38 fuser_cmd = "ncontext --nid 1 --migrate -- chcontext --ctx 1 fuser -n udp %d 2> /dev/null"%port
39 process_tcp = os.popen(fuser_cmd).read().rstrip()
41 do_kill(process_tcp.lstrip())
42 do_kill(process_udp.lstrip())
45 print "%d is not in your range"%port