#!/usr/bin/env python
+# $Id$
import os, sys, time
from optparse import OptionParser
def main (self):
try:
- usage = """usage: %prog [options] MyplcURL"""
+ usage = """usage: %prog [options] [myplc-url]
+myplc-url defaults to the last value used, as stored in URL"""
parser=OptionParser(usage=usage,version=self.subversion_id)
# verbosity
parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False,
pids=[]
timset=time.strftime("%H:%M:%S", time.localtime())
#test the existence of the URL
- if (len (self.args)):
+ if (len (self.args) > 2):
+ parser.print_help()
+ sys.exit(1)
+ else if (len (self.args) == 1):
url=self.args[0]
- print 'the myplc url is ',url
else:
- print "PLease introduce a right URL for the myplc instal"
- sys.exit(1)
+ try:
+ url=open("%s/URL"%self.path)
+ url=url_file.read().strip()
+ url_file.close()
+ except:
+ print "Cannot determine myplc url"
+ parser.print_help()
+ sys.exit(1)
+ print '* Using myplc url:',url
#check where to display Virtual machines
if (self.options.Xterm):
display=self.options.Xterm
print "no way to find the virtual file"
sys.exit(1)
+ print 'Saving myplc url into URL'
+ fsave=open('%s/URL'%self.path,"w")
+ fsave.write(url)
+ fsave.write('\n')
+ fsave.close()
+
for plc_spec in TestConfig.plc_specs:
print '========>Creating plc at '+timset+':',plc_spec
test_plc = TestPlc(plc_spec)
+# $Id$
import os
import sys
import xmlrpclib
# now plc-config-tty silently creates needed directories
# os.system('mkdir -p /etc/planetlab/configs')
- fileconf=open('tty_conf','w')
+ tmpname='/tmp/plc-config-tty-%d'%os.getpid()
+ fileconf=open(tmpname,'w')
for var in [ 'PLC_NAME',
'PLC_ROOT_PASSWORD',
'PLC_ROOT_USER',
fileconf.write('w\n')
fileconf.write('q\n')
fileconf.close()
- os.system('set -x ; cat tty_conf')
- os.system('set -x ; chroot /plc/root plc-config-tty < tty_conf')
+ os.system('set -x ; cat %s'%tmpname)
+ os.system('set -x ; chroot /plc/root plc-config-tty < %s'%tmpname)
os.system('set -x ; service plc start')
os.system('set -x; service sendmail stop')
os.system('set -x; chroot /plc/root service sendmail restart')
+ os.system('set -x; rm %s'%tmpname)
def cleanup_plc(self):
os.system('service plc safestop')