5 from pprint import PrettyPrinter
7 # how could this accept a list again ?
9 now=time.strftime("%H:%M:%S", time.localtime())
10 print "*",now,'--',message
12 def pprint(message,spec,depth=2):
13 now=time.strftime("%H:%M:%S", time.localtime())
14 print ">",now,"--",message
15 PrettyPrinter(indent=8,depth=depth).pprint(spec)
17 def show_site_spec (site):
18 print '======== site',site['site_fields']['name']
19 for (k,v) in site.iteritems():
22 print '\t\t','nodes : ',
24 print node['node_fields']['hostname'],'',
30 print user['name'],'',
32 elif k == 'site_fields':
33 print '\t\tlogin_base',':',v['login_base']
34 elif k == 'address_fields':
38 PrettyPrinter(indent=8,depth=2).pprint(v)
40 def show_initscript_spec (initscript):
41 print '======== initscript',initscript['initscript_fields']['name']
43 def show_key_spec (key):
44 print '======== key',key['name']
46 def show_slice_spec (slice):
47 print '======== slice',slice['slice_fields']['name']
48 for (k,v) in slice.iteritems():
61 elif k=='slice_fields':
62 print '\t\tfields',':',
63 print 'max_nodes=',v['max_nodes'],
68 def show_test_spec (message,all_plc_specs):
69 now=time.strftime("%H:%M:%S", time.localtime())
70 print ">",now,"--",message
71 for plc_spec in all_plc_specs:
72 show_test_spec_pass (plc_spec,1)
73 show_test_spec_pass (plc_spec,2)
75 def show_test_spec_pass (plc_spec,passno):
76 for (key,val) in plc_spec.iteritems():
81 elif key=='initscripts':
82 for initscript in val:
83 show_initscript_spec (initscript)
86 show_slice_spec (slice)
91 if key not in ['sites','initscripts','slices','keys']:
92 print '\t',key,':',val
94 def system(command,background=False):
95 now=time.strftime("%H:%M:%S", time.localtime())
96 if background: command += " &"
97 print "+",now,':',command
98 return os.system("set -x; " + command)
100 def match (string, pattern):
101 # tmp - there's probably much simpler
102 # rewrite * into .*, ? into .
103 pattern=pattern.replace("*",".*")
104 pattern=pattern.replace("?",".")
105 return re.compile(pattern).match(string)