plabnode.in 1.03 KB
Newer Older
1
#!/usr/local/bin/python
2 3 4 5
# -*- python -*-

import sys
sys.path.append("@prefix@/lib")
6
import getopt
7 8 9
import libplab

def usage(me):
10
    print "Usage: %s [ -vd ] { alloc | free } pid eid nodeid" % me
11 12 13
    sys.exit(1)

def main(args):
14
    me = args[0]
15
    try:
16 17 18
        command, pid, eid, nodeid = libplab.handleArgs(args[1:])
    except getopt.GetoptError:
        usage(me)
19
    except ValueError:
20
        usage(me)
21 22 23 24 25 26

    plab = libplab.Plab()
    slice = plab.loadSlice(pid, eid)
    if command == "alloc":
        node = slice.createNode(nodeid)
        try:
27 28
            node.addKey("/root/.ssh/identity.pub")
            node.emulabify()
29
            # XXX This file is redundant
30
            #node.putConfig("/etc/vnodeid", nodeid)
31 32 33 34 35 36 37 38 39 40 41 42 43
            # Note that vnode_setup boots the node
        except:
            print "Node setup failed.  Cleaning up"
            node.free()
            raise
    elif command == "free":
        node = slice.loadNode(nodeid)
        node.free()
    else:
        usage(me)

if __name__ == "__main__":
    main(sys.argv)