OLD | NEW |
1 // DTM submission automation program | 1 // DTM submission automation program |
2 // Author: Michael Goldish <mgoldish@redhat.com> | 2 // Author: Michael Goldish <mgoldish@redhat.com> |
3 // Based on sample code by Microsoft. | 3 // Based on sample code by Microsoft. |
4 | 4 |
5 // Note: this program has only been tested with DTM version 1.5. | 5 // Note: this program has only been tested with DTM version 1.5. |
6 // It might fail to work with other versions, specifically because it uses | 6 // It might fail to work with other versions, specifically because it uses |
7 // a few undocumented methods/attributes. | 7 // a few undocumented methods/attributes. |
8 | 8 |
9 using System; | 9 using System; |
10 using System.Collections.Generic; | 10 using System.Collections.Generic; |
11 using System.Text.RegularExpressions; | 11 using System.Text.RegularExpressions; |
12 using Microsoft.DistributedAutomation.DeviceSelection; | 12 using Microsoft.DistributedAutomation.DeviceSelection; |
13 using Microsoft.DistributedAutomation.SqlDataStore; | 13 using Microsoft.DistributedAutomation.SqlDataStore; |
14 | 14 |
15 namespace automate0 | 15 namespace automate0 |
16 { | 16 { |
17 class AutoJob | 17 class AutoJob |
18 { | 18 { |
19 // Wait for a machine to show up in the data store | |
20 static void FindMachine(IResourcePool rootPool, string machineName) | |
21 { | |
22 Console.WriteLine("Looking for machine '{0}'", machineName); | |
23 IResource machine = null; | |
24 while (true) | |
25 { | |
26 try | |
27 { | |
28 machine = rootPool.GetResourceByName(machineName); | |
29 } | |
30 catch (Exception e) | |
31 { | |
32 Console.WriteLine("Warning: " + e.Message); | |
33 } | |
34 // Make sure the machine is valid | |
35 if (machine != null && | |
36 machine.OperatingSystem != null && | |
37 machine.OperatingSystem.Length > 0 && | |
38 machine.ProcessorArchitecture != null && | |
39 machine.ProcessorArchitecture.Length > 0 && | |
40 machine.GetDevices().Length > 0) | |
41 break; | |
42 System.Threading.Thread.Sleep(1000); | |
43 } | |
44 Console.WriteLine("Client machine '{0}' found ({1}, {2})", | |
45 machineName, machine.OperatingSystem, machine.ProcessorArchitect
ure); | |
46 } | |
47 | |
48 // Delete a machine pool if it exists | |
49 static void DeleteResourcePool(IDeviceScript script, string poolName) | |
50 { | |
51 while (true) | |
52 { | |
53 try | |
54 { | |
55 IResourcePool pool = script.GetResourcePoolByName(poolName); | |
56 if (pool != null) | |
57 script.DeleteResourcePool(pool); | |
58 break; | |
59 } | |
60 catch (Exception e) | |
61 { | |
62 Console.WriteLine("Warning: " + e.Message); | |
63 System.Threading.Thread.Sleep(1000); | |
64 } | |
65 } | |
66 } | |
67 | |
68 // Set the machine's status to 'Reset' and optionally wait for it to bec
ome ready | |
69 static void ResetMachine(IResourcePool rootPool, string machineName, boo
l wait) | |
70 { | |
71 Console.WriteLine("Resetting machine '{0}'", machineName); | |
72 IResource machine; | |
73 while (true) | |
74 { | |
75 try | |
76 { | |
77 machine = rootPool.GetResourceByName(machineName); | |
78 machine.ChangeResourceStatus("Reset"); | |
79 break; | |
80 } | |
81 catch (Exception e) | |
82 { | |
83 Console.WriteLine("Warning: " + e.Message); | |
84 System.Threading.Thread.Sleep(5000); | |
85 } | |
86 } | |
87 if (wait) | |
88 { | |
89 Console.WriteLine("Waiting for machine '{0}' to be ready", machi
neName); | |
90 while (machine.Status != "Ready") | |
91 { | |
92 try | |
93 { | |
94 machine = rootPool.GetResourceByName(machineName); | |
95 } | |
96 catch (Exception e) | |
97 { | |
98 Console.WriteLine("Warning: " + e.Message); | |
99 } | |
100 System.Threading.Thread.Sleep(1000); | |
101 } | |
102 Console.WriteLine("Machine '{0}' is ready", machineName); | |
103 } | |
104 } | |
105 | |
106 // Look for a device in a machine, and if not found, keep trying for 3 m
inutes | |
107 static IDevice GetDevice(IResourcePool rootPool, string machineName, str
ing regexStr) | |
108 { | |
109 Regex deviceRegex = new Regex(regexStr, RegexOptions.IgnoreCase); | |
110 int numAttempts = 1; | |
111 DateTime endTime = DateTime.Now.AddSeconds(180); | |
112 while (DateTime.Now < endTime) | |
113 { | |
114 IResource machine = rootPool.GetResourceByName(machineName); | |
115 Console.WriteLine("Looking for device '{0}' in machine '{1}' (ma
chine has {2} devices)", | |
116 regexStr, machineName, machine.GetDevices().Length); | |
117 foreach (IDevice d in machine.GetDevices()) | |
118 { | |
119 if (deviceRegex.IsMatch(d.FriendlyName)) | |
120 { | |
121 Console.WriteLine("Found device '{0}'", d.FriendlyName); | |
122 return d; | |
123 } | |
124 } | |
125 Console.WriteLine("Device not found"); | |
126 if (numAttempts % 5 == 0) | |
127 ResetMachine(rootPool, machineName, true); | |
128 else | |
129 System.Threading.Thread.Sleep(5000); | |
130 numAttempts++; | |
131 } | |
132 Console.WriteLine("Error: device '{0}' not found", deviceRegex); | |
133 return null; | |
134 } | |
135 | |
136 static int Main(string[] args) | 19 static int Main(string[] args) |
137 { | 20 { |
138 if (args.Length < 5) | 21 if (args.Length != 5) |
139 { | 22 { |
140 Console.WriteLine("Error: incorrect number of command line argum
ents"); | 23 Console.WriteLine("Error: incorrect number of command line argum
ents"); |
141 Console.WriteLine("Usage: {0} serverName machinePoolName submiss
ionName timeout machineName0 machineName1 ...", | 24 Console.WriteLine("Usage: {0} serverName clientName machinePoolN
ame submissionName timeout", |
142 System.Environment.GetCommandLineArgs()[0]); | 25 System.Environment.GetCommandLineArgs()[0]); |
143 return 1; | 26 return 1; |
144 } | 27 } |
145 string serverName = args[0]; | 28 string serverName = args[0]; |
146 string machinePoolName = args[1]; | 29 string clientName = args[1]; |
147 string submissionName = args[2]; | 30 string machinePoolName = args[2]; |
148 double timeout = Convert.ToDouble(args[3]); | 31 string submissionName = args[3]; |
149 | 32 double timeout = Convert.ToDouble(args[4]); |
150 List<string> machines = new List<string>(); | |
151 for (int i = 4; i < args.Length; i++) | |
152 machines.Add(args[i]); | |
153 | 33 |
154 try | 34 try |
155 { | 35 { |
156 // Initialize DeviceScript and connect to data store | 36 // Initialize DeviceScript and connect to data store |
157 Console.WriteLine("Initializing DeviceScript object"); | 37 Console.WriteLine("Initializing DeviceScript object"); |
158 DeviceScript script = new DeviceScript(); | 38 DeviceScript script = new DeviceScript(); |
159 Console.WriteLine("Connecting to data store"); | 39 Console.WriteLine("Connecting to data store"); |
| 40 |
160 script.ConnectToNamedDataStore(serverName); | 41 script.ConnectToNamedDataStore(serverName); |
161 | 42 |
162 // Wait for client machines to become available | 43 // Find client machine |
163 IResourcePool rootPool = script.GetResourcePoolByName("$"); | 44 IResourcePool rootPool = script.GetResourcePoolByName("$"); |
164 foreach (string machineName in machines) | 45 Console.WriteLine("Looking for client machine '{0}'", clientName
); |
165 FindMachine(rootPool, machineName); | 46 IResource machine = null; |
| 47 while (true) |
| 48 { |
| 49 try |
| 50 { |
| 51 machine = rootPool.GetResourceByName(clientName); |
| 52 } |
| 53 catch (Exception e) |
| 54 { |
| 55 Console.WriteLine("Warning: " + e.Message); |
| 56 } |
| 57 // Make sure the machine is valid |
| 58 if (machine != null && |
| 59 machine.OperatingSystem != null && |
| 60 machine.OperatingSystem.Length > 0 && |
| 61 machine.ProcessorArchitecture != null && |
| 62 machine.ProcessorArchitecture.Length > 0 && |
| 63 machine.GetDevices().Length > 0) |
| 64 break; |
| 65 System.Threading.Thread.Sleep(1000); |
| 66 } |
| 67 Console.WriteLine("Client machine '{0}' found ({1}, {2})", |
| 68 clientName, machine.OperatingSystem, machine.ProcessorArchit
ecture); |
166 | 69 |
167 // Delete the machine pool if it already exists | 70 // Create machine pool and add client machine to it |
168 DeleteResourcePool(script, machinePoolName); | |
169 | |
170 // Create the machine pool and add the client machines to it | |
171 // (this must be done because jobs cannot be scheduled for machi
nes in the | 71 // (this must be done because jobs cannot be scheduled for machi
nes in the |
172 // default pool) | 72 // default pool) |
173 try | 73 try |
174 { | 74 { |
175 script.CreateResourcePool(machinePoolName, rootPool.Resource
PoolId); | 75 script.CreateResourcePool(machinePoolName, rootPool.Resource
PoolId); |
176 } | 76 } |
177 catch (Exception e) | 77 catch (Exception e) |
178 { | 78 { |
179 Console.WriteLine("Warning: " + e.Message); | 79 Console.WriteLine("Warning: " + e.Message); |
180 } | 80 } |
181 IResourcePool newPool = script.GetResourcePoolByName(machinePool
Name); | 81 IResourcePool newPool = script.GetResourcePoolByName(machinePool
Name); |
182 foreach (string machineName in machines) | 82 Console.WriteLine("Moving the client machine to pool '{0}'", mac
hinePoolName); |
183 { | 83 machine.ChangeResourcePool(newPool); |
184 Console.WriteLine("Moving machine '{0}' to pool '{1}'", mach
ineName, machinePoolName); | |
185 rootPool.GetResourceByName(machineName).ChangeResourcePool(n
ewPool); | |
186 } | |
187 | 84 |
188 // Reset client machine | 85 // Reset client machine |
189 foreach (string machineName in machines) | 86 if (machine.Status != "Ready") |
190 ResetMachine(rootPool, machineName, true); | 87 { |
| 88 Console.WriteLine("Changing the client machine's status to '
Reset'"); |
| 89 while (true) |
| 90 { |
| 91 try |
| 92 { |
| 93 machine = rootPool.GetResourceByName(clientName); |
| 94 machine.ChangeResourceStatus("Unsafe"); |
| 95 System.Threading.Thread.Sleep(5000); |
| 96 machine.ChangeResourceStatus("Reset"); |
| 97 break; |
| 98 } |
| 99 catch (Exception e) |
| 100 { |
| 101 Console.WriteLine("Warning: " + e.Message); |
| 102 } |
| 103 System.Threading.Thread.Sleep(5000); |
| 104 } |
| 105 Console.WriteLine("Waiting for client machine to be ready"); |
| 106 while (machine.Status != "Ready") |
| 107 { |
| 108 try |
| 109 { |
| 110 machine = rootPool.GetResourceByName(clientName); |
| 111 } |
| 112 catch (Exception e) |
| 113 { |
| 114 Console.WriteLine("Warning: " + e.Message); |
| 115 } |
| 116 System.Threading.Thread.Sleep(1000); |
| 117 } |
| 118 } |
| 119 Console.WriteLine("Client machine is ready"); |
191 | 120 |
192 // Get requested device regex and look for a matching device in
the first machine | 121 // Get requested device regex and look for a matching device |
193 Console.WriteLine("Device to test:"); | 122 Console.WriteLine("Device to test: "); |
194 IDevice device = GetDevice(rootPool, machines[0], Console.ReadLi
ne()); | 123 Regex deviceRegex = new Regex(Console.ReadLine(), RegexOptions.I
gnoreCase); |
195 if (device == null) | 124 Console.WriteLine("Looking for device '{0}'", deviceRegex); |
196 return 1; | 125 IDevice device; |
| 126 DateTime endTime = DateTime.Now.AddSeconds(120); |
| 127 while (DateTime.Now < endTime) |
| 128 { |
| 129 machine = rootPool.GetResourceByName(clientName); |
| 130 Console.WriteLine("(Client machine has {0} devices)", machin
e.GetDevices().Length); |
| 131 foreach (IDevice d in machine.GetDevices()) |
| 132 { |
| 133 if (deviceRegex.IsMatch(d.FriendlyName)) |
| 134 { |
| 135 device = d; |
| 136 goto deviceFound; |
| 137 } |
| 138 } |
| 139 System.Threading.Thread.Sleep(5000); |
| 140 } |
| 141 Console.WriteLine("Error: device '{0}' not found", deviceRegex); |
| 142 return 1; |
| 143 |
| 144 deviceFound: |
| 145 Console.WriteLine("Found device '{0}'", device.FriendlyName); |
197 | 146 |
198 // Get requested jobs regex | 147 // Get requested jobs regex |
199 Console.WriteLine("Jobs to run:"); | 148 Console.WriteLine("Jobs to run: "); |
200 Regex jobRegex = new Regex(Console.ReadLine(), RegexOptions.Igno
reCase); | 149 Regex jobRegex = new Regex(Console.ReadLine(), RegexOptions.Igno
reCase); |
201 | 150 |
202 // Create a submission | 151 // Create submission |
203 Object[] existingSubmissions = script.GetSubmissionByName(submis
sionName); | 152 Object[] existingSubmissions = script.GetSubmissionByName(submis
sionName); |
204 if (existingSubmissions.Length > 0) | 153 if (existingSubmissions.Length > 0) |
205 { | 154 { |
206 Console.WriteLine("Submission '{0}' already exists -- removi
ng it", | 155 Console.WriteLine("Submission '{0}' already exists -- removi
ng it", |
207 submissionName); | 156 submissionName); |
208 script.DeleteSubmission(((ISubmission)existingSubmissions[0]
).Id); | 157 script.DeleteSubmission(((ISubmission)existingSubmissions[0]
).Id); |
209 } | 158 } |
210 string hardwareId = device.InstanceId.Remove(device.InstanceId.L
astIndexOf("\\")); | 159 Console.WriteLine("Creating submission '{0}'", submissionName); |
211 Console.WriteLine("Creating submission '{0}' (hardware ID: {1})"
, submissionName, hardwareId); | 160 ISubmission submission = script.CreateHardwareSubmission(submiss
ionName, |
212 ISubmission submission = script.CreateHardwareSubmission(submiss
ionName, newPool.ResourcePoolId, hardwareId); | 161 newPool.ResourcePoolId, device.InstanceId); |
213 | 162 |
214 // Set submission DeviceData | 163 // Get DeviceData objects from the user |
215 List<Object> deviceDataList = new List<Object>(); | 164 List<Object> deviceDataList = new List<Object>(); |
216 while (true) | 165 while (true) |
217 { | 166 { |
218 ISubmissionDeviceData dd = script.CreateNewSubmissionDeviceD
ata(); | 167 ISubmissionDeviceData dd = script.CreateNewSubmissionDeviceD
ata(); |
219 Console.WriteLine("DeviceData name:"); | 168 Console.WriteLine("DeviceData name: "); |
220 dd.Name = Console.ReadLine(); | 169 dd.Name = Console.ReadLine(); |
221 if (dd.Name.Length == 0) | 170 if (dd.Name.Length == 0) |
222 break; | 171 break; |
223 Console.WriteLine("DeviceData data:"); | 172 Console.WriteLine("DeviceData data: "); |
224 dd.Data = Console.ReadLine(); | 173 dd.Data = Console.ReadLine(); |
225 deviceDataList.Add(dd); | 174 deviceDataList.Add(dd); |
226 } | 175 } |
| 176 |
| 177 // Set the submission's DeviceData |
227 submission.SetDeviceData(deviceDataList.ToArray()); | 178 submission.SetDeviceData(deviceDataList.ToArray()); |
228 | 179 |
229 // Set submission descriptors | 180 // Get descriptors from the user |
230 List<Object> descriptorList = new List<Object>(); | 181 List<Object> descriptorList = new List<Object>(); |
231 while (true) | 182 while (true) |
232 { | 183 { |
233 Console.WriteLine("Descriptor path:"); | 184 Console.WriteLine("Descriptor path: "); |
234 string descriptorPath = Console.ReadLine(); | 185 string descriptorPath = Console.ReadLine(); |
235 if (descriptorPath.Length == 0) | 186 if (descriptorPath.Length == 0) |
236 break; | 187 break; |
237 descriptorList.Add(script.GetDescriptorByPath(descriptorPath
)); | 188 descriptorList.Add(script.GetDescriptorByPath(descriptorPath
)); |
238 } | 189 } |
| 190 |
| 191 // Set the submission's descriptors |
239 submission.SetLogoDescriptors(descriptorList.ToArray()); | 192 submission.SetLogoDescriptors(descriptorList.ToArray()); |
240 | 193 |
241 // Set machine dimensions | 194 // Create a schedule |
242 foreach (string machineName in machines) | 195 ISchedule schedule = script.CreateNewSchedule(); |
243 { | |
244 IResource machine = rootPool.GetResourceByName(machineName); | |
245 while (true) | |
246 { | |
247 Console.WriteLine("Dimension name ({0}):", machineName); | |
248 string dimName = Console.ReadLine(); | |
249 if (dimName.Length == 0) | |
250 break; | |
251 Console.WriteLine("Dimension value ({0}):", machineName)
; | |
252 machine.SetDimension(dimName, Console.ReadLine()); | |
253 } | |
254 // Set the WDKSubmissionId dimension for all machines | |
255 machine.SetDimension("WDKSubmissionId", submission.Id.ToStri
ng() + "_" + submission.Name); | |
256 } | |
257 | |
258 // Get job parameters | |
259 List<string> paramNames = new List<string>(); | |
260 List<string> paramValues = new List<string>(); | |
261 foreach (string machineName in machines) | |
262 { | |
263 while (true) | |
264 { | |
265 Console.WriteLine("Parameter name ({0}):", machineName); | |
266 string paramName = Console.ReadLine(); | |
267 if (paramName.Length == 0) | |
268 break; | |
269 Console.WriteLine("Device regex ({0}):", machineName); | |
270 IDevice d = GetDevice(rootPool, machineName, Console.Rea
dLine()); | |
271 if (d == null) | |
272 return 1; | |
273 string deviceName = d.GetAttribute("name")[0].ToString()
; | |
274 Console.WriteLine("Setting parameter value to '{0}'", de
viceName); | |
275 paramNames.Add(paramName); | |
276 paramValues.Add(deviceName); | |
277 } | |
278 } | |
279 | |
280 // Find jobs that match the requested pattern | |
281 Console.WriteLine("Scheduling jobs:"); | 196 Console.WriteLine("Scheduling jobs:"); |
282 List<IJob> jobs = new List<IJob>(); | 197 int jobCount = 0; |
283 foreach (IJob j in submission.GetJobs()) | 198 foreach (IJob j in submission.GetJobs()) |
284 { | 199 { |
285 if (jobRegex.IsMatch(j.Name)) | 200 if (jobRegex.IsMatch(j.Name)) |
286 { | 201 { |
287 Console.WriteLine(" " + j.Name); | 202 Console.WriteLine(" " + j.Name); |
288 // Set job parameters | 203 schedule.AddDeviceJob(device, j); |
289 for (int i = 0; i < paramNames.Count; i++) | 204 jobCount++; |
290 { | |
291 IParameter p = j.GetParameterByName(paramNames[i]); | |
292 if (p != null) | |
293 p.ScheduleValue = paramValues[i]; | |
294 } | |
295 jobs.Add(j); | |
296 } | 205 } |
297 } | 206 } |
298 if (jobs.Count == 0) | 207 if (jobCount == 0) |
299 { | 208 { |
300 Console.WriteLine("Error: no submission jobs match pattern '
{0}'", jobRegex); | 209 Console.WriteLine("Error: no submission jobs match pattern '
{0}'", jobRegex); |
301 return 1; | 210 return 1; |
302 } | 211 } |
303 | |
304 // Create a schedule, add jobs to it and run it | |
305 ISchedule schedule = script.CreateNewSchedule(); | |
306 foreach (IScheduleItem item in submission.ProcessJobs(jobs.ToArr
ay())) | |
307 { | |
308 item.Device = device; | |
309 schedule.AddScheduleItem(item); | |
310 } | |
311 schedule.AddSubmission(submission); | 212 schedule.AddSubmission(submission); |
312 schedule.SetResourcePool(newPool); | 213 schedule.SetResourcePool(newPool); |
313 script.RunSchedule(schedule); | 214 script.RunSchedule(schedule); |
314 | 215 |
315 // Wait for jobs to complete | 216 // Wait for jobs to complete |
316 Console.WriteLine("Waiting for all jobs to complete (timeout={0}
s)", timeout); | 217 Console.WriteLine("Waiting for all jobs to complete (timeout={0}
)", timeout); |
317 DateTime endTime = DateTime.Now.AddSeconds(timeout); | 218 endTime = DateTime.Now.AddSeconds(timeout); |
318 int numCompleted, numFailed; | 219 int numCompleted = 0, numFailed = 0; |
319 do | 220 while (numCompleted < submission.GetResults().Length && DateTime
.Now < endTime) |
320 { | 221 { |
| 222 // Sleep for 30 seconds |
321 System.Threading.Thread.Sleep(30000); | 223 System.Threading.Thread.Sleep(30000); |
322 // Report results in a Python readable format and count comp
leted and failed schedule jobs | 224 // Count completed submission jobs |
323 numCompleted = numFailed = 0; | 225 numCompleted = 0; |
| 226 foreach (IResult r in submission.GetResults()) |
| 227 if (r.ResultStatus != "InProgress") |
| 228 numCompleted++; |
| 229 // Report results in a Python readable format and count fail
ed schedule jobs |
| 230 // (submission jobs are a subset of schedule jobs) |
324 Console.WriteLine(); | 231 Console.WriteLine(); |
325 Console.WriteLine("---- ["); | 232 Console.WriteLine("---- ["); |
| 233 numFailed = 0; |
326 foreach (IResult r in schedule.GetResults()) | 234 foreach (IResult r in schedule.GetResults()) |
327 { | 235 { |
328 if (r.ResultStatus != "InProgress") numCompleted++; | |
329 if (r.ResultStatus == "Investigate") numFailed++; | |
330 Console.WriteLine(" {"); | 236 Console.WriteLine(" {"); |
331 Console.WriteLine(" 'id': {0}, 'job': r'''{1}''',", r
.Job.Id, r.Job.Name); | 237 Console.WriteLine(" 'id': {0}, 'job': r'''{1}''',", r
.Job.Id, r.Job.Name); |
332 Console.WriteLine(" 'logs': r'''{0}''',", r.LogLocati
on); | 238 Console.WriteLine(" 'logs': r'''{0}''',", r.LogLocati
on); |
333 if (r.ResultStatus != "InProgress") | 239 if (r.ResultStatus != "InProgress") |
334 Console.WriteLine(" 'report': r'''{0}''',", | 240 Console.WriteLine(" 'report': r'''{0}''',", |
335 submission.GetSubmissionResultReport(r)); | 241 submission.GetSubmissionResultReport(r)); |
336 Console.WriteLine(" 'status': '{0}',", r.ResultStatus
); | 242 Console.WriteLine(" 'status': '{0}',", r.ResultStatus
); |
337 Console.WriteLine(" 'pass': {0}, 'fail': {1}, 'notrun
': {2}, 'notapplicable': {3}", | 243 Console.WriteLine(" 'pass': {0}, 'fail': {1}, 'notrun
': {2}, 'notapplicable': {3}", |
338 r.Pass, r.Fail, r.NotRun, r.NotApplicable); | 244 r.Pass, r.Fail, r.NotRun, r.NotApplicable); |
339 Console.WriteLine(" },"); | 245 Console.WriteLine(" },"); |
| 246 numFailed += r.Fail; |
340 } | 247 } |
341 Console.WriteLine("] ----"); | 248 Console.WriteLine("] ----"); |
342 } while (numCompleted < schedule.GetResults().Length && DateTime
.Now < endTime); | 249 } |
343 | |
344 Console.WriteLine(); | 250 Console.WriteLine(); |
345 | 251 |
346 // Cancel incomplete jobs | 252 // Cancel incomplete jobs |
347 foreach (IResult r in schedule.GetResults()) | 253 foreach (IResult r in schedule.GetResults()) |
348 if (r.ResultStatus == "InProgress") | 254 if (r.ResultStatus == "InProgress") |
349 r.Cancel(); | 255 r.Cancel(); |
350 | 256 |
351 // Reset the machines | 257 // Set the machine's status to Unsafe and then Reset |
352 foreach (string machineName in machines) | 258 try |
353 ResetMachine(rootPool, machineName, false); | 259 { |
| 260 machine = rootPool.GetResourceByName(clientName); |
| 261 machine.ChangeResourceStatus("Unsafe"); |
| 262 System.Threading.Thread.Sleep(5000); |
| 263 machine.ChangeResourceStatus("Reset"); |
| 264 } |
| 265 catch (Exception e) |
| 266 { |
| 267 Console.WriteLine("Warning: " + e.Message); |
| 268 } |
354 | 269 |
355 // Report failures | 270 // Report failures |
356 if (numCompleted < schedule.GetResults().Length) | 271 if (numCompleted < submission.GetResults().Length) |
357 Console.WriteLine("Some jobs did not complete on time."); | 272 Console.WriteLine("Some jobs did not complete on time."); |
358 if (numFailed > 0) | 273 if (numFailed > 0) |
359 Console.WriteLine("Some jobs failed."); | 274 Console.WriteLine("Some jobs failed."); |
360 if (numFailed > 0 || numCompleted < schedule.GetResults().Length
) | 275 |
| 276 if (numFailed > 0 || numCompleted < submission.GetResults().Leng
th) |
361 return 1; | 277 return 1; |
362 | 278 |
363 Console.WriteLine("All jobs completed."); | 279 Console.WriteLine("All jobs completed."); |
364 return 0; | 280 return 0; |
365 } | 281 } |
366 catch (Exception e) | 282 catch (Exception e) |
367 { | 283 { |
368 Console.WriteLine("Error: " + e.Message); | 284 Console.WriteLine("Error: " + e.Message); |
369 return 1; | 285 return 1; |
370 } | 286 } |
371 } | 287 } |
372 } | 288 } |
373 } | 289 } |
OLD | NEW |