From: Sapan Bhatia Date: Mon, 18 Jul 2011 22:37:09 +0000 (-0400) Subject: The previous commit had some extra gunk. X-Git-Tag: vsys-scripts-0.95-30~3 X-Git-Url: http://git.onelab.eu/?p=vsys-scripts.git;a=commitdiff_plain;h=a6b19c6f5771ad8e9d838f85d7e58f7521b1bf2c The previous commit had some extra gunk. This reverts commit 91a70f483609c9700ebe156cc38659906e717db4. --- diff --git a/exec/claimport b/exec/claimport deleted file mode 100644 index ac1fdd3..0000000 --- a/exec/claimport +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python - -import sys -import os -import string - -vsys_config_dir = "/etc/planetlab/vsys-attributes" -slicename=sys.argv[1] -port_config=os.path.join(vsys_config_dir,slicename,"vsys_portreservation") - -ports = open(port_config).read().rstrip() -(low,high) = map(lambda n:int(n),ports.split('-')) - -arglines = map(string.strip, sys.stdin.readlines()) -if len(arglines)<1: - print >>sys.stderr, "Insufficient argument lines." - sys.exit(1) - -port = int(arglines[0]) # interface name - -def do_kill(p): - if (p): - slice_info = os.popen('chcontext --ctx 1 cat /proc/%s/vinfo'%p).readlines() - xid_info = slice_info[0] - slice_id = xid_info.split()[1] - os.system("vkill %s"%p) - slice = os.popen('getent passwd %s'%slice_id).read().split(':')[0] - mail_cmd = 'mail -s "PlanetLab notification" %s@slices.planet-lab.org -c %s@slices.planet-lab.org'%(slice,slicename) - f = os.popen(mail_cmd,'w') - f.write('Hi,\nOne of your processes on PlanetLab was terminated because you were using port %s, which is assigned to %s.'%(port,slicename)) - f.close() - - -if (low<=port<=high): - fuser_cmd = "ncontext --nid 1 --migrate -- chcontext --ctx 1 fuser -n tcp %d 2> /dev/null"%port - process_udp = os.popen(fuser_cmd).read().rstrip() - - fuser_cmd = "ncontext --nid 1 --migrate -- chcontext --ctx 1 fuser -n udp %d 2> /dev/null"%port - process_tcp = os.popen(fuser_cmd).read().rstrip() - - do_kill(process_tcp.lstrip()) - do_kill(process_udp.lstrip()) - -else: - print "%d is not in your range"%port diff --git a/exec/vif_up b/exec/vif_up index 00edd69..c151d63 100755 --- a/exec/vif_up +++ b/exec/vif_up @@ -14,7 +14,37 @@ import pwd import re import socket import struct -import o +import os +import string + +vsys_config_dir = "/etc/planetlab/vsys-attributes" + +if len(sys.argv) != 2: sys.exit(1) + +# VSYS scripts get slicename as $1 +slicename=sys.argv[1] +sliceid = pwd.getpwnam(slicename).pw_uid + +netblock_config=os.path.join(vsys_config_dir,slicename,"vsys_vnet") + +# Read netblock allocation file +base = None + +for netblock in open(netblock_config,'r'): + base, mask = netblock.split('/') + +if base is None: + print >>sys.stderr, "Could not find entry for slice %s in netblock config file %s" % (slicename, netblock_config) + sys.exit(1) + + +### Read args from stdin +arglines = map(string.strip, sys.stdin.readlines()) + +if len(arglines)<3: + print >>sys.stderr, "Insufficient argument lines." + sys.exit(1) + vif = arglines[0] # interface name vip = arglines[1] # IP vmask = int(arglines[2]) # netmask as int