From 66a6f94d121bc9c6902296500e9d301a1a2255e0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 19 Dec 2007 16:05:38 +0000 Subject: [PATCH] Test framework reworked for (*) modular scenarios for running step-by-step (*) modular configurations - ability to define alternate configurations (*) accepts and store BUILD URL needed for vserver-based plcs (not implem. yet), for locating myplc-init-vserver A lot still to be done, in terms of (*) cleaning (*) vserver vs chroot (*) management of remote plcs through ssh --- system/TestConfig.py | 150 -------------------- system/TestMain.py | 224 ++++++++++++++++++------------ system/TestNode.py | 135 +++++++----------- system/TestPlc.py | 203 ++++++++++++++++++++++----- system/TestSite.py | 246 ++++++++++++++------------------- system/TestUser.py | 50 +++++++ system/config-onelab-chroot.py | 171 +++++++++++++++++++++++ system/step-check-nodes.py | 15 ++ system/step-check-slices.py | 15 ++ system/step-fresh-install.py | 15 ++ 10 files changed, 727 insertions(+), 497 deletions(-) delete mode 100644 system/TestConfig.py create mode 100644 system/TestUser.py create mode 100644 system/config-onelab-chroot.py create mode 100644 system/step-check-nodes.py create mode 100644 system/step-check-slices.py create mode 100644 system/step-fresh-install.py diff --git a/system/TestConfig.py b/system/TestConfig.py deleted file mode 100644 index d8e6edb..0000000 --- a/system/TestConfig.py +++ /dev/null @@ -1,150 +0,0 @@ -#definition of all structure used by the test_setup.py script -site1_nodes = { -'node1' : {'hostname': 'test1.one-lab.org', - 'boot_state':'inst', - 'model':'vmware/minhw', - 'owned' : 'pi', - 'network': { 'method':'static', - 'type':'ipv4', - 'ip':'192.168.132.128', - 'gateway':'192.168.132.1', - 'network':'192.168.132.0', - 'broadcast':'192.168.132.255', - 'netmask':'255.255.255.0', - 'dns1': '192.168.132.2', - }, - - }, -'node2' : { 'hostname':'test2.one-lab.org', - 'boot_state':'inst', - 'model':'vmware/minhw', - 'owned' : 'tech', - 'network': {'method':'static', - 'type':'ipv4', - 'ip':'192.168.132.130', - 'gateway':'192.168.132.1', - 'network':'192.168.132.0', - 'broadcast':'192.168.132.255', - 'netmask':'255.255.255.0', - 'dns1': '192.168.132.2', - }, - - }, -} -site_users= { -'pi_spec' : {'first_name':'PI', - 'last_name':'PI', - 'enabled':'True', - 'email':'fake-pi1@one-lab.org', - 'password':'testpi', - 'roles':['pi'], - 'auth_meth':'pi', - }, -'tech_spec' : {'first_name':'Tech', - 'last_name':'Tech', - 'enabled':'true', - 'email':'fake-tech1@one-lab.org', - 'password':'testtech', - 'roles':['tech'], - 'auth_meth':'tech', - }, -'user_spec' : {'first_name':'User', - 'last_name':'User', - 'enabled':'true', - 'email':'fake-user1@one-lab.org', - 'password':'testuser', - 'roles':['user'], - 'auth_meth':'user', - }, -'tech_user_spec' : {'first_name':'UserTech', - 'last_name':'UserTech', - 'enabled':'true', - 'email':'fake-tech2@one-lab.org', - 'password':'testusertech', - 'roles':['tech','user'], - 'auth_meth':'techuser', - }, -'pi_tech_spec' : {'first_name':'PiTech', - 'last_name':'PiTech', - 'enabled':'true', - 'email':'fake-pi2@one-lab.org', - 'password':'testusertech', - 'roles':['pi','tech'], - 'auth_meth':'pitech', - }, -} -site_spec1 = { -'site_fields' : {'name':'testsite', - 'login_base':'ts', - 'abbreviated_name':'PLanettest', - 'max_slices':100, - 'url':'http://onelab-test.inria.fr', - }, -'site_address' : {'line1':'route des lucioles', - 'city':'sophia', - 'state':'fr', - 'postalcode':'06600', - 'country':'france', - }, -'users': [ site_users['pi_spec'], site_users['tech_spec'], site_users['user_spec'],site_users['tech_user_spec'],site_users['pi_tech_spec']], -'nodes' : [ site1_nodes['node1'], site1_nodes['node2']], -} - - -site_specs = [ site_spec1 ] - -plc_spec1 = { - 'hostname' : 'localhost', - 'role' : 'root', - 'PLC_ROOT_USER' : 'root@onelab-test.inria.fr', - 'PLC_ROOT_PASSWORD' : 'test++', - 'PLC_NAME' : 'TestLab', - 'PLC_MAIL_ENABLED':'true', - 'PLC_MAIL_SUPPORT_ADDRESS' : 'mohamed-amine.chaoui@sophia.inria.fr', - 'PLC_DB_HOST' : 'onelab-test.inria.fr', - 'PLC_API_HOST' : 'onelab-test.inria.fr', - 'PLC_WWW_HOST' : 'onelab-test.inria.fr', - 'PLC_BOOT_HOST' : 'onelab-test.inria.fr', - 'PLC_NET_DNS1' : '138.96.0.10', - 'PLC_NET_DNS2' : '138.96.0.11', - 'sites' : site_specs, - } -plc_specs = [ plc_spec1 ] - -key={'key_type':'ssh', - 'key':'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFUYyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXeWYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzVFN9YRhvQ/d8WDz84B5Pr0J7pWpaX7EyC4bvdskxl6kmdNIwIRcIe4OcuIiX5Z9oO+7h/chsEVJWF4vqNIYlL9Zvyhnr0hLLhhuk2bw== root@onelab-test.inria.fr'} - -initscripts =[{ 'enabled' : True, - 'name':'Test1', - 'script' : '#! /bin/sh\n echo Starting test initscript: Stage 1\n date > /tmp/test_initscript_stage1.log \n ', - }, - { 'enabled' : True, - 'name':'Test2', - 'script' : '#! /bin/sh\n echo Starting test initscript: Stage 2\n date > /tmp/test_initscript_stage2.log \n ', - } - ] - -slice1_spec={ -'slice_spec':{'name':'ts_slicetest1', - 'instantiation':'plc-instantiated', - 'url':'http://foo@ffo.com', - 'description':'testslice the first slice for the site testsite', - 'max_nodes':1000 - }, -'slice_users' : [ site_users['pi_spec'], site_users['tech_spec'],site_users['tech_user_spec']], -'slice_nodes' : [ site1_nodes['node1'], site1_nodes['node2'] ], -'slice_initscript' : initscripts[0], -} -slice2_spec={ -'slice_spec':{'name':'ts_slicetest2', - 'instantiation':'plc-instantiated', - 'url':'http://foo2@ffo2.com', - 'description':'testslice the second slice for the site testsite', - 'max_nodes':100 - }, -'slice_users' : [ site_users['pi_spec'], site_users['tech_spec'],site_users['tech_user_spec']], -'slice_nodes' : [ site1_nodes['node1'], site1_nodes['node2'] ], -'slice_initscript' : initscripts[1], -} -slices_specs= [slice1_spec, slice2_spec ] - diff --git a/system/TestMain.py b/system/TestMain.py index b0fc82e..1aeea5c 100755 --- a/system/TestMain.py +++ b/system/TestMain.py @@ -4,12 +4,17 @@ import os, sys from optparse import OptionParser import pprint +import traceback import utils from TestPlc import TestPlc from TestSite import TestSite from TestNode import TestNode -import TestConfig + + +#default_steps = ['uninstall','install','configure', 'populate' , 'check_nodes' ] +default_steps = ['uninstall','install','configure', 'sites', 'nodes', 'initscripts', 'slices', 'bootcd', 'start_nodes', 'check-nodes', 'check-slices' ] +other_steps = [ 'clean_sites', 'clean_slices' , 'stop_nodes' , 'db_dump' , 'fresh-install'] class TestMain: @@ -18,105 +23,148 @@ class TestMain: def __init__ (self): self.path=os.path.dirname(sys.argv[0]) - def main (self): + @staticmethod + def show_env (options, message): + utils.header (message) + pprint.PrettyPrinter(indent=4,depth=2).pprint(options) + + @staticmethod + def optparse_list (option, opt, value, parser): try: - usage = """usage: %prog [options] [myplc-url] -myplc-url defaults to the last value used, as stored in MYPLC-URL""" - parser=OptionParser(usage=usage,version=self.subversion_id) - - parser.add_option("-d","--display", action="store", dest="Xdisplay", default='bellami:0.0', - help="sets DISPLAY for vmplayer") - parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, - help="Run in verbose mode") - parser.add_option("-r","--run", action="store", dest="run_node", - help="Only starts vmplayer for the specified node") - parser.add_option("-h","--help", action="store_true", dest="help", default=False, - help="Displays this message") - (self.options, self.args) = parser.parse_args() - if self.options.help: - parser.print_help() - sys.exit(1) + setattr(parser.values,option.dest,getattr(parser.values,option.dest)+[value]) + except: + setattr(parser.values,option.dest,[value]) - display='' - url='' - test_plcs=[] - test_nodes=[] - pids=[] - #test the existence of the url - if (len (self.args) > 2): + def main (self): + usage = """usage: %prog [options] steps +myplc-url defaults to the last value used, as stored in MYPLC-URL +build-url defaults to the last value used, as stored in BUILD-URL +steps refer to a method in TestPlc or to a step-* module""" + usage += "\n Defaut steps are %r"%default_steps + usage += "\n Other useful steps are %r"%other_steps + parser=OptionParser(usage=usage,version=self.subversion_id) + parser.add_option("-u","--url",action="store", dest="myplc_url", + help="myplc URL - for locating build output") + parser.add_option("-b","--build",action="store", dest="build_url", + help="Build URL - for using myplc-init-vserver.sh in native mode") + parser.add_option("-c","--config",action="callback", callback=TestMain.optparse_list, dest="config", + nargs=1,type="string", + help="config module - can be set multiple times") + parser.add_option("-a","--all",action="store_true",dest="all_steps", default=False, + help="Runs all default steps") + parser.add_option("-d","--display", action="store", dest="display", default='bellami.inria.fr:0.0', + help="set DISPLAY for vmplayer") + parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, + help="Run in verbose mode") + parser.add_option("-n","--dry-run", action="store_true", dest="dry_run", default=False, + help="Show environment and exits") + (self.options, self.args) = parser.parse_args() + + if len(self.args) == 0: + if self.options.all_steps: + self.options.steps=default_steps + else: parser.print_help() sys.exit(1) - elif (len (self.args) == 1): - url=self.args[0] - else: + else: + self.options.steps = self.args + + # display display + utils.header('X11 display : %s'% self.options.display) + + # handle defaults and option persistence + for (recname,filename) in ( ('myplc_url','MYPLC-URL') , ('build_url','BUILD-URL') ) : + if not getattr(self.options,recname): try: - url_file=open("%s/MYPLC-URL"%self.path) + url_file=open("%s/%s"%(self.path,filename)) url=url_file.read().strip() url_file.close() + setattr(self.options,recname,url) except: - print "Cannot determine myplc url" + print "Cannot determine",recname parser.print_help() sys.exit(1) - utils.header('* Using myplc at url : %s'%url) - #check where to display Virtual machines - if (self.options.Xdisplay): - display=self.options.Xdisplay - utils.header('X11 display : %s'% display) - #the run option - if (self.options.run_node): - file=self.path+'/vmplayer-'+self.options.run_node+'/node.vmx' - if os.path.exists(file): - utils.header('starting vmplayer for node %s'%self.options.run_node) - os.system('DISPLAY=%s vmplayer %s '%(display,file)) - sys.exit(0) - else: - utils.header ('File not found %s - exiting'%file) - sys.exit(1) - - utils.header('Saving current myplc url into MYPLC-URL') - fsave=open('%s/MYPLC-URL'%self.path,"w") - fsave.write(url) + utils.header('* Using %s = %s'%(recname,getattr(self.options,recname))) + + fsave=open('%s/%s'%(self.path,filename),"w") + fsave.write(getattr(self.options,recname)) fsave.write('\n') fsave.close() + utils.header('Saved %s into %s'%(recname,filename)) + + # config modules + if not self.options.config: + # legacy default - do not set in optparse + self.options.config=['onelab-chroot'] + # step modules + if not self.options.steps: + #default (all) steps + #self.options.steps=['dump','clean','install','populate'] + self.options.steps=default_steps + + # store self.path in options.path for the various callbacks + self.options.path = self.path + + if self.options.verbose: + self.show_env(self.options,"Verbose") + + all_plc_specs = [] + for config in self.options.config: + modulename='config-'+config + try: + m = __import__(modulename) + all_plc_specs = m.config(all_plc_specs,self.options) + except : + traceback.print_exc() + print 'Cannot load config %s -- ignored'%modulename + # show config + utils.header ("Test specifications") + pprint.PrettyPrinter(indent=4,depth=2).pprint(all_plc_specs) + # build a TestPlc object from the result + for spec in all_plc_specs: + spec['disabled'] = False + all_plcs = [ (x, TestPlc(x)) for x in all_plc_specs] + + testplc_method_dict = __import__("TestPlc").__dict__['TestPlc'].__dict__ + all_step_infos=[] + for step in self.options.steps: + # try and locate a method in TestPlc + if testplc_method_dict.has_key(step): + all_step_infos += [ (step, testplc_method_dict[step] )] + # otherwise search for the 'run' method in the step- module + else: + modulename='step-'+step + try: + # locate all methods named run* in the module + module_dict = __import__(modulename).__dict__ + names = [ key for key in module_dict.keys() if key.find("run")==0 ] + if not names: + raise Exception,"No run* method in module %s"%modulename + names.sort() + all_step_infos += [ ("%s.%s"%(step,name),module_dict[name]) for name in names ] + except : + print 'Step %s -- ignored'%(step) + traceback.print_exc() + + if self.options.dry_run: + self.show_env(self.options,"Dry run") + sys.exit(0) + + # do all steps on all plcs + for (name,method) in all_step_infos: + for (spec,obj) in all_plcs: + if not spec['disabled']: + try: + utils.header("Running step %s on plc %s"%(name,spec['name'])) + if method(obj,self.options): + utils.header('Successful step %s on %s'%(name,spec['name'])) + else: + utils.header('Step %s on %s FAILED - discarding'%(name,spec['name'])) + spec['disabled'] = True + except: + spec['disabled'] = True + print 'Cannot run step %s on plc %s'%(name,spec['name']) + traceback.print_exc() - pp = pprint.PrettyPrinter(indent=4,depth=2) - for plc_spec in TestConfig.plc_specs: - utils.header('Creating plc with spec') - pp.pprint(plc_spec) - test_plc = TestPlc(plc_spec) - test_plc.connect() - test_plcs.append(test_plc) - test_plc.cleanup_plc() - utils.header('Installing myplc from url %s'%url) - test_plc.install_plc(url) - test_plc.config_plc(plc_spec) - ##create all the sites under the new plc,and then populate them with - ##nodes,persons and slices(with initscripts) - for site_spec in plc_spec['sites']: - utils.header('Creating site') - pp.pprint(site_spec) - test_site = test_plc.init_site(site_spec) - for node_spec in site_spec['nodes']: - utils.header('Creating node') - pp.pprint(node_spec) - test_nodes.append(node_spec) - test_node = test_plc.init_node(test_site,node_spec,self.path) - test_node.add_initscripts() - test_node.create_slice ("pi") - utils.header('Starting vmware nodes') - test_site.run_vmware(test_nodes,display) - utils.header('Checking nodes') - if(test_site.node_check_status(test_nodes,True)): - test_plc.db_dump() - test_site.slice_access() - print "System test successful" - return 0 - else : - print "System test failed" - sys.exit(1) - except Exception, e: - print str(e) - sys.exit(1) - if __name__ == "__main__": TestMain().main() diff --git a/system/TestNode.py b/system/TestNode.py index e63b8bd..ceabd8d 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -2,8 +2,8 @@ import os, sys, time, base64 import xmlrpclib import pprint -import TestConfig import utils +from TestUser import TestUser class TestNode: @@ -12,71 +12,23 @@ class TestNode: self.test_site=test_site self.node_spec=node_spec - def create_node (self,role): - auth = self.test_site.anyuser_auth (role) + def name(self): + return self.node_spec['node_fields']['hostname'] + + def create_node (self): + ownername = self.node_spec['owner'] + user_spec = self.test_site.locate_user(ownername) + test_user = TestUser(self.test_plc,self.test_site,user_spec) + auth = test_user.auth() + utils.header("node %s created by user %s"%(self.name(),test_user.name())) filter={'boot_state':'rins'} - try: - if (role=='pi' and self.node_spec['owned']=='pi'): - self.node_id = \ - self.test_plc.server.AddNode(auth, - self.test_site.site_spec['site_fields']['login_base'], - self.node_spec) - self.test_plc.server.AddNodeNetwork(auth,self.node_id, - self.node_spec['network']) - self.test_plc.server.UpdateNode(auth, self.node_id, filter) - return self.node_id - - elif (role=='tech' and self.node_spec['owned']=='tech'): - self.node_id = \ - self.test_plc.server.AddNode(auth, - self.test_site.site_spec['site_fields']['login_base'], - self.node_spec) - self.test_plc.server.AddNodeNetwork(auth,self.node_id, - self.node_spec['network']) - self.test_plc.server.UpdateNode(auth, self.node_id, filter) - return self.node_id - except Exception, e: - print str(e) - - def add_initscripts(self): - try: - for initscript in TestConfig.initscripts: - utils.header('Adding Initscripts') - pp = pprint.PrettyPrinter(indent=4) - pp.pprint(initscript) - self.initscript_id=self.test_plc.server.AddInitScript(self.test_plc.auth_root(), - initscript) - except Exception, e: - print str(e) - exit (1) + self.test_plc.server.AddNode(auth, + self.test_site.site_spec['site_fields']['login_base'], + self.node_spec['node_fields']) + self.test_plc.server.AddNodeNetwork(auth,self.name(), + self.node_spec['network_fields']) + self.test_plc.server.UpdateNode(auth, self.name(), filter) - def create_slice(self, role): - auth = self.test_site.anyuser_auth (role) - liste_hosts=[] - try: - for slicespec in TestConfig.slices_specs : - utils.header('Creating Slice') - pp = pprint.PrettyPrinter(indent=4) - pp.pprint(slicespec) - slice_id=self.test_plc.server.AddSlice(auth,slicespec['slice_spec']) - for sliceuser in slicespec['slice_users']: - self.test_plc.server.AddPersonToSlice(auth, - sliceuser['email'], - slice_id) - for slicenode in slicespec['slice_nodes']: - liste_hosts.append(slicenode['hostname']) - self.test_plc.server.AddSliceToNodes(auth, - slice_id, - liste_hosts) - - self.test_plc.server.AddSliceAttribute(self.test_plc.auth_root(), - slice_id, 'initscript', - slicespec['slice_initscript']['name']) - - except Exception, e: - print str(e) - sys.exit(1) - def conffile(self,image,hostname,path): template='%s/template-vmplayer/node.vmx'%(path) actual='%s/vmplayer-%s/node.vmx'%(path,hostname) @@ -86,22 +38,39 @@ class TestNode: def create_boot_cd(self,path): node_spec=self.node_spec - hostname=node_spec['hostname'] - try: - utils.header('Initializing vmplayer area for node %s'%hostname) - clean_dir="rm -rf %s/vmplayer-%s"%(path,hostname) - mkdir_command="mkdir -p %s/vmplayer-%s"%(path,hostname) - tar_command="tar -C %s/template-vmplayer -cf - . | tar -C %s/vmplayer-%s -xf -"%(path,path,hostname) - os.system('set -x; ' +clean_dir + ';' + mkdir_command + ';' + tar_command); - utils.header('Creating boot medium for node %s'%hostname) - encoded=self.test_plc.server.GetBootMedium(self.test_plc.auth_root(), hostname, 'node-iso', '') - if (encoded == ''): - raise Exception, 'boot.iso not found' - file=open(path+'/vmplayer-'+hostname+'/boot_file.iso','w') - file.write(base64.b64decode(encoded)) - file.close() - utils.header('boot cd created for %s'%hostname) - self.conffile('boot_file.iso',hostname, path) - except Exception, e: - print str(e) - sys.exit(1) + hostname=node_spec['node_fields']['hostname'] + utils.header('Initializing vmplayer area for node %s'%hostname) + clean_dir="rm -rf %s/vmplayer-%s"%(path,hostname) + mkdir_command="mkdir -p %s/vmplayer-%s"%(path,hostname) + tar_command="tar -C %s/template-vmplayer -cf - . | tar -C %s/vmplayer-%s -xf -"%(path,path,hostname) + os.system('set -x; ' +clean_dir + ';' + mkdir_command + ';' + tar_command); + utils.header('Creating boot medium for node %s'%hostname) + encoded=self.test_plc.server.GetBootMedium(self.test_plc.auth_root(), hostname, 'node-iso', '') + if (encoded == ''): + raise Exception, 'boot.iso not found' + file=open(path+'/vmplayer-'+hostname+'/boot_file.iso','w') + file.write(base64.b64decode(encoded)) + file.close() + utils.header('boot cd created for %s'%hostname) + self.conffile('boot_file.iso',hostname, path) + + def start_node (self,options): + model=self.node_spec['node_fields']['model'] + if model.find("vmware") >= 0: + self.start_vmware(options) + elif model.find("qemu") >= 0: + self.start_qemu(options) + else: + utils.header("TestNode.start_node : ignoring model %s"%model) + + def start_vmware (self,options): + hostname=self.node_spec['node_fields']['hostname'] + path=options.path + display=options.display + utils.header('Starting vmplayer for node %s on %s'%(hostname,display)) + os.system('set -x; cd %s/vmplayer-%s ; DISPLAY=%s vmplayer node.vmx < /dev/null >/dev/null 2>/dev/null &'%(path,hostname,display)) + + def start_qemu (self, options): + utils.header ("TestNode.start_qemu: not implemented yet") + + diff --git a/system/TestPlc.py b/system/TestPlc.py index a76da42..274d73c 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -3,8 +3,14 @@ import os import sys import xmlrpclib import datetime +import pprint +import traceback +import utils from TestSite import TestSite from TestNode import TestNode +from TestUser import TestUser + +# step methods must take (self, options) and return a boolean class TestPlc: @@ -13,7 +19,14 @@ class TestPlc: self.url="https://%s:443/PLCAPI/"%plc_spec['hostname'] self.server=xmlrpclib.Server(self.url,allow_none=True) self.path=os.path.dirname(sys.argv[0]) + try: + self.vserver=plc_spec['vserver'] + except: + self.vserver=None + def name(self): + return self.plc_spec['name'] + def connect (self): # tricky : define les methodes de l'API sur cet object pass @@ -30,8 +43,52 @@ class TestPlc: fileHandle.write ( str(test_case_name)+'\t' +str(status)+'\t'+str(timers)+'\n') fileHandle.close() + def init_node (self,test_site,node_spec,path): + + test_node = TestNode(self, test_site, node_spec) + test_node.create_node (test_site.locate_user("pi")) + test_node.create_node ("tech") + test_node.create_boot_cd(path) + return test_node + + def locate_site (self,sitename): + for site in self.plc_spec['sites']: + if site['site_fields']['name'] == sitename: + return site + if site['site_fields']['login_base'] == sitename: + return site + raise Exception,"Cannot locate site %s"%sitename + + def locate_key (self,keyname): + for key in self.plc_spec['keys']: + if key['name'] == keyname: + return key + raise Exception,"Cannot locate key %s"%keyname + + def kill_all_vmwares(self): + utils.header('Killing any running vmware or vmplayer instance') + os.system('pgrep vmware | xargs -r kill') + os.system('pgrep vmplayer | xargs -r kill ') + os.system('pgrep vmware | xargs -r kill -9') + os.system('pgrep vmplayer | xargs -r kill -9') + + # step methods + def uninstall(self,options): + os.system('set -x; service plc safestop') + #####detecting the last myplc version installed and remove it + os.system('set -x; rpm -e myplc') + ##### Clean up the /plc directory + os.system('set -x; rm -rf /plc/data') + return True + + def install(self,options): + utils.header('Installing from %s'%options.myplc_url) + url=options.myplc_url + os.system('set -x; rpm -Uvh '+url) + os.system('set -x; service plc mount') + return True - def config_plc(self,plc_spec): + def configure(self,options): tmpname='/tmp/plc-config-tty-%d'%os.getpid() fileconf=open(tmpname,'w') for var in [ 'PLC_NAME', @@ -45,7 +102,7 @@ class TestPlc: 'PLC_BOOT_HOST', 'PLC_NET_DNS1', 'PLC_NET_DNS2']: - fileconf.write ('e %s\n%s\n'%(var,plc_spec[var])) + fileconf.write ('e %s\n%s\n'%(var,self.plc_spec[var])) fileconf.write('w\n') fileconf.write('q\n') fileconf.close() @@ -55,42 +112,118 @@ class TestPlc: os.system('set -x; service sendmail stop') os.system('set -x; chroot /plc/root service sendmail restart') os.system('set -x; rm %s'%tmpname) + return True - def cleanup_plc(self): - os.system('set -x; service plc safestop') - #####detecting the last myplc version installed and remove it - os.system('set -x; rpm -e myplc') - ##### Clean up the /plc directory - os.system('set -x; rm -rf /plc/data') - - def install_plc(self,url): - os.system('set -x; rpm -Uvh '+url) - os.system('set -x; service plc mount') - - def init_site (self,site_spec): - test_site = TestSite (self,site_spec) - test_site.create_site() - for key in site_spec['users']: - test_site.create_user(key) - test_site.enable_user(key) - test_site.add_key_user(key) - return test_site + def sites (self,options): + return self.do_sites(options) + + def clean_sites (self,options): + return self.do_sites(options,"delete") + + def do_sites (self,options,action="add"): + for site_spec in self.plc_spec['sites']: + test_site = TestSite (self,site_spec) + if (action == "delete"): + utils.header("Deleting site %s in %s"%(test_site.name(),self.name())) + test_site.delete_site() + # deleted with the site + #test_site.delete_users() + continue + else: + utils.header("Creating site %s & users in %s"%(test_site.name(),self.name())) + test_site.create_site() + test_site.create_users() + return True - def init_node (self,test_site,node_spec,path): + def nodes (self, options): + for site_spec in self.plc_spec['sites']: + test_site = TestSite (self,site_spec) + utils.header("Creating nodes for site %s in %s"%(test_site.name(),self.name())) + for node_spec in site_spec['nodes']: + utils.header('Creating node %s'%node_spec) + pprint.PrettyPrinter(indent=4).pprint(node_spec) + test_node = TestNode (self,test_site,node_spec) + test_node.create_node () + return True - test_node = TestNode(self, test_site, node_spec) - test_node.create_node ("pi") - test_node.create_node ("tech") - test_node.create_boot_cd(path) - return test_node - - def db_dump(self): + def bootcd (self, options): + for site_spec in self.plc_spec['sites']: + test_site = TestSite (self,site_spec) + for node_spec in site_spec['nodes']: + test_node=TestNode (self,test_site,node_spec) + test_node.create_boot_cd(options.path) + return True + + def initscripts (self, options): + for initscript in self.plc_spec['initscripts']: + utils.header('Adding Initscript %s in plc %s'%\ + (initscript['name'],self.plc_spec['name'])) + pprint.PrettyPrinter(indent=4).pprint(initscript) + self.server.AddInitScript(self.auth_root(),initscript['initscript_fields']) + return True + + def slices (self, options): + return self.do_slices() + + def clean_slices (self, options): + return self.do_slices("delete") + + ### would need a TestSlice class + def do_slices (self, add_or_delete="add"): + for slice in self.plc_spec['slices']: + site_spec = self.locate_site (slice['sitename']) + test_site = TestSite(self,site_spec) + owner_spec = test_site.locate_user(slice['owner']) + auth = TestUser(self,test_site,owner_spec).auth() + slice_fields = slice['slice_fields'] + slice_name = slice_fields['name'] + if (add_or_delete == "delete"): + self.server.DeleteSlice(auth,slice_fields['name']) + utils.header("Deleted slice %s"%slice_fields['name']) + continue + pprint.PrettyPrinter(indent=4).pprint(slice_fields) + self.server.AddSlice(auth,slice_fields) + utils.header('Created Slice %s'%slice_fields['name']) + for username in slice['usernames']: + user_spec=test_site.locate_user(username) + test_user=TestUser(self,test_site,user_spec) + self.server.AddPersonToSlice(auth, test_user.name(), slice_name) + + hostnames=[] + for nodename in slice['nodenames']: + node_spec=test_site.locate_node(nodename) + test_node=TestNode(self,test_site,node_spec) + hostnames += [test_node.name()] + utils.header("Adding %r in %s"%(hostnames,slice_name)) + self.server.AddSliceToNodes(auth, slice_name, hostnames) + if slice.has_key('initscriptname'): + isname=slice['initscriptname'] + utils.header("Adding initscript %s in %s"%(isname,slice_name)) + self.server.AddSliceAttribute(self.auth_root(), slice_name, + 'initscript',isname) + return True - t=datetime.datetime.now() - d=t.date() - dump='/var/lib/pgsql/backups/planetlab4-'+str(d)+'-2nodes' + def start_nodes (self, options): + self.kill_all_vmwares() + utils.header("Starting vmware nodes") + for site_spec in self.plc_spec['sites']: + TestSite(self,site_spec).start_nodes (options) + return True + + def stop_nodes (self, options): + self.kill_all_vmwares () + return True + + def db_dump(self, options): + # uses options.dbname if it is found + try: + name=options.dbname + except: + t=datetime.datetime.now() + d=t.date() + name=str(d) + dump='/data/%s.sql'%name os.system('chroot /plc/root pg_dump -U pgsqluser planetlab4 -f '+ dump) - print 'dump is done',dump - + utils.header('Dumped planetlab4 database in %s'%dump) + return True - diff --git a/system/TestSite.py b/system/TestSite.py index 7edd280..9357d5f 100644 --- a/system/TestSite.py +++ b/system/TestSite.py @@ -3,83 +3,66 @@ import sys import datetime import time import xmlrpclib +import traceback -from TestConfig import * import utils +from TestNode import TestNode +from TestUser import TestUser class TestSite: def __init__ (self,test_plc,site_spec): self.test_plc=test_plc self.site_spec=site_spec - self.sitename=site_spec['site_fields']['name'] + def name(self): + return self.site_spec['site_fields']['login_base'] + def create_site (self): - try: - print self.test_plc.auth_root() - self.site_id = self.test_plc.server.AddSite(self.test_plc.auth_root(), - self.site_spec['site_fields']) - self.test_plc.server.AddSiteAddress(self.test_plc.auth_root(),self.site_id, - self.site_spec['site_address']) + print self.test_plc.auth_root() + self.site_id = self.test_plc.server.AddSite(self.test_plc.auth_root(), + self.site_spec['site_fields']) + self.test_plc.server.AddSiteAddress(self.test_plc.auth_root(),self.site_id, + self.site_spec['address_fields']) - return self.site_id - except Exception, e: - print str(e) + return self.site_id - def site_id(self): - return self.site_id() + def create_users (self): + for user_spec in self.site_spec['users']: + test_user=TestUser(self.test_plc,self,user_spec) + test_user.create_user() + test_user.add_keys() + - def create_user (self, user_spec): - try: - i=0 - utils.header('Adding user %s'%user_spec['email']) - self.person_id=self.test_plc.server.AddPerson(self.test_plc.auth_root(), - user_spec) - self.test_plc.server.UpdatePerson(self.test_plc.auth_root(), - self.person_id,{'enabled': True}) - for role in user_spec['roles']: - self.test_plc.server.AddRoleToPerson(self.test_plc.auth_root(), - role,user_spec['email']) - self.test_plc.server.AddPersonToSite(self.test_plc.auth_root(), - user_spec['email'], - self.site_spec['site_fields']['login_base']) - except Exception,e: - print str(e) - - def enable_user (self, user_spec): - try: - persones=self.test_plc.server.GetPersons(self.test_plc.auth_root()) - for person in persones: - if (person['enabled']!="True"): - self.test_plc.server.UpdatePerson(self.test_plc.auth_root(), - person['person_id'], - {'enabled': True}) - except Exception,e: - print str(e) + def delete_site (self): + print self.test_plc.auth_root() + self.test_plc.server.DeleteSite(self.test_plc.auth_root(),self.name()) + return True - def add_key_user(self,user_spec): - try: - auth="" - for userspec in self.site_spec['users']: - if(user_spec == userspec): - for role in userspec['roles']: - auth=auth+role - print auth - self.test_plc.server.AddPersonKey(self.anyuser_auth(auth), - user_spec['email'], key) - except Exception, e: - print str(e) - - def anyuser_auth (self,key): - for person in self.site_spec['users']: - if person['auth_meth']== key : - return {'Username':person['email'], - 'AuthMethod':'password', - 'AuthString':person['password'], - 'Role':person['roles'][0], - } + def delete_users(self): + for user_spec in self.site_spec['users']: + test_user=TestUser(self.test_plc,self,user_spec) + test_user.delete_user() - def node_check_status(self,liste_nodes,bool): + def locate_user (self,username): + for user in self.site_spec['users']: + if user['name'] == username: + return user + if user['user_fields']['email'] == username: + return user + raise Exception,"Cannot locate user %s"%username + + def locate_node (self,nodename): + for node in self.site_spec['nodes']: + if node['node_fields']['hostname'] == nodename: + return node + raise Exception,"Cannot locate node %s"%nodename + + # left as-is, i.e. crappy + def check_nodes(self): + # should filter out nodes not under vmware not qemu + node_specs=self.site_spec['nodes'] + bool=True try: ret_value=True filter=['boot_state'] @@ -88,10 +71,10 @@ class TestSite: secondes=15 start_time = datetime.datetime.now() ##geting the current time dead_time=datetime.datetime.now()+ datetime.timedelta(minutes=5) - utils.header("Starting checking for nodes in site %s"%self.sitename) + utils.header("Starting checking for nodes in site %s"%self.name()) - for l in liste_nodes : - hostname=l['hostname'] + for node_spec in node_specs : + hostname=node_spec['node_fields']['hostname'] while (bool): node_status=self.test_plc.server.GetNodes(self.test_plc.auth_root(),hostname, filter) utils.header('Actual status for node %s is [%s]'%(hostname,node_status)) @@ -120,91 +103,72 @@ class TestSite: test_name='Test Installation Node Hosted: ',hostname self.test_plc.display_results(test_name, 'Failure', '') - utils.header("End checking for nodes in site %s"%self.sitename) + utils.header("End checking for nodes in site %s"%self.name()) return ret_value except Exception, e: - print str(e) + traceback.print_exc() utils.header("will kill vmware in 10 seconds") - time.sleep(10) - self.kill_all_vmwares() - sys.exit(1) + time.sleep(5) + self.tst_plc.kill_all_vmwares() + raise - def kill_all_vmwares(self): - utils.header('Killing any running vmware or vmplayer instance') - os.system('pgrep vmware | xargs -r kill') - os.system('pgrep vmplayer | xargs -r kill ') - os.system('pgrep vmware | xargs -r kill -9') - os.system('pgrep vmplayer | xargs -r kill -9') - - def run_vmware(self,node_specs,display): - path=os.path.dirname(sys.argv[0]) - self.kill_all_vmwares() - utils.header('Displaying vmplayer on DISPLAY=%s'%display) - for spec in node_specs : - hostname=spec['hostname'] - utils.header('Starting vmplayer for node %s -- see vmplayer.log'%hostname) -# os.system('set -x; cd %s/vmplayer-%s ; DISPLAY=%s vmplayer node.vmx < /dev/null 2>&1 >> vmplayer.log &'%(path,hostname,display)) - os.system('set -x; cd %s/vmplayer-%s ; DISPLAY=%s vmplayer node.vmx < /dev/null >/dev/null 2>/dev/null &'%(path,hostname,display)) - + def start_nodes (self,options): + for node_spec in self.site_spec['nodes']: + TestNode(self.test_plc, self, node_spec).start_node(options) + return True + def delete_known_hosts(self): utils.header("Messing with known_hosts (cleaning hostnames starting with 'test[0-9]')") sed_command="sed -i -e '/^test[0-9]/d' /root/.ssh/known_hosts" os.system("set -x ; " + sed_command) - def slice_access(self): - try: - bool=True - bool1=True - secondes=15 - self.delete_known_hosts() - start_time = datetime.datetime.now() - dead_time=start_time + datetime.timedelta(minutes=3)##adding 3minutes - for slice in slices_specs: - for slicenode in slice['slice_nodes']: - hostname=slicenode['hostname'] - slicename=slice['slice_spec']['name'] - while(bool): - utils.header('restarting nm on %s'%hostname) - access=os.system('set -x; ssh -i /etc/planetlab/root_ssh_key.rsa root@%s service nm restart'%hostname ) - if (access==0): - utils.header('nm restarted on %s'%hostname) - while(bool1): - utils.header('trying to connect to %s@%s'%(slicename,hostname)) + # xxx should be attached to TestPlc + def check_slices(self): + + bool=True + bool1=True + secondes=15 + self.delete_known_hosts() + start_time = datetime.datetime.now() + dead_time=start_time + datetime.timedelta(minutes=3)##adding 3minutes + for slice_spec in self.test_plc.plc_spec['slices']: + for hostname in slice_spec['nodenames']: + slicename=slice_spec['slice_fields']['name'] + while(bool): + utils.header('restarting nm on %s'%hostname) + access=os.system('set -x; ssh -i /etc/planetlab/root_ssh_key.rsa root@%s service nm restart'%hostname ) + if (access==0): + utils.header('nm restarted on %s'%hostname) + while(bool1): + utils.header('trying to connect to %s@%s'%(slicename,hostname)) + Date=os.system('set -x; ssh -i ~/.ssh/slices.rsa %s@%s date'%(slicename,hostname)) + if (Date==0): + break + elif ( start_time <= dead_time ) : + start_time=datetime.datetime.now()+ datetime.timedelta(seconds=30) + time.sleep(secondes) + else: + bool1=False + if(bool1): + utils.header('connected to %s@%s -->'%(slicename,hostname)) + else: + utils.header('%s@%s : last chance - restarting nm on %s'%(slicename,hostname,hostname)) + access=os.system('set -x; ssh -i /etc/planetlab/root_ssh_key.rsa root@%s service nm restart'%hostname) + if (access==0): + utils.header('trying to connect (2) to %s@%s'%(slicename,hostname)) Date=os.system('set -x; ssh -i ~/.ssh/slices.rsa %s@%s date'%(slicename,hostname)) if (Date==0): - break - elif ( start_time <= dead_time ) : - start_time=datetime.datetime.now()+ datetime.timedelta(seconds=30) - time.sleep(secondes) + utils.header('connected to %s@%s -->'%(slicename,hostname)) else: - bool1=False - if(bool1): - utils.header('connected to %s@%s -->'%(slicename,hostname)) - else: - utils.header('%s@%s : last chance - restarting nm on %s'%(slicename,hostname,hostname)) - access=os.system('set -x; ssh -i /etc/planetlab/root_ssh_key.rsa root@%s service nm restart'%hostname) - if (access==0): - utils.header('trying to connect (2) to %s@%s'%(slicename,hostname)) - Date=os.system('set -x; ssh -i ~/.ssh/slices.rsa %s@%s date'%(slicename,hostname)) - if (Date==0): - utils.header('connected to %s@%s -->'%(slicename,hostname)) - else: - utils.header('giving up with to %s@%s -->'%(slicename,hostname)) - sys.exit(1) - else : - utils.header('Last chance failed on %s@%s -->'%(slicename,hostname)) - break - elif ( start_time <= dead_time ) : - start_time=datetime.datetime.now()+ datetime.timedelta(minutes=1) - time.sleep(secondes) - else: - bool=False - - if (not bool): - print 'Node manager problems' - sys.exit(1) - - except Exception, e: - print str(e) - sys.exit(1) - + utils.header('giving up with to %s@%s -->'%(slicename,hostname)) + sys.exit(1) + else : + utils.header('Last chance failed on %s@%s -->'%(slicename,hostname)) + break + elif ( start_time <= dead_time ) : + start_time=datetime.datetime.now()+ datetime.timedelta(minutes=1) + time.sleep(secondes) + else: + bool=False + + return bool diff --git a/system/TestUser.py b/system/TestUser.py new file mode 100644 index 0000000..6646e04 --- /dev/null +++ b/system/TestUser.py @@ -0,0 +1,50 @@ +import os, sys, time +import xmlrpclib +import pprint + +import utils + +class TestUser: + + def __init__ (self,test_plc,test_site,user_spec): + self.test_plc=test_plc + self.test_site=test_site + self.user_spec=user_spec + + def name(self): + return self.user_spec['user_fields']['email'] + + def auth (self): + person=self.user_spec['user_fields'] + return {'Username':person['email'], + 'AuthMethod':'password', + 'AuthString':person['password'], + 'Role':self.user_spec['roles'][0], + } + + def create_user (self): + user_spec=self.user_spec + fields=user_spec['user_fields'] + auth=self.test_plc.auth_root() + utils.header('Adding user %s - roles %r'%(fields['email'],user_spec['roles'])) + self.test_plc.server.AddPerson(auth,fields) + self.test_plc.server.UpdatePerson(auth,fields['email'],{'enabled': True}) + for role in user_spec['roles']: + self.test_plc.server.AddRoleToPerson(auth,role,fields['email']) + self.test_plc.server.AddPersonToSite(auth, + self.name(), + self.test_site.name()) + + def delete_user(self): + auth=self.test_plc.auth_root() + self.test_plc.server.DeletePerson(auth,self.name()) + + def add_keys (self): + user_spec=self.user_spec + for keyname in user_spec['keynames']: + key=self.test_plc.locate_key(keyname) + auth=self.auth() + self.test_plc.server.AddPersonKey(auth,self.name(), key['key_fields']) + + + diff --git a/system/config-onelab-chroot.py b/system/config-onelab-chroot.py new file mode 100644 index 0000000..070788d --- /dev/null +++ b/system/config-onelab-chroot.py @@ -0,0 +1,171 @@ +# a configuration module is expected: +# (*) to define a config method +# (*) that takes two arguments +# (**) the current set of plc_specs as output by the preceding config modules +# (**) TestMain options field +# (*) and that returns the new set of plc_specs + +onelab="one-lab.org" + +# use a model that contains "vmware" to get the node actually started +def nodes(): + return [ {'node_fields': {'hostname': 'test1.one-lab.org', + 'model':'vmware/minhw'}, + 'owner' : 'pi', + 'network_fields': { 'method':'static', + 'type':'ipv4', + 'ip':'192.168.132.128', + 'gateway':'192.168.132.1', + 'network':'192.168.132.0', + 'broadcast':'192.168.132.255', + 'netmask':'255.255.255.0', + 'dns1': '192.168.132.2', + }, + }, + { 'node_fields': {'hostname':'test2.one-lab.org', + 'model':'vmware/minhw'}, + 'owner' : 'tech', + 'network_fields': {'method':'static', + 'type':'ipv4', + 'ip':'192.168.132.130', + 'gateway':'192.168.132.1', + 'network':'192.168.132.0', + 'broadcast':'192.168.132.255', + 'netmask':'255.255.255.0', + 'dns1': '192.168.132.2', + }, + }, + ] + +def all_nodenames (): + return [ node['node_fields']['hostname'] for node in nodes()] + +def users (domain=onelab) : + return [ {'name' : 'pi', 'keynames' : [ 'key1' ], + 'user_fields' : {'first_name':'PI', 'last_name':'PI', + 'enabled':'True', + 'email':'fake-pi1@%s'%domain, + 'password':'testpi'}, + 'roles':['pi']}, + {'name' : 'tech', 'keynames' : [ 'key1' ], + 'user_fields' : {'first_name':'Tech', 'last_name':'Tech', + 'enabled':'true', + 'email':'fake-tech1@%s'%domain, + 'password':'testtech'}, + 'roles':['tech']}, + {'name':'user', 'keynames' : [ 'key1' ], + 'user_fields' : {'first_name':'User', 'last_name':'User', + 'enabled':'true', + 'email':'fake-user1@%s'%domain, + 'password':'testuser'}, + 'roles':['user']}, + {'name':'techuser', 'keynames' : [ 'key1' ], + 'user_fields' : {'first_name':'UserTech', 'last_name':'UserTech', + 'enabled':'true', + 'email':'fake-tech2@%s'%domain, + 'password':'testusertech'}, + 'roles':['tech','user']}, + {'name':'pitech', 'keynames' : [ 'key1' ], + 'user_fields' : {'first_name':'PiTech', + 'last_name':'PiTech', + 'enabled':'true', + 'email':'fake-pi2@%s'%domain, + 'password':'testusertech'}, + 'roles':['pi','tech']}, + ] + +def all_usernames (): + return [ user['name'] for user in users()] + +def sites (): + return [ {'site_fields' : {'name':'mainsite', + 'login_base':'main', + 'abbreviated_name':'PLanettest', + 'max_slices':100, + 'url':'http://onelab-test.inria.fr', + }, + 'address_fields' : {'line1':'route des lucioles', + 'city':'sophia', + 'state':'fr', + 'postalcode':'06600', + 'country':'france', + }, + 'users' : users(), + 'nodes': nodes(), + }] + +def keys (): + return [ {'name': 'key1', + 'key_fields' : {'key_type':'ssh', + 'key':'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFUYyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXeWYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzVFN9YRhvQ/d8WDz84B5Pr0J7pWpaX7EyC4bvdskxl6kmdNIwIRcIe4OcuIiX5Z9oO+7h/chsEVJWF4vqNIYlL9Zvyhnr0hLLhhuk2bw== root@onelab-test.inria.fr'}} + ] + +def initscripts(): + return [ { 'name' : 'test1', + 'initscript_fields' : { 'enabled' : True, + 'name':'Test1', + 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/initscript1.log \n ', + }}, + { 'name' : 'test2', + 'initscript_fields' : { 'enabled' : True, + 'name':'Test2', + 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/initscript2.log \n ', + }}, + ] + +def slices (): + both = [ { 'slice_fields': {'name':'main_slicetest1', + 'instantiation':'plc-instantiated', + 'url':'http://foo@ffo.com', + 'description':'testslice the first slice for the site testsite', + 'max_nodes':2 + }, + 'usernames' : [ 'pi','tech','techuser' ], + 'nodenames' : all_nodenames(), + 'initscriptname' : 'test1', + 'sitename' : 'main', + 'owner' : 'pi', + }, + { 'slice_fields': {'name':'main_slicetest2', + 'instantiation':'plc-instantiated', + 'url':'http://foo2@ffo2.com', + 'description':'testslice the second slice for the site testsite', + 'max_nodes':100 + }, + 'usernames' : [ 'user', 'pitech' ], + 'nodenames' : all_nodenames(), + 'initscriptname' : 'test2', + 'sitename' : 'main', + 'owner' : 'pi', + }] + # I suspect the check_slices stuff to work improperly with 2 slices + return both + +def plc () : + return { + 'name' : 'onelab-chroot', + # as of yet, not sure we can handle foreign hosts, but this is required though + 'hostname' : 'localhost', + # use this to run in a vserver + # 'vserver': '138.96.250.131' + 'role' : 'root', + 'PLC_ROOT_USER' : 'root@onelab-test.inria.fr', + 'PLC_ROOT_PASSWORD' : 'test++', + 'PLC_NAME' : 'TestLab', + 'PLC_MAIL_ENABLED':'true', + 'PLC_MAIL_SUPPORT_ADDRESS' : 'mohamed-amine.chaoui@sophia.inria.fr', + 'PLC_DB_HOST' : 'onelab-test.inria.fr', + 'PLC_API_HOST' : 'onelab-test.inria.fr', + 'PLC_WWW_HOST' : 'onelab-test.inria.fr', + 'PLC_BOOT_HOST' : 'onelab-test.inria.fr', + 'PLC_NET_DNS1' : '138.96.0.10', + 'PLC_NET_DNS2' : '138.96.0.11', + 'sites' : sites(), + 'keys' : keys(), + 'initscripts': initscripts(), + 'slices' : slices(), + } + +def config (plc_specs,options): + return plc_specs + [ plc() ] + diff --git a/system/step-check-nodes.py b/system/step-check-nodes.py new file mode 100644 index 0000000..a953069 --- /dev/null +++ b/system/step-check-nodes.py @@ -0,0 +1,15 @@ +import utils +from TestPlc import TestPlc +from TestSite import TestSite + +# requirement is to implement +# run (plc_spec, options) + +def run (test_plc,options): + + result=True + for site_spec in test_plc.plc_spec['sites']: + utils.header('Checking nodes') + if not TestSite(test_plc,site_spec).check_nodes(): + result=False + return result diff --git a/system/step-check-slices.py b/system/step-check-slices.py new file mode 100644 index 0000000..9c85447 --- /dev/null +++ b/system/step-check-slices.py @@ -0,0 +1,15 @@ +import utils +from TestPlc import TestPlc +from TestSite import TestSite + +# requirement is to implement +# run (plc_spec, options) + +def run (test_plc,options): + + result=True + for site_spec in test_plc.plc_spec['sites']: + utils.header('Checking slices') + if not TestSite(test_plc,site_spec).check_slices(): + result=False + return result diff --git a/system/step-fresh-install.py b/system/step-fresh-install.py new file mode 100644 index 0000000..90afd7d --- /dev/null +++ b/system/step-fresh-install.py @@ -0,0 +1,15 @@ +import utils +from TestPlc import TestPlc + +# requirement is to implement +# run* (plc_spec, options) + +def run01_uninstall (test_plc,options): + return test_plc.uninstall(options) +def run02_install (test_plc,options): + return test_plc.install(options) +def run03_configure (test_plc,options): + return test_plc.configure(options) +def run04_dump_just_installed (test_plc,options): + options.dbname='just-installed' + return test_plc.db_dump(options) -- 2.43.0