config.py 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/usr/bin/python

import argparse
import sys
import subprocess

def parse_manifest(args):

  nodes = []

  with open(args.manifest, "r") as m:
     for line in m:
       if "<emulab:vnode name=" in line:
         node_num = line.split("\"")[1].split("pc")[1]
         nodes.append(node_num)

  return nodes

def parse_args(args):
  
  parser = argparse.ArgumentParser(description='Configure HyPer4/ConViDa evaluation')
  parser.add_argument('--user', help='cloudlab username',
                      type=str, action="store")
  parser.add_argument('--manifest', help='path to cloudlab manifest',
                      type=str, action="store", default="manifest")

  parser.set_defaults(func=parse_manifest)

  return parser.parse_args(args)


def main():
  args = parse_args(sys.argv[1:])
  config_args = ['./config.sh']
  if args.user:
    nodes = args.func(args)
    config_args.append(args.user)
    config_args += nodes
  elif args.manifest:
    print("Error: missing cloudlab username")
    exit()
  
  subprocess.call(config_args)

if __name__ == '__main__':
  main()