else: with open('/tmp/login.exp', 'w') as fd: fd.write(expect_script.format(user, ip, passwd)) os.system("expect /tmp/login.exp") elif opts.list_sets: for name, tp in Sets.all(): print "{0} {1}".format(tp, name) elif opts.start_set: if len(files) == 1: print >> sys.stderr, "Cluster name should be given" storage = Storage() for vm in Sets().start(files[1], vconn()): storage.set_vm(vm.name, dict((eth.hw, eth.ip) for eth in vm.eths(with_ip = True))) elif opts.set_state: if len(files) == 1: print >> sys.stderr, "vm name template should be given" conn = vconn() all_ips = {} is_alive = {} all_names = [] for templ in files[1:]: if templ == 'ALL': templ = '*'