From: Thierry Parmentelat Date: Mon, 31 Mar 2008 15:47:40 +0000 (+0000) Subject: smarter way to write configs, provide structure and map to avail. resources (testboxe... X-Git-Tag: tests-4.2-4~126 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2f5a9f05d3d581c1c5ebe75f1d4e55ef2c5d44d1;p=tests.git smarter way to write configs, provide structure and map to avail. resources (testboxes, ips, ..) later on --- diff --git a/system/TestMain.py b/system/TestMain.py index b0ce308..52d688f 100755 --- a/system/TestMain.py +++ b/system/TestMain.py @@ -77,13 +77,13 @@ steps refer to a method in TestPlc or to a step_* module help="Run all default steps") parser.add_option("-l","--list",action="store_true",dest="list_steps", default=False, help="List known steps") - parser.add_option("-s","--state",action="store",dest="dbname",default=None, - help="Used by db_dump and db_restore") - parser.add_option("-d","--display", action="store", dest="display", default='bellami.inria.fr:0.0', - help="Set DISPLAY for vmplayer") parser.add_option("-i","--ip",action="callback", callback=TestMain.optparse_list, dest="ips", nargs=1,type="string", help="Specify the set of IP addresses to use in vserver mode (disable scanning)") + parser.add_option("-s","--small",action="store_true",dest="small_test",default=False, + help="run a small test -- typically only one node") + parser.add_option("-d","--dbname",action="store",dest="dbname",default=None, + help="Used by db_dump and db_restore") parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False, help="Run in verbose mode") parser.add_option("-q","--quiet", action="store_true", dest="quiet", default=False, diff --git a/system/TestMapper.py b/system/TestMapper.py index 06ed8f7..87ec6c4 100644 --- a/system/TestMapper.py +++ b/system/TestMapper.py @@ -13,9 +13,8 @@ import utils class TestMapper: - def __init__ (self,plcs,mapper,options): + def __init__ (self,plcs,options): self.plcs=plcs - self.mapper=mapper self.options=options @staticmethod @@ -42,17 +41,16 @@ class TestMapper: o=obj for step in path[:-1]: if not o.has_key(step): - utils.header ("WARNING : cannot apply step %s in path %s on %s %s"%( + o[step]={} + utils.header ("WARNING : created step %s in path %s on %s %s"%( step,path,type,name)) - return - o=obj[step] + o=o[step] # last step is the one for side-effect step=path[-1] if not o.has_key(step): - utils.header ("WARNING : cannot apply step %s in path %s on %s %s"%( + utils.header ("WARNING : inserting key %s for path %s on %s %s"%( step,path,type,name)) - return - # apply formatting if found + # apply formatting if '%s' found in the value if v.find('%s')>=0: v=v%obj[k] if self.options.verbose: @@ -61,21 +59,32 @@ class TestMapper: # only apply first rule return - def map (self): + def node_names (self): + result=[] + for plc in self.plcs: + for site in plc['sites']: + for node in site['nodes']: + result.append(node['node_fields']['hostname']) + return result - plc_maps = self.mapper['plc'] + def map (self,mapper): + + try: + plc_maps = mapper['plc'] + except: + plc_maps = [] + try: + node_maps = mapper['node'] + except: + node_maps = [] for plc in self.plcs: name=TestMapper.plc_name(plc) self.apply_first_map ('plc',name,plc,plc_maps) - node_maps = self.mapper['node'] - for site in plc['sites']: for node in site['nodes']: nodename = TestMapper.node_name(node) self.apply_first_map('node',nodename,node,node_maps) return self.plcs - - diff --git a/system/TestNode.py b/system/TestNode.py index f8545e9..a893619 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -13,7 +13,7 @@ class TestNode: self.node_spec=node_spec def name(self): - return self.node_spec['node_fields']['hostname'] + return self.node_spec['name'] @staticmethod def is_qemu_model (model): diff --git a/system/TestPlc.py b/system/TestPlc.py index 46c6cbb..9ab023f 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -122,7 +122,7 @@ class TestPlc: def locate_node (self,nodename): for site in self.plc_spec['sites']: for node in site['nodes']: - if node['node_fields']['hostname'] == nodename: + if node['name'] == nodename: return (site,node) raise Exception,"Cannot locate node %s"%nodename diff --git a/system/TestPool.py b/system/TestPool.py new file mode 100644 index 0000000..61d24d9 --- /dev/null +++ b/system/TestPool.py @@ -0,0 +1,66 @@ +# +# Thierry Parmentelat - INRIA Sophia Antipolis +# +# pool class +# +# allows to pick an available IP among a pool +# +# input is expressed as a list of tuples ('hostname_or_ip',user_data) +# can be searched iteratively +# e.g. +# pool = [ (hostname1,ip1,user_data1), (hostname2,ip2,user_data2), +# (hostname3,ip3,user_data2), (hostname4,ip4,user_data4) ] +# assuming that ip1 and ip3 are taken (pingable), then we'd get +# pool=TestPool(pool) +# pool.next_free() -> entry2 +# pool.next_free() -> entry4 +# pool.next_free() -> None +# that is, even if ip2 is not busy/pingable when the second next_free() is issued + +import commands +import utils + +class TestPool: + + def __init__ (self, pool, options): + self.pool=pool + self.options=options + self.busy=[] + + def locate (self, hostname_or_ip): + for (h,i,u) in self.pool: + if h==hostname_or_ip or i==hostname_or_ip: + return (h,i,u) + return None + + def next_free (self): + # if preferred is provided, let's re-order + for (host,ip,user_data) in self.pool: + if host in self.busy: + continue + utils.header('TestPool : checking %s'%host) + if not TestPool.check_ping (host): + utils.header('%s is available'%host) + self.busy.append(host) + return (host,ip,user_data) + else: + self.busy.append(host) + return None + +# OS-dependent ping option (support for macos, for convenience) + ping_timeout_option = None +# checks whether a given hostname/ip responds to ping + @staticmethod + def check_ping (hostname): + if not TestPool.ping_timeout_option: + (status,osname) = commands.getstatusoutput("uname -s") + if status != 0: + raise Exception, "TestPool: Cannot figure your OS name" + if osname == "Linux": + TestPool.ping_timeout_option="-w" + elif osname == "Darwin": + TestPool.ping_timeout_option="-t" + + command="ping -c 1 %s 1 %s"%(TestPool.ping_timeout_option,hostname) + (status,output) = commands.getstatusoutput(command) + return status == 0 diff --git a/system/config_1testbox32.py b/system/config_1testbox32.py new file mode 100644 index 0000000..7bc0935 --- /dev/null +++ b/system/config_1testbox32.py @@ -0,0 +1,19 @@ +# +from TestMapper import TestMapper + +# using mapper to do the reallocation job + +target = 'testbox32.one-lab.org' + +def config (plcs, options): + + mapper = {'plc': [ ('*' , {'hostname':target, + 'PLC_DB_HOST':target, + 'PLC_API_HOST':target, + 'PLC_BOOT_HOST':target, + 'PLC_WWW_HOST':target, + 'name':'%s32' } ) ], + 'node': [ ('*' , {'host_box': target } ) ], + } + + return TestMapper(plcs,options).map(mapper) diff --git a/system/config_1testbox64.py b/system/config_1testbox64.py new file mode 100644 index 0000000..3d1f1b9 --- /dev/null +++ b/system/config_1testbox64.py @@ -0,0 +1,17 @@ +# +from TestMapper import TestMapper + +# using mapper to do the reallocation job + +def config (plcs, options): + + mapper = {'plc': [ ('*' , {'hostname':target, + 'PLC_DB_HOST':target, + 'PLC_API_HOST':target, + 'PLC_BOOT_HOST':target, + 'PLC_WWW_HOST':target, + 'name':'%s64' } ) ], + 'node': [ ('*' , {'host_box': target } ) ], + } + + return TestMapper(plcs,options).map(mapper) diff --git a/system/config_1vnodes.py b/system/config_1vnodes.py new file mode 100644 index 0000000..a9efc1a --- /dev/null +++ b/system/config_1vnodes.py @@ -0,0 +1,35 @@ +# map all nodes onto the avail. pool + +from TestMapper import TestMapper +from TestPool import TestPool + +onelab_plcs_pool = [ + ( 'vnode%02d.inria.fr'%i, '138.96.250.22%d'%i, 'ab:cd:ef:00:01:%02d'%i) for i in range(1,10) ] +site_dict = { + 'network_fields:gateway':'138.96.248.250', + 'network_fields:network':'138.96.0.0', + 'network_fields:broadcast':'138.96.255.255', + 'network_fields:netmask':'255.255.0.0', + 'network_fields:dns1': '138.96.0.10', + 'network_fields:dns2': '138.96.0.11', +} + +def config (plcs, options): + + test_pool = TestPool (onelab_plcs_pool,options) + test_mapper = TestMapper (plcs, options) + + all_nodenames = test_mapper.node_names() + maps = [] + for nodename in all_nodenames: + (hostname,ip,mac) = test_pool.next_free() + node_dict= {'node_fields:hostname':hostname, + 'network_fields:ip':ip, + 'network_fields:mac':mac} + node_dict.update(site_dict) + maps.append ( ( nodename, node_dict) ) + + plc_map = [ ( '*' , { 'PLC_NET_DNS1' : site_dict [ 'network_fields:dns1' ], + 'PLC_NET_DNS2' : site_dict [ 'network_fields:dns2' ], } ) ] + + return test_mapper.map ({'node': maps, 'plc' : plc_map } ) diff --git a/system/config_1vservers.py b/system/config_1vservers.py new file mode 100644 index 0000000..b6f6d09 --- /dev/null +++ b/system/config_1vservers.py @@ -0,0 +1,59 @@ +import utils +import os.path +from TestPool import TestPool + +# the pool of IP addresses available - from 01 to 09 +onelab_plcs_pool = [ + ( 'vplc%02d.inria.fr'%i, '138.96.250.13%d'%i, 'ab:cd:ef:00:00:%02d'%i) for i in range(1,10) ] + +# let's be flexible +def locate (user_provided): + global available + for (hostname,ip,mac) in available: + if hostname.find(user_provided) >=0 or ip.find(user_provided) >=0: + return (hostname,ip) + +def config (plcs,options): + + utils.header ("Turning configuration into a vserver-based one for onelab") + + test_pool = TestPool (onelab_plcs_pool,options) + + if len(options.ips) != 0: + utils.header('Using user-provided IPS:\nips=%r'%options.ips) + options.ips.reverse() + + plc_counter=0 + for plc in plcs: + try: + if len (options.ips != 0): + (hostname,ip,mac)=test_pool.locate(options.ips.pop()) + else: + (hostname,ip,mac)=test_pool.next_free() + + ### rewrite fields in plc + # compute a helpful vserver name - remove domain in hostname + simplehostname=hostname.split('.')[0] + # myplc rpm basename, without .rpm + vservername = os.path.basename(options.myplc_url) + vservername = vservername.replace(".rpm","") + # vservername + vservername = vservername.replace("myplc","vtest") + if len(plcs) == 1 : + vservername = "%s-%s" % (vservername,simplehostname) + else: + plc_counter += 1 + vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname) + # apply + plc['vservername']=vservername + plc['vserverip']=ip + plc['name'] = "%s_%s"%(plc['name'],simplehostname) + utils.header("Attaching plc %s to vserver %s (%s)"%( + plc['name'],plc['vservername'],plc['vserverip'])) + for key in [ 'PLC_DB_HOST', 'PLC_API_HOST', 'PLC_WWW_HOST', 'PLC_BOOT_HOST',]: + plc[key] = hostname + + except: + raise Exception('Cannot find an available IP for %s - exiting'%plc['name']) + + return plcs diff --git a/system/config_onelab.py b/system/config_main.py similarity index 63% rename from system/config_onelab.py rename to system/config_main.py index 7ab7795..de4a8a0 100644 --- a/system/config_onelab.py +++ b/system/config_main.py @@ -5,47 +5,52 @@ # (**) TestMain options field # (*) and that returns the new set of plc_specs -onelab="one-lab.org" +# values like 'hostname', 'ip' and the like my be rewritten later with a TestPool object -# host_box is taken as 'localhost' if omitted (should be a direct field in the node spec) -def nodes(): - nodes= [{'node_fields': {'hostname': 'vnode01.inria.fr', +def nodes(options): + nodes= [{'name':'node1', + 'node_fields': {'hostname': 'deferred01', 'model':'qemu/minhw', } , 'host_box': 'testbox1.one-lab.org', 'owner' : 'pi', 'network_fields': { 'method':'static', 'type':'ipv4', - 'ip':'138.96.250.221', - 'gateway':'138.96.248.250', - 'network':'138.96.0.0', - 'broadcast':'138.96.255.255', - 'netmask':'255.255.0.0', - 'dns1': '138.96.0.10', - 'dns2': '138.96.0.11', + 'ip':'xx-deferred-xxx', + 'gateway':'xx-deferred-xxx', + 'network':'xx-deferred-xxx', + 'broadcast':'xx-deferred-xxx', + 'netmask':'xx-deferred-xxx', + 'dns1': 'xx-deferred-xxx', + 'dns2': 'xx-deferred-xxx', + }, + }, + {'name':'node2', + 'node_fields': {'hostname': 'deferred02', + 'model':'qemu/minhw', } , + 'host_box': 'testbox1.one-lab.org', + 'owner' : 'pi', + 'network_fields': { 'method':'static', + 'type':'ipv4', + 'ip':'xx-deferred-xxx', + 'gateway':'xx-deferred-xxx', + 'network':'xx-deferred-xxx', + 'broadcast':'xx-deferred-xxx', + 'netmask':'xx-deferred-xxx', + 'dns1': 'xx-deferred-xxx', + 'dns2': 'xx-deferred-xxx', }, }, - #{'node_fields': {'hostname': 'vnode02.inria.fr', - # 'model':'qemu/minhw', } , - # 'host_box': 'testbox1.one-lab.org', - # 'owner' : 'pi', - # 'network_fields': { 'method':'static', - # 'type':'ipv4', - # 'ip':'138.96.250.222', - # 'gateway':'138.96.248.250', - # 'network':'138.96.0.0', - # 'broadcast':'138.96.255.255', - # 'netmask':'255.255.0.0', - # 'dns1': '138.96.0.10', - # 'dns2': '138.96.0.11', - # }, - # }, ] - return nodes + if options.small_test: + return [nodes[0]] + else: + return nodes -def all_nodenames (): - return [ node['node_fields']['hostname'] for node in nodes()] +def all_nodenames (options): + return [ node['name'] for node in nodes(options)] -def users (domain=onelab) : +def users (options) : + domain="one-lab.org" return [ {'name' : 'pi', 'keynames' : [ 'key1' ], 'user_fields' : {'first_name':'PI', 'last_name':'PI', 'enabled':'True', @@ -79,10 +84,10 @@ def users (domain=onelab) : 'roles':['pi','tech']}, ] -def all_usernames (): - return [ user['name'] for user in users()] +def all_usernames (options): + return [ user['name'] for user in users(options)] -def sites (): +def sites (options): return [ {'site_fields' : {'name':'mainsite', 'login_base':'main', 'abbreviated_name':'PLanettest', @@ -95,8 +100,8 @@ def sites (): 'postalcode':'06600', 'country':'france', }, - 'users' : users(), - 'nodes': nodes(), + 'users' : users(options), + 'nodes': nodes(options), }] ########## @@ -131,25 +136,29 @@ BO+VyPNWF+kDNI8mSUwi7jLW6liMdhNOmDaSX0+0X8CHtK898xM= -----END RSA PRIVATE KEY----- """ -def keys (): +def keys (options): return [ {'name': 'key1', 'private' : private_key, 'key_fields' : {'key_type':'ssh', 'key': public_key}} ] -def initscripts(): - return [ { 'initscript_fields' : { 'enabled' : True, - 'name':'script1', - 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/initscript1.log \n ', - }}, - { 'initscript_fields' : { 'enabled' : True, - 'name':'script2', - 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/initscript2.log \n ', - }}, - ] +def initscripts(options): + initscripts= [ { 'initscript_fields' : { 'enabled' : True, + 'name':'script1', + 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/initscript1.log \n ', + }}, + { 'initscript_fields' : { 'enabled' : True, + 'name':'script2', + 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/initscript2.log \n ', + }}, + ] + if options.small_test: + return [initscripts[0]] + else: + return initscripts -def slices (): +def slices (options): both = [ { 'slice_fields': {'name':'main_slicetest1', 'instantiation':'plc-instantiated', 'url':'http://foo@ffo.com', @@ -157,7 +166,7 @@ def slices (): 'max_nodes':2 }, 'usernames' : [ 'pi','tech','techuser' ], - 'nodenames' : all_nodenames(), + 'nodenames' : all_nodenames(options), 'initscriptname' : 'script1', 'sitename' : 'main', 'owner' : 'pi', @@ -169,39 +178,45 @@ def slices (): 'max_nodes':100 }, 'usernames' : [ 'user', 'pitech' ], - 'nodenames' : all_nodenames(), + 'nodenames' : all_nodenames(options), 'initscriptname' : 'script2', 'sitename' : 'main', 'owner' : 'pi', }] - return both + if options.small_test: + return [both[0]] + else: + return both -def all_slicenames (): - return [ slice['slice_fields']['name'] for slice in slices()] -#def tcp_param(): -# param = [{ 'tcp_fields' : {'peer_name' : 'server', -# 'slice_name' :all_slicenames()[0], -# 'server_name': all_nodenames()[0] -# }, -# -# }, -# { 'tcp_fields':{'peer_name' : 'client', -# 'slice_name' :all_slicenames()[1], -# 'client_name': all_nodenames()[1], -# 'peer_server' : all_nodenames()[0], -# 'server_port' : 22 -# }, -# }, -# -# ] -# return param +def all_slicenames (options): + return [ slice['slice_fields']['name'] for slice in slices(options)] + +def tcp_param (options): + try: + return [{ 'tcp_fields' : {'peer_name' : 'server', + 'slice_name' :all_slicenames(options)[0], + 'server_name': all_nodenames()[0] + }, + + }, + { 'tcp_fields':{'peer_name' : 'client', + 'slice_name' :all_slicenames()[1], + 'client_name': all_nodenames()[1], + 'peer_server' : all_nodenames()[0], + 'server_port' : 22 + }, + }, + + ] + except: + return None -def plc () : +def plc (options) : return { - 'name' : 'onelabtest', + 'name' : 'onetest', # as of yet, not sure we can handle foreign hosts, but this is required though - 'hostname' : 'testbox1.one-lab.org', + 'hostname' : 'xx-deferred-xxx', # set these two items to run within a vserver # 'vservername': '138.96.250.131' # 'vserverip': '138.96.250.131' @@ -215,14 +230,14 @@ def plc () : 'PLC_API_HOST' : 'test.one-lab.org', 'PLC_WWW_HOST' : 'test.one-lab.org', 'PLC_BOOT_HOST' : 'test.one-lab.org', - 'PLC_NET_DNS1' : '138.96.0.10', - 'PLC_NET_DNS2' : '138.96.0.11', - 'sites' : sites(), - 'keys' : keys(), - 'initscripts': initscripts(), - 'slices' : slices(), - #'tcp_param' : tcp_param(), + 'PLC_NET_DNS1' : 'xx-deferred-xxx', + 'PLC_NET_DNS2' : 'xx-deferred-xxx', + 'sites' : sites(options), + 'keys' : keys(options), + 'initscripts': initscripts(options), + 'slices' : slices(options), + 'tcp_param' : tcp_param(options), } def config (plc_specs,options): - return plc_specs + [ plc() ] + return plc_specs + [ plc(options) ] diff --git a/system/config_onelab_testbox32.py b/system/config_onelab_testbox32.py deleted file mode 100644 index 5a657a3..0000000 --- a/system/config_onelab_testbox32.py +++ /dev/null @@ -1,13 +0,0 @@ -# -from TestMapper import TestMapper - -# using mapper to do the reallocation job - -def config (plcs, options): - - mapper = {'plc': [ ('*' , {'hostname':'testbox32.one-lab.org', - 'name':'%s2' } ) ], - 'node': [ ('*' , {'host_box':'testbox32.one-lab.org'} ) ], - } - - return TestMapper(plcs,mapper,options).map() diff --git a/system/config_onelab_testbox64.py b/system/config_onelab_testbox64.py deleted file mode 100644 index 1d476b3..0000000 --- a/system/config_onelab_testbox64.py +++ /dev/null @@ -1,13 +0,0 @@ -# -from TestMapper import TestMapper - -# using mapper to do the reallocation job - -def config (plcs, options): - - mapper = {'plc': [ ('*' , {'hostname':'testbox64.one-lab.org', - 'name':'%s2' } ) ], - 'node': [ ('*' , {'host_box':'testbox64.one-lab.org'} ) ], - } - - return TestMapper(plcs,mapper,options).map() diff --git a/system/config_onelab_vserver.py b/system/config_onelab_vserver.py deleted file mode 100644 index bc9fc1a..0000000 --- a/system/config_onelab_vserver.py +++ /dev/null @@ -1,60 +0,0 @@ -import utils -import os.path - -# the pool of IP addresses available -# from 01 to 09 -available = [ ( 'vplc%02d.inria.fr'%i, '138.96.250.13%d'%i, 'ab:cd:ef:00:00:%02d'%i) for i in range(1,10) ] - -# let's be flexible -def locate (user_provided): - global available - for (hostname,ip,mac) in available: - if hostname.find(user_provided) >=0 or ip.find(user_provided) >=0: - return (hostname,ip) - -def config (plcs,options): - global available - available.reverse() - if len(options.ips) != 0: - options.ips.reverse() - plc_counter=0 - for plc in plcs: - if len(options.ips) != 0: - utils.header('ips=%r'%options.ips) - user_provided = options.ips.pop() - utils.header('vserver IP assignment : using user-provided %s'%user_provided) - (hostname,ip) = locate(user_provided) - else: - ### locating the next available hostname (using ping) - while True: - try: - (hostname,ip,mac)=available.pop() - utils.header('vserver IP assignment : scanning IP %s'%ip) - if not utils.check_ping(hostname): - utils.header('IP %s is OK'%ip) - break - except: - raise Exception('Cannot find an available IP for %s - exiting'%plc['name']) - # compute a helpful vserver name - plc_counter += 1 - simplehostname=hostname.split('.')[0] - vservername = os.path.basename(options.myplc_url) - vservername = vservername.replace(".rpm","") - vservername = vservername.replace("myplc","vtest") - if len(plcs) == 1 : - vservername = "%s-%s" % (vservername,simplehostname) - else: - vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname) - plc['vservername']=vservername - plc['vserverip']=ip - plc['name'] = "%s_%s"%(plc['name'],simplehostname) - utils.header("Attaching plc %s to vserver %s (%s)"%\ - (plc['name'],plc['vservername'],plc['vserverip'])) - for key in [ 'PLC_DB_HOST', - 'PLC_API_HOST', - 'PLC_WWW_HOST', - 'PLC_BOOT_HOST', - ]: - plc[key] = hostname - - return plcs diff --git a/system/config_wifilab.py b/system/config_wifilab.py index 4b89100..ba94866 100644 --- a/system/config_wifilab.py +++ b/system/config_wifilab.py @@ -9,7 +9,8 @@ onelab="one-lab.org" # use a model that contains "vmware" to get the node actually started def nodes(): - node02 = {'node_fields': {'hostname': 'wlab02.inria.fr', 'model':'Dell Latitude 830'}, + node02 = {'name':'wlab02', + 'node_fields': {'hostname': 'wlab02.inria.fr', 'model':'Dell Latitude 830'}, 'owner' : 'pi', 'nodegroups' : 'wifi', 'network_fields': { 'method':'dhcp', 'type' : 'ipv4', 'ip':'138.96.250.162',}, @@ -22,7 +23,8 @@ def nodes(): }, ], } - node05 = {'node_fields': {'hostname': 'wlab05.inria.fr', 'model':'Dell Latitude 830'}, + node05 = {'name':'wlab05', + 'node_fields': {'hostname': 'wlab05.inria.fr', 'model':'Dell Latitude 830'}, 'owner' : 'pi', 'nodegroups' : 'wifi', 'network_fields': { 'method':'dhcp', 'type' : 'ipv4', 'ip':'138.96.250.165',}, @@ -49,7 +51,8 @@ def nodes(): }, ], } - node17 = {'node_fields': {'hostname': 'wlab17.inria.fr', 'model':'Dell Latitude 830'}, + node17 = {'name':'wlab17', + 'node_fields': {'hostname': 'wlab17.inria.fr', 'model':'Dell Latitude 830'}, 'owner' : 'pi', 'nodegroups' : ['wifi','x86_64'] , 'network_fields': { 'method':'dhcp', 'type' : 'ipv4', 'ip':'138.96.250.177',}, @@ -66,7 +69,7 @@ def nodes(): return [ node02 , node05 , node17 ] def all_nodenames (): - return [ node['node_fields']['hostname'] for node in nodes()] + return [ node['name'] for node in nodes()] def users (domain=onelab) : return [ {'name' : 'pi', 'keynames' : [ 'key1' ], diff --git a/system/utils.py b/system/utils.py index c4adcb6..6c26318 100644 --- a/system/utils.py +++ b/system/utils.py @@ -1,7 +1,6 @@ # $Id$ import time import os -import commands from pprint import PrettyPrinter # how could this accept a list again ? @@ -96,22 +95,5 @@ def system(command): print "+",now,':',command return os.system("set -x; " + command) -# checks whether a given hostname/ip responds to ping -ping_timeout_option = None -def check_ping (hostname): - # check OS (support for macos) - global ping_timeout_option - if not ping_timeout_option: - (status,osname) = commands.getstatusoutput("uname -s") - if status != 0: - raise Exception, "Cannot figure your OS name" - if osname == "Linux": - ping_timeout_option="-w" - elif osname == "Darwin": - ping_timeout_option="-t" - - command="ping -c 1 %s 1 %s"%(ping_timeout_option,hostname) - (status,output) = commands.getstatusoutput(command) - return status == 0