1
2
3
4
5
6 """
7 List of cluster computers.
8 Each host must be accessible via ssh w/o password::
9
10 nodes_* .. lists with one entry per computer
11 cpus_* .. lists with one entry per CPU (usually that's the one used)
12
13 nodes/cpus_own .. computers reserved for own use, highest priority
14 nodes/cpus_shared.. computers shared with others, medium priority
15 nodes/cpus_other .. computers mainly used by others, lowest priority
16
17 nodes/cpus_all .. all computers in descending priority
18 nice_dic .. nice value for each host
19 """
20 import Biskit.mathUtils as MU
21 import os
22 import string as S
23
24 import ConfigParser
25
26
27 conf = ConfigParser.ConfigParser()
28 conf.read( os.path.expanduser('~/.biskit/hosts.dat' ) )
29
30
32 """
33 Get a list of hosts from the host list using ConfigParser.
34
35 @param section: ConfigParser section in ~/.biskit/hosts.dat
36 @type section: str
37 @param option: ConfigParser option in ~/.biskit/hosts.dat
38 @type option: str
39
40 @return: a list of hosts
41 @rtype: [str]
42 """
43
44
45 if conf.has_option( section, option ):
46 setting = conf.get( section, option )
47 setting = S.split( setting, '#' )
48 hosts = []
49 for host in S.split( setting[0], ' ' ):
50 if len(host) != 0:
51 hosts += [ S.strip(host) ]
52 return hosts
53 return []
54
55
57 """
58 Get a dictionary with host as key.
59
60 @param section: ConfigParser section in ~/.biskit/hosts.dat
61 @type section: str
62 @param option: ConfigParser option in ~/.biskit/hosts.dat
63 @type option: str
64
65 @return: a dictionary with host as key and (nice) value as value
66 @rtype: dict
67 """
68
69
70
71 dic = {}
72 for i in getHosts( section, option ):
73 i = S.split( i, ':' )
74 dic[ S.strip(i[0]) ] = float( i[1] )
75 return dic
76
77
78 dual = []
79
80
81
82
83 __dual = getHosts( 'own_hosts', 'dual' )
84 __single = getHosts( 'own_hosts', 'single' )
85
86 nodes_own = __dual +__single
87 cpus_own = __dual * 2 + __single
88
89 dual += __dual
90
91
92
93
94
95 __dual = getHosts( 'shared_hosts', 'dual' )
96 __single = getHosts( 'shared_hosts', 'single' )
97
98 dual += __dual
99
100 nodes_shared = __dual + __single
101 cpus_shared = __dual * 2 + __single
102
103
104
105
106
107 __dual = getHosts( 'others_hosts', 'dual' )
108 __single = getHosts( 'others_hosts', 'single' )
109
110 dual += __dual
111
112 nodes_other = __dual + __single
113 cpus_other = __dual * 2 + __single
114
115
116
117
118
119 nodes_all = nodes_own + nodes_shared + nodes_other
120 cpus_all = cpus_own + cpus_shared + cpus_other
121
122
123
124
125
126 nice_dic = { 'default':19 }
127 for h in nodes_own:
128 nice_dic[h] = 0
129 for h in cpus_shared:
130 nice_dic[h] = 0
131 for h in cpus_other:
132 nice_dic[h] = 17
133
134
135
136
137 own_nice = getDict( 'own_hosts', 'nice' )
138 shared_nice = getDict( 'shared_hosts', 'nice' )
139 others_nice = getDict( 'others_hosts', 'nice' )
140
141 nice_dic.update(own_nice)
142 nice_dic.update(shared_nice)
143 nice_dic.update(others_nice)
144
145
146
147
148
149 own_ram = getDict( 'own_hosts', 'ram' )
150 shared_ram = getDict( 'shared_hosts', 'ram' )
151 others_ram = getDict( 'others_hosts', 'ram' )
152
153 ram_dic = { 'default':0.5 }
154 for h in dual:
155 ram_dic[ h ] = 1.0
156
157 ram_dic.update(own_ram)
158 ram_dic.update(shared_ram)
159 ram_dic.update(others_ram)
160
161
162
163
164
165 nodes_exclude = []
166 nodes_exclude += getHosts( 'own_hosts', 'exclude' )
167 nodes_exclude += getHosts( 'shared_hosts', 'exclude' )
168 nodes_exclude += getHosts( 'others_hosts', 'exclude' )
169
170
171
172
173
174
175
176 REMOVE = 1
177
178 if REMOVE:
179 for l in [ nodes_all, cpus_all, nodes_own, cpus_own,
180 nodes_shared, cpus_shared, nodes_other, cpus_other ]:
181
182 MU.removeFromList( l, nodes_exclude, all=1 )
183
184
185
186
187 import Biskit.test as BT
188
189 -class Test(BT.BiskitTest):
190 """Mock test, hosts only contains data"""
191 pass
192