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