Merge lp:~le-chi-thu/lava-dispatcher/improve-logging-2 into lp:lava-dispatcher
- improve-logging-2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Zygmunt Krynicki |
Approved revision: | 207 |
Merged at revision: | 221 |
Proposed branch: | lp:~le-chi-thu/lava-dispatcher/improve-logging-2 |
Merge into: | lp:lava-dispatcher |
Diff against target: |
316 lines (+58/-17) 7 files modified
lava_dispatcher/actions/boot_control.py (+0/-2) lava_dispatcher/actions/launch_control.py (+4/-3) lava_dispatcher/client/base.py (+4/-1) lava_dispatcher/client/master.py (+13/-5) lava_dispatcher/connection.py (+1/-1) lava_dispatcher/job.py (+32/-1) lava_dispatcher/utils.py (+4/-4) |
To merge this branch: | bzr merge lp:~le-chi-thu/lava-dispatcher/improve-logging-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Le Chi Thu (community) | Needs Resubmitting | ||
Yongqin Liu | Approve | ||
Review via email: mp+90253@code.launchpad.net |
Commit message
Description of the change
make it easier to follow the flow and outcome of actions
Zygmunt Krynicki (zyga) wrote : | # |
Hi ChiThu
59 - rc = session.
60 + rc = session.
I understand this is not related to logging
294 + def _set_logging_
295 + # set logging level is optional
296 + try:
297 + logging.
298 + except :
299 + pass
I understand the intent was to ignore missing entries in the job file (and in that case accessing self.logging_level would raise KeyError). I think this is somewhat confusing and I'd suggest wrapping that inside the def logging_level(self) property method. To users of this class this should be a normal property, not something that may raise an unexpected KeyError. In addition, I think we should validate the values of logging level that are passed. Instead of using raw integers that few users will understand (is 0 more verbose than 100?) I would just use the standard set of logging.XXX names {DEBUG, INFO, WARNING, ERROR, CRITICAL}.
I can show you how to make code like that elegant and how to validate the input quickly.
Le Chi Thu (le-chi-thu) wrote : | # |
wait merging util I have updated according to the discussion below.
<zyga> ChiThu: so for that isuse: I was suggesting to use foo.set_
<zyga> ChiThu: you can convert a string to an integer (for logging) using...
<zyga> ChiThu: try logging.
<zyga> ChiThu: then I was hoping that we actually validate the dispatcher job file
<zyga> ChiThu: a simple schema could check if the log level is in the valid set ("INFO", "DEBUG", etc)
<zyga> ChiThu: for doing that I could point you to json-schema-
<zyga> ChiThu: and to json-document documentation (for better tutorial-like approach)
* antipov (~antipov@
<plars> zyga, ChiThu: Adding a schema for the dispatcher would also go a long way toward documenting the dispatcher
<ChiThu> zyga, yes, good idea about schema for dispatcher
Paul Larson (pwlars) wrote : | # |
I don't think adding a schema and validator should be part of this merge, though I do thing we should do it. I'll add a blueprint for it as I think it would improve reliability and documentation in the dispatcher. Is that something you'd like to work on ChiThu?
Le Chi Thu (le-chi-thu) wrote : | # |
I can update the log_level to string and let the let schema and validator feature be in an other patch.
Paul Larson (pwlars) wrote : | # |
You may want to take a look at logging.
Le Chi Thu (le-chi-thu) wrote : | # |
Updated according to the comments.
* Use string as logging level.
* Removed not logging related changes
* Sync with trunk
Zygmunt Krynicki (zyga) wrote : | # |
ChiThu: resubmit == submit another proposal I think
Preview Diff
1 | === modified file 'lava_dispatcher/actions/boot_control.py' | |||
2 | --- lava_dispatcher/actions/boot_control.py 2011-11-24 03:00:54 +0000 | |||
3 | +++ lava_dispatcher/actions/boot_control.py 2012-02-07 19:21:18 +0000 | |||
4 | @@ -43,7 +43,6 @@ | |||
5 | 43 | client = self.client | 43 | client = self.client |
6 | 44 | status = 'pass' | 44 | status = 'pass' |
7 | 45 | try: | 45 | try: |
8 | 46 | logging.info("Boot Linaro image") | ||
9 | 47 | client.boot_linaro_image() | 46 | client.boot_linaro_image() |
10 | 48 | except: | 47 | except: |
11 | 49 | logging.exception("boot_linaro_image failed") | 48 | logging.exception("boot_linaro_image failed") |
12 | @@ -58,5 +57,4 @@ | |||
13 | 58 | """ | 57 | """ |
14 | 59 | def run(self): | 58 | def run(self): |
15 | 60 | client = self.client | 59 | client = self.client |
16 | 61 | logging.info("Boot master image") | ||
17 | 62 | client.boot_master_image() | 60 | client.boot_master_image() |
18 | 63 | 61 | ||
19 | === modified file 'lava_dispatcher/actions/launch_control.py' | |||
20 | --- lava_dispatcher/actions/launch_control.py 2012-02-02 01:56:11 +0000 | |||
21 | +++ lava_dispatcher/actions/launch_control.py 2012-02-07 19:21:18 +0000 | |||
22 | @@ -62,8 +62,9 @@ | |||
23 | 62 | json_bundle = json.dumps(main_bundle) | 62 | json_bundle = json.dumps(main_bundle) |
24 | 63 | job_name = self.context.job_data.get('job_name', "LAVA Results") | 63 | job_name = self.context.job_data.get('job_name', "LAVA Results") |
25 | 64 | try: | 64 | try: |
28 | 65 | print >> self.context.oob_file, 'dashboard-put-result:', \ | 65 | result = dashboard.put_ex(json_bundle, job_name, stream) |
29 | 66 | dashboard.put_ex(json_bundle, job_name, stream) | 66 | print >> self.context.oob_file, 'dashboard-put-result:', result |
30 | 67 | logging.info("Dashboard : %s" %result) | ||
31 | 67 | except xmlrpclib.Fault, err: | 68 | except xmlrpclib.Fault, err: |
32 | 68 | logging.warning("xmlrpclib.Fault occurred") | 69 | logging.warning("xmlrpclib.Fault occurred") |
33 | 69 | logging.warning("Fault code: %d" % err.faultCode) | 70 | logging.warning("Fault code: %d" % err.faultCode) |
34 | @@ -176,6 +177,6 @@ | |||
35 | 176 | logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!") | 177 | logging.warn("The url seems not RPC2 or xml-rpc endpoints, please make sure it's a valid one!!!") |
36 | 177 | dashboard = srv.dashboard | 178 | dashboard = srv.dashboard |
37 | 178 | 179 | ||
39 | 179 | logging.info("server RPC endpoint URL: %s" % server) | 180 | logging.debug("server RPC endpoint URL: %s" % server) |
40 | 180 | return dashboard | 181 | return dashboard |
41 | 181 | 182 | ||
42 | 182 | 183 | ||
43 | === modified file 'lava_dispatcher/client/base.py' | |||
44 | --- lava_dispatcher/client/base.py 2012-02-07 18:42:14 +0000 | |||
45 | +++ lava_dispatcher/client/base.py 2012-02-07 19:21:18 +0000 | |||
46 | @@ -374,7 +374,6 @@ | |||
47 | 374 | timeout=timeout) | 374 | timeout=timeout) |
48 | 375 | if match_id == 1: | 375 | if match_id == 1: |
49 | 376 | raise OperationFailed | 376 | raise OperationFailed |
50 | 377 | logging.info("System is in test image now") | ||
51 | 378 | 377 | ||
52 | 379 | def deploy_linaro(self, hwpack, rootfs, kernel_matrix=None, use_cache=True, rootfstype='ext3'): | 378 | def deploy_linaro(self, hwpack, rootfs, kernel_matrix=None, use_cache=True, rootfstype='ext3'): |
53 | 380 | raise NotImplementedError(self.deploy_linaro) | 379 | raise NotImplementedError(self.deploy_linaro) |
54 | @@ -386,6 +385,8 @@ | |||
55 | 386 | """ | 385 | """ |
56 | 387 | Reboot the system to the test image | 386 | Reboot the system to the test image |
57 | 388 | """ | 387 | """ |
58 | 388 | logging.info("Boot the test image") | ||
59 | 389 | |||
60 | 389 | self.proc._boot(self.boot_cmds) | 390 | self.proc._boot(self.boot_cmds) |
61 | 390 | self.in_test_shell(300) | 391 | self.in_test_shell(300) |
62 | 391 | # set PS1 to include return value of last command | 392 | # set PS1 to include return value of last command |
63 | @@ -395,6 +396,8 @@ | |||
64 | 395 | self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "') | 396 | self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "') |
65 | 396 | self.proc.expect(self.tester_str, timeout=10) | 397 | self.proc.expect(self.tester_str, timeout=10) |
66 | 397 | 398 | ||
67 | 399 | logging.info("System is in test image now") | ||
68 | 400 | |||
69 | 398 | def get_seriallog(self): | 401 | def get_seriallog(self): |
70 | 399 | return self.sio.getvalue() | 402 | return self.sio.getvalue() |
71 | 400 | 403 | ||
72 | 401 | 404 | ||
73 | === modified file 'lava_dispatcher/client/master.py' | |||
74 | --- lava_dispatcher/client/master.py 2012-01-27 03:23:09 +0000 | |||
75 | +++ lava_dispatcher/client/master.py 2012-02-07 19:21:18 +0000 | |||
76 | @@ -121,7 +121,7 @@ | |||
77 | 121 | session.run('umount /mnt/lava/boot') | 121 | session.run('umount /mnt/lava/boot') |
78 | 122 | 122 | ||
79 | 123 | def _recreate_uInitrd(session): | 123 | def _recreate_uInitrd(session): |
81 | 124 | logging.info("Recreate uInitrd") | 124 | logging.debug("Recreate uInitrd") |
82 | 125 | # Original android sdcard partition layout by l-a-m-c | 125 | # Original android sdcard partition layout by l-a-m-c |
83 | 126 | sys_part_org = session._client.device_option("sys_part_android_org") | 126 | sys_part_org = session._client.device_option("sys_part_android_org") |
84 | 127 | cache_part_org = session._client.device_option("cache_part_android_org") | 127 | cache_part_org = session._client.device_option("cache_part_android_org") |
85 | @@ -245,9 +245,8 @@ | |||
86 | 245 | self.run( | 245 | self.run( |
87 | 246 | cmd, [pattern1, pexpect.EOF, pexpect.TIMEOUT], timeout=5) | 246 | cmd, [pattern1, pexpect.EOF, pexpect.TIMEOUT], timeout=5) |
88 | 247 | if self.match_id == 0: | 247 | if self.match_id == 0: |
89 | 248 | logging.info("\nmatching pattern is %s" % self.match_id) | ||
90 | 249 | ip = self.match.group(1) | 248 | ip = self.match.group(1) |
92 | 250 | logging.info("Master IP is %s" % ip) | 249 | logging.debug("Master image IP is %s" % ip) |
93 | 251 | return ip | 250 | return ip |
94 | 252 | return None | 251 | return None |
95 | 253 | 252 | ||
96 | @@ -269,9 +268,11 @@ | |||
97 | 269 | boot_tgz, root_tgz = self._generate_tarballs( | 268 | boot_tgz, root_tgz = self._generate_tarballs( |
98 | 270 | hwpack, rootfs, kernel_matrix, use_cache) | 269 | hwpack, rootfs, kernel_matrix, use_cache) |
99 | 271 | except: | 270 | except: |
100 | 271 | logging.error("Deployment tarballs preparation failed") | ||
101 | 272 | tb = traceback.format_exc() | 272 | tb = traceback.format_exc() |
102 | 273 | self.sio.write(tb) | 273 | self.sio.write(tb) |
103 | 274 | raise CriticalError("Deployment tarballs preparation failed") | 274 | raise CriticalError("Deployment tarballs preparation failed") |
104 | 275 | |||
105 | 275 | logging.info("Booting master image") | 276 | logging.info("Booting master image") |
106 | 276 | try: | 277 | try: |
107 | 277 | self.boot_master_image() | 278 | self.boot_master_image() |
108 | @@ -288,6 +289,7 @@ | |||
109 | 288 | try: | 289 | try: |
110 | 289 | session.wait_network_up() | 290 | session.wait_network_up() |
111 | 290 | except: | 291 | except: |
112 | 292 | logging.error("Unable to reach LAVA server, check network") | ||
113 | 291 | tb = traceback.format_exc() | 293 | tb = traceback.format_exc() |
114 | 292 | self.sio.write(tb) | 294 | self.sio.write(tb) |
115 | 293 | raise CriticalError("Unable to reach LAVA server, check network") | 295 | raise CriticalError("Unable to reach LAVA server, check network") |
116 | @@ -296,6 +298,7 @@ | |||
117 | 296 | _deploy_linaro_rootfs(session, root_url) | 298 | _deploy_linaro_rootfs(session, root_url) |
118 | 297 | _deploy_linaro_bootfs(session, boot_url) | 299 | _deploy_linaro_bootfs(session, boot_url) |
119 | 298 | except: | 300 | except: |
120 | 301 | logging.error("Deployment failed") | ||
121 | 299 | tb = traceback.format_exc() | 302 | tb = traceback.format_exc() |
122 | 300 | self.sio.write(tb) | 303 | self.sio.write(tb) |
123 | 301 | raise CriticalError("Deployment failed") | 304 | raise CriticalError("Deployment failed") |
124 | @@ -317,6 +320,7 @@ | |||
125 | 317 | try: | 320 | try: |
126 | 318 | session.wait_network_up() | 321 | session.wait_network_up() |
127 | 319 | except: | 322 | except: |
128 | 323 | logging.error("Unable to reach LAVA server, check network") | ||
129 | 320 | tb = traceback.format_exc() | 324 | tb = traceback.format_exc() |
130 | 321 | self.sio.write(tb) | 325 | self.sio.write(tb) |
131 | 322 | raise CriticalError("Unable to reach LAVA server, check network") | 326 | raise CriticalError("Unable to reach LAVA server, check network") |
132 | @@ -325,6 +329,7 @@ | |||
133 | 325 | boot_tbz2, system_tbz2, data_tbz2, pkg_tbz2 = \ | 329 | boot_tbz2, system_tbz2, data_tbz2, pkg_tbz2 = \ |
134 | 326 | self._download_tarballs(boot, system, data, pkg, use_cache) | 330 | self._download_tarballs(boot, system, data, pkg, use_cache) |
135 | 327 | except: | 331 | except: |
136 | 332 | logging.error("Unable to download artifacts for deployment") | ||
137 | 328 | tb = traceback.format_exc() | 333 | tb = traceback.format_exc() |
138 | 329 | self.sio.write(tb) | 334 | self.sio.write(tb) |
139 | 330 | raise CriticalError("Unable to download artifacts for deployment") | 335 | raise CriticalError("Unable to download artifacts for deployment") |
140 | @@ -353,6 +358,7 @@ | |||
141 | 353 | # _purge_linaro_android_sdcard(session) | 358 | # _purge_linaro_android_sdcard(session) |
142 | 354 | _deploy_linaro_android_data(session, data_url) | 359 | _deploy_linaro_android_data(session, data_url) |
143 | 355 | except: | 360 | except: |
144 | 361 | logging.error("Android deployment failed") | ||
145 | 356 | tb = traceback.format_exc() | 362 | tb = traceback.format_exc() |
146 | 357 | self.sio.write(tb) | 363 | self.sio.write(tb) |
147 | 358 | raise CriticalError("Android deployment failed") | 364 | raise CriticalError("Android deployment failed") |
148 | @@ -400,6 +406,7 @@ | |||
149 | 400 | """ | 406 | """ |
150 | 401 | reboot the system, and check that we are in a master shell | 407 | reboot the system, and check that we are in a master shell |
151 | 402 | """ | 408 | """ |
152 | 409 | logging.info("Boot the system master image") | ||
153 | 403 | self.proc.soft_reboot() | 410 | self.proc.soft_reboot() |
154 | 404 | try: | 411 | try: |
155 | 405 | self.proc.expect("Starting kernel") | 412 | self.proc.expect("Starting kernel") |
156 | @@ -410,6 +417,7 @@ | |||
157 | 410 | self._in_master_shell(300) | 417 | self._in_master_shell(300) |
158 | 411 | self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "') | 418 | self.proc.sendline('export PS1="$PS1 [rc=$(echo \$?)]: "') |
159 | 412 | self.proc.expect(self.master_str, timeout=10, lava_no_logging=1) | 419 | self.proc.expect(self.master_str, timeout=10, lava_no_logging=1) |
160 | 420 | logging.info("System is in master image now") | ||
161 | 413 | 421 | ||
162 | 414 | def _format_testpartition(self, session, fstype): | 422 | def _format_testpartition(self, session, fstype): |
163 | 415 | logging.info("Format testboot and testrootfs partitions") | 423 | logging.info("Format testboot and testrootfs partitions") |
164 | @@ -434,6 +442,7 @@ | |||
165 | 434 | _extract_partition(image_file, self.boot_part, boot_tgz) | 442 | _extract_partition(image_file, self.boot_part, boot_tgz) |
166 | 435 | _extract_partition(image_file, self.root_part, root_tgz) | 443 | _extract_partition(image_file, self.root_part, root_tgz) |
167 | 436 | except: | 444 | except: |
168 | 445 | logging.error("Failed to generate tarballs") | ||
169 | 437 | shutil.rmtree(tarball_dir) | 446 | shutil.rmtree(tarball_dir) |
170 | 438 | tb = traceback.format_exc() | 447 | tb = traceback.format_exc() |
171 | 439 | self.sio.write(tb) | 448 | self.sio.write(tb) |
172 | @@ -553,8 +562,7 @@ | |||
173 | 553 | [self.master_str, pexpect.TIMEOUT], timeout=timeout, lava_no_logging=1) | 562 | [self.master_str, pexpect.TIMEOUT], timeout=timeout, lava_no_logging=1) |
174 | 554 | if match_id == 1: | 563 | if match_id == 1: |
175 | 555 | raise OperationFailed | 564 | raise OperationFailed |
178 | 556 | logging.info("System is in master image now") | 565 | |
177 | 557 | |||
179 | 558 | @contextlib.contextmanager | 566 | @contextlib.contextmanager |
180 | 559 | def _master_session(self): | 567 | def _master_session(self): |
181 | 560 | """A session that can be used to run commands in the master image. | 568 | """A session that can be used to run commands in the master image. |
182 | 561 | 569 | ||
183 | === modified file 'lava_dispatcher/connection.py' | |||
184 | --- lava_dispatcher/connection.py 2012-01-12 23:08:03 +0000 | |||
185 | +++ lava_dispatcher/connection.py 2012-02-07 19:21:18 +0000 | |||
186 | @@ -82,13 +82,13 @@ | |||
187 | 82 | self.sendline("") | 82 | self.sendline("") |
188 | 83 | 83 | ||
189 | 84 | def soft_reboot(self): | 84 | def soft_reboot(self): |
190 | 85 | logging.info("Perform soft reboot the system") | ||
191 | 85 | cmd = self.device_option("soft_boot_cmd") | 86 | cmd = self.device_option("soft_boot_cmd") |
192 | 86 | if cmd != "": | 87 | if cmd != "": |
193 | 87 | self.sendline(cmd) | 88 | self.sendline(cmd) |
194 | 88 | else: | 89 | else: |
195 | 89 | self.sendline("reboot") | 90 | self.sendline("reboot") |
196 | 90 | # set soft reboot timeout 120s, or do a hard reset | 91 | # set soft reboot timeout 120s, or do a hard reset |
197 | 91 | logging.info("Rebooting the system") | ||
198 | 92 | id = self.expect( | 92 | id = self.expect( |
199 | 93 | ['Restarting system.', 'The system is going down for reboot NOW', | 93 | ['Restarting system.', 'The system is going down for reboot NOW', |
200 | 94 | 'Will now restart', pexpect.TIMEOUT], timeout=120) | 94 | 'Will now restart', pexpect.TIMEOUT], timeout=120) |
201 | 95 | 95 | ||
202 | === modified file 'lava_dispatcher/job.py' | |||
203 | --- lava_dispatcher/job.py 2012-02-02 11:01:31 +0000 | |||
204 | +++ lava_dispatcher/job.py 2012-02-07 19:21:18 +0000 | |||
205 | @@ -67,6 +67,9 @@ | |||
206 | 67 | 'type': 'integer', | 67 | 'type': 'integer', |
207 | 68 | 'optional': False, | 68 | 'optional': False, |
208 | 69 | }, | 69 | }, |
209 | 70 | 'logging_level': { | ||
210 | 71 | 'optional': True, | ||
211 | 72 | }, | ||
212 | 70 | }, | 73 | }, |
213 | 71 | } | 74 | } |
214 | 72 | 75 | ||
215 | @@ -85,6 +88,13 @@ | |||
216 | 85 | return self.job_data['target'] | 88 | return self.job_data['target'] |
217 | 86 | 89 | ||
218 | 87 | @property | 90 | @property |
219 | 91 | def logging_level(self): | ||
220 | 92 | try: | ||
221 | 93 | return self.job_data['logging_level'] | ||
222 | 94 | except : | ||
223 | 95 | return None | ||
224 | 96 | |||
225 | 97 | @property | ||
226 | 88 | def image_type(self): | 98 | def image_type(self): |
227 | 89 | return self.job_data.get('image_type') | 99 | return self.job_data.get('image_type') |
228 | 90 | 100 | ||
229 | @@ -101,6 +111,7 @@ | |||
230 | 101 | 111 | ||
231 | 102 | def run(self): | 112 | def run(self): |
232 | 103 | self.validate() | 113 | self.validate() |
233 | 114 | self._set_logging_level() | ||
234 | 104 | lava_commands = get_all_cmds() | 115 | lava_commands = get_all_cmds() |
235 | 105 | 116 | ||
236 | 106 | if self.job_data['actions'][-1]['command'].startswith("submit_results"): | 117 | if self.job_data['actions'][-1]['command'].startswith("submit_results"): |
237 | @@ -119,6 +130,7 @@ | |||
238 | 119 | try: | 130 | try: |
239 | 120 | for cmd in self.job_data['actions']: | 131 | for cmd in self.job_data['actions']: |
240 | 121 | params = cmd.get('parameters', {}) | 132 | params = cmd.get('parameters', {}) |
241 | 133 | logging.info("[ACTION-B] Command %s is started with parameters %s." % (cmd['command'],params)) | ||
242 | 122 | metadata = cmd.get('metadata', {}) | 134 | metadata = cmd.get('metadata', {}) |
243 | 123 | self.context.test_data.add_metadata(metadata) | 135 | self.context.test_data.add_metadata(metadata) |
244 | 124 | action = lava_commands[cmd['command']](self.context) | 136 | action = lava_commands[cmd['command']](self.context) |
245 | @@ -135,8 +147,8 @@ | |||
246 | 135 | status = 'pass' | 147 | status = 'pass' |
247 | 136 | finally: | 148 | finally: |
248 | 137 | err_msg = "" | 149 | err_msg = "" |
249 | 138 | logging.info("Action %s finished." % cmd['command']) | ||
250 | 139 | if status == 'fail': | 150 | if status == 'fail': |
251 | 151 | logging.warning("[ACTION-E] %s is finished with error (%s)." %(cmd['command'], err)) | ||
252 | 140 | err_msg = "Lava failed at action %s with error: %s\n" %\ | 152 | err_msg = "Lava failed at action %s with error: %s\n" %\ |
253 | 141 | (cmd['command'], unicode(str(err), 'ascii', 'replace')) | 153 | (cmd['command'], unicode(str(err), 'ascii', 'replace')) |
254 | 142 | if cmd['command'] == 'lava_test_run': | 154 | if cmd['command'] == 'lava_test_run': |
255 | @@ -146,6 +158,7 @@ | |||
256 | 146 | # output to both serial log and logfile | 158 | # output to both serial log and logfile |
257 | 147 | self.context.client.sio.write(err_msg) | 159 | self.context.client.sio.write(err_msg) |
258 | 148 | else: | 160 | else: |
259 | 161 | logging.info("[ACTION-E] %s is finished successfully." %cmd['command']) | ||
260 | 149 | err_msg = "" | 162 | err_msg = "" |
261 | 150 | self.context.test_data.add_result( | 163 | self.context.test_data.add_result( |
262 | 151 | action.test_name(**params), status, err_msg) | 164 | action.test_name(**params), status, err_msg) |
263 | @@ -159,3 +172,21 @@ | |||
264 | 159 | action = lava_commands[submit_results['command']]( | 172 | action = lava_commands[submit_results['command']]( |
265 | 160 | self.context) | 173 | self.context) |
266 | 161 | action.run(**params) | 174 | action.run(**params) |
267 | 175 | |||
268 | 176 | def _set_logging_level(self): | ||
269 | 177 | # set logging level is optional | ||
270 | 178 | level = self.logging_level | ||
271 | 179 | # CRITICAL, ERROR, WARNING, INFO or DEBUG | ||
272 | 180 | if level: | ||
273 | 181 | if level == 'DEBUG': | ||
274 | 182 | logging.root.setLevel(logging.DEBUG) | ||
275 | 183 | elif level == 'INFO': | ||
276 | 184 | logging.root.setLevel(logging.INFO) | ||
277 | 185 | elif level == 'WARNING': | ||
278 | 186 | logging.root.setLevel(logging.WARNING) | ||
279 | 187 | elif level == 'ERROR': | ||
280 | 188 | logging.root.setLevel(logging.ERROR) | ||
281 | 189 | elif level == 'CRITICAL': | ||
282 | 190 | logging.root.setLevel(logging.CRITICAL) | ||
283 | 191 | else: | ||
284 | 192 | logging.warning("Unknown logging level in the job '%s'. Allow level are : CRITICAL, ERROR, WARNING, INFO or DEBUG" %level) | ||
285 | 162 | 193 | ||
286 | === modified file 'lava_dispatcher/utils.py' | |||
287 | --- lava_dispatcher/utils.py 2012-01-26 10:11:27 +0000 | |||
288 | +++ lava_dispatcher/utils.py 2012-02-07 19:21:18 +0000 | |||
289 | @@ -55,9 +55,9 @@ | |||
290 | 55 | if err.errno == errno.EXDEV: | 55 | if err.errno == errno.EXDEV: |
291 | 56 | shutil.copy(cache_loc, file_location) | 56 | shutil.copy(cache_loc, file_location) |
292 | 57 | if err.errno == errno.EEXIST: | 57 | if err.errno == errno.EEXIST: |
294 | 58 | logging.info("Cached copy of %s already exists" % url) | 58 | logging.debug("Cached copy of %s already exists" % url) |
295 | 59 | else: | 59 | else: |
297 | 60 | logging.exception("os.link failed") | 60 | logging.exception("os.link '%s' with '%s' failed"%(cache_loc,file_location)) |
298 | 61 | else: | 61 | else: |
299 | 62 | file_location = download(url, path) | 62 | file_location = download(url, path) |
300 | 63 | try: | 63 | try: |
301 | @@ -70,7 +70,7 @@ | |||
302 | 70 | if err.errno == errno.EXDEV: | 70 | if err.errno == errno.EXDEV: |
303 | 71 | shutil.copy(file_location, cache_loc) | 71 | shutil.copy(file_location, cache_loc) |
304 | 72 | if err.errno == errno.EEXIST: | 72 | if err.errno == errno.EEXIST: |
306 | 73 | logging.info("Cached copy of %s already exists" % url) | 73 | logging.debug("Cached copy of %s already exists" % url) |
307 | 74 | else: | 74 | else: |
308 | 75 | logging.exception("os.link failed") | 75 | logging.exception("os.link failed") |
309 | 76 | return file_location | 76 | return file_location |
310 | @@ -90,6 +90,6 @@ | |||
311 | 90 | return map(strip_newlines, list(splitter)) | 90 | return map(strip_newlines, list(splitter)) |
312 | 91 | 91 | ||
313 | 92 | def logging_system(cmd): | 92 | def logging_system(cmd): |
315 | 93 | logging.info('executing %r'%cmd) | 93 | logging.debug("Executing on host : '%r'"%cmd) |
316 | 94 | return os.system(cmd) | 94 | return os.system(cmd) |
317 | 95 | 95 |
the logging level has been set in lava-dispatcher /lava-dispatch with the default value specified in lava-dispatcher .conf.
is it necessary that we change that to use the value specified in job file, and delete the _set_logging_level method?