Merge lp:~javier.collado/utah/static_analysis_4 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 646
Merged at revision: 640
Proposed branch: lp:~javier.collado/utah/static_analysis_4
Merge into: lp:utah
Diff against target: 611 lines (+91/-63)
21 files modified
examples/run_install_test.py (+2/-1)
examples/run_test_vm.py (+2/-1)
utah/client/common.py (+4/-1)
utah/client/result.py (+3/-1)
utah/client/runner.py (+5/-3)
utah/client/testcase.py (+6/-4)
utah/client/tests/common.py (+4/-1)
utah/client/tests/manual_privileges.py (+1/-1)
utah/client/tests/test_common.py (+2/-1)
utah/client/tests/test_jsonschema.py (+10/-7)
utah/client/tests/test_misc.py (+3/-1)
utah/client/tests/test_result.py (+1/-1)
utah/client/tests/test_runner.py (+4/-6)
utah/client/tests/test_state_agent.py (+5/-7)
utah/client/tests/test_testcase.py (+4/-3)
utah/client/tests/test_testsuite.py (+5/-3)
utah/client/tests/test_yaml.py (+8/-7)
utah/client/testsuite.py (+6/-4)
utah/provisioning/baremetal/cobbler.py (+2/-1)
utah/provisioning/provisioning.py (+11/-6)
utah/provisioning/vm/libvirtvm.py (+3/-3)
To merge this branch: bzr merge lp:~javier.collado/utah/static_analysis_4
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Javier Collado (community) Needs Resubmitting
Review via email: mp+118745@code.launchpad.net

Description of the change

One more round of static analysis changes

Please have a look at the commit messages for further information about the problems fixed

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :
Download full text (21.5 KiB)

On Wed, Aug 08, 2012 at 01:31:34PM -0000, Javier Collado wrote:
> Javier Collado has proposed merging lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.
>
> Requested reviews:
> UTAH Dev (utah)

See my comments below. I'm pulling setUp and tearDown from
utah/client/tests/common.py into the tests namespace so that nosetests
will find them and run them on start and finish.

Joe
>
> For more details, see:
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
>
> One more round of static analysis changes
>
> Please have a look at the commit messages for further information about the problems fixed
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

> === modified file 'examples/run_install_test.py'
> --- examples/run_install_test.py 2012-07-31 20:54:45 +0000
> +++ examples/run_install_test.py 2012-08-08 13:30:26 +0000
> @@ -97,7 +97,8 @@
> try:
> inventory.destroy(machine.machineid)
> except UTAHException as error:
> - sys.stderr.write('Failed to update inventory: ' + str(error))
> + sys.stderr.write('Failed to update inventory: '
> + + str(error))
> finally:
> del machine
> if len(locallogs) != 0:
>
> === modified file 'examples/run_test_vm.py'
> --- examples/run_test_vm.py 2012-07-31 20:54:02 +0000
> +++ examples/run_test_vm.py 2012-08-08 13:30:26 +0000
> @@ -77,7 +77,8 @@
> try:
> inventory.destroy(machine.machineid)
> except UTAHException as error:
> - sys.stderr.write('Failed to update inventory: ' + str(error))
> + sys.stderr.write('Failed to update inventory: '
> + + str(error))
> finally:
> del machine
> if len(locallogs) != 0:
>
> === modified file 'utah/client/common.py'
> --- utah/client/common.py 2012-08-02 18:36:14 +0000
> +++ utah/client/common.py 2012-08-08 13:30:26 +0000
> @@ -48,6 +48,7 @@
> CMD_TS_SETUP = 'testsuite_setup'
> CMD_TS_CLEANUP = 'testsuite_cleanup'
>
> +
> def do_nothing(obj=None):
> """
> Do nothing method used a placeholder for save_state_callbacks.
> @@ -265,6 +266,7 @@
> fp.close()
> print("### End {} ###".format(artifact))
>
> +
> def get_media_info():
> """
> Get the contents of the media-info file if available.
> @@ -279,6 +281,7 @@
>
> return media_info
>
> +
> def get_host_info():
> """
> Get host info, useful for debugging.
> @@ -291,6 +294,7 @@
>
> return retval
>
> +
> def get_api_config():
> """
> Parse the client configuration file for API configuration data.
> @@ -303,4 +307,3 @@
> data = json.load(fp)
>
> return data['API']
> -
>
> === modified file 'utah/client/result.py'
> --- utah/client/result.py 2012-08-02 16:03:40 +0000
> +++ utah/client/resul...

Revision history for this message
Javier Collado (javier.collado) wrote :

That makes sense, I'll add again those imports then an resubmit. Thanks for your feedback.

607. By Max Brustkern

Added support for nested timeouts; outer timeout alwasy wins right
now

608. By Max Brustkern

Merged Javier's packaging fix

609. By Max Brustkern

Added debhelper tokens to scripts

Revision history for this message
Javier Collado (javier.collado) wrote :

@Joe
The imports that were mistakenly removed have been added again.

I wanted to verify if nosetests works fine and I got 20 errors mainly because:
- master.run file is missing
-/var/lib/utah/examples isn't found
- and ...
Traceback (most recent call last):
  File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
    self.assertTrue(os.path.exists(os.path.join(path, name)))
AssertionError: False is not true

I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

Revision history for this message
Joe Talbott (joetalbott) wrote :

On Wed, Aug 08, 2012 at 04:30:27PM -0000, Javier Collado wrote:
> @Joe
> The imports that were mistakenly removed have been added again.
>
> I wanted to verify if nosetests works fine and I got 20 errors mainly because:
> - master.run file is missing
> -/var/lib/utah/examples isn't found
> - and ...
> Traceback (most recent call last):
> File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
> self.assertTrue(os.path.exists(os.path.join(path, name)))
> AssertionError: False is not true
>
> I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

Have a look at utah/client/tests/README. There's a list in there of the
required packages for testing. Also note that the recommended way is to
run the nosetests from the top-level of the repo. Also make sure you
clean out /var/lib/utah before running. If that fails let me know and
I'll pull your branch and check it out.

Thanks,
Joe
>
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

Revision history for this message
Joe Talbott (joetalbott) wrote :

On Wed, Aug 08, 2012 at 04:30:27PM -0000, Javier Collado wrote:
> @Joe
> The imports that were mistakenly removed have been added again.
>
> I wanted to verify if nosetests works fine and I got 20 errors mainly because:
> - master.run file is missing
> -/var/lib/utah/examples isn't found
> - and ...
> Traceback (most recent call last):
> File "/home/javi/code/bzr/utah/static_analysis_4/utah/client/tests/test_testsuite.py", line 30, in setUp
> self.assertTrue(os.path.exists(os.path.join(path, name)))
> AssertionError: False is not true
>
> I followed the instructions in utah_howto.txt, but something must be missing in my environment. Please could you let me know what did you do to set up yours? Thanks.

Also make sure that the global setUp and tearDown methods are getting
called because they do some setting up of the environment as well.
>
> --
> https://code.launchpad.net/~javier.collado/utah/static_analysis_4/+merge/118745
> Your team UTAH Dev is requested to review the proposed merge of lp:~javier.collado/utah/static_analysis_4 into lp:utah/dev.

610. By Joe Talbott

Support timeout overrides from master.run to ts_control to
tc_control

611. By Max Brustkern

Added exception for when client fails to install

612. By Joe Talbott

Merge Javier's LP URL work

Revision history for this message
Javier Collado (javier.collado) wrote :

I've run the test cases for both precise and quantal with the packaged version of python-jsonschema and they passed successfully.

review: Needs Resubmitting
613. By Max Brustkern

Check for correct error when New option is not set to True

614. By Joe Talbott

Download and run testsuites in UTAH_DIR/testsuites

615. By Joe Talbott

Merge Javier's python-jsonschema work

616. By Joe Talbott

Remove extra 'testsuites' directory

617. By Max Brustkern

Merged Javier's changes for propagating exit status so exceptions still show

618. By Max Brustkern

Merged Javier's client installation related exceptions

619. By Max Brustkern

Merged Javier's readability improvements

620. By Max Brustkern

Merged Javier's change that Fixes 1034348

Revision history for this message
Javier Collado (javier.collado) wrote :

@Joe

Please let me know if there's some other thing might be a concern. Thanks.

621. By Max Brustkern

Merged Javier's changes for clearer error reporting when file downloads fail

622. By Max Brustkern

Improved docstrings for non-provisioning modules

623. By Max Brustkern

This is in config.py now

624. By Max Brustkern

Removed old json files

625. By Max Brustkern

Improved documentation in provisioning

626. By Javier Collado

Merged lp:~nuclearbob/utah/packaging-changes

This fixes the problem of not being able to install both utah and utah-client
together.

627. By Max Brustkern

Added diskbus option for VM creation

628. By Max Brustkern

Cleaning up stop method of libvirtvm

629. By Max Brustkern

Testing package version change

630. By Max Brustkern

Fixed postinst typo

631. By Max Brustkern

Merged Javier's default test case fixes

632. By Max Brustkern

Merged Javier's packaging changes

633. By Max Brustkern

Merged Javier's changes for new try blocks

634. By Max Brustkern

Merges Javier's gdebi changes

635. By Javier Collado

Merged fix from lp:~javier.collado/utah/bug1035231

Although package installation failures are reported, gdebi must be executed as
root for the succesful case.

646. By Javier Collado

Added again the imports needed by nosetests

Used NOQA to skip flake8 error on those imports and added a comment to mark
clearly that they are needed even if they aren't used directly.

Revision history for this message
Javier Collado (javier.collado) wrote :

I've rebased changes to make sure the merge is still easy to do (resolved one conflict).

Revision history for this message
Joe Talbott (joetalbott) wrote :

Look good. Feel free to merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/run_install_test.py'
2--- examples/run_install_test.py 2012-08-14 15:42:17 +0000
3+++ examples/run_install_test.py 2012-08-16 12:03:20 +0000
4@@ -100,7 +100,8 @@
5 try:
6 inventory.destroy(machine.machineid)
7 except UTAHException as error:
8- sys.stderr.write('Failed to update inventory: ' + str(error))
9+ sys.stderr.write('Failed to update inventory: '
10+ + str(error))
11 finally:
12 del machine
13 if len(locallogs) != 0:
14
15=== modified file 'examples/run_test_vm.py'
16--- examples/run_test_vm.py 2012-07-31 20:54:02 +0000
17+++ examples/run_test_vm.py 2012-08-16 12:03:20 +0000
18@@ -77,7 +77,8 @@
19 try:
20 inventory.destroy(machine.machineid)
21 except UTAHException as error:
22- sys.stderr.write('Failed to update inventory: ' + str(error))
23+ sys.stderr.write('Failed to update inventory: '
24+ + str(error))
25 finally:
26 del machine
27 if len(locallogs) != 0:
28
29=== modified file 'utah/client/common.py'
30--- utah/client/common.py 2012-08-09 20:14:54 +0000
31+++ utah/client/common.py 2012-08-16 12:03:20 +0000
32@@ -49,6 +49,7 @@
33 CMD_TS_SETUP = 'testsuite_setup'
34 CMD_TS_CLEANUP = 'testsuite_cleanup'
35
36+
37 def do_nothing(obj=None):
38 """
39 Do nothing method used a placeholder for save_state_callbacks.
40@@ -266,6 +267,7 @@
41 fp.close()
42 print("### End {} ###".format(artifact))
43
44+
45 def get_media_info():
46 """
47 Get the contents of the media-info file if available.
48@@ -280,6 +282,7 @@
49
50 return media_info
51
52+
53 def get_host_info():
54 """
55 Get host info, useful for debugging.
56@@ -292,6 +295,7 @@
57
58 return retval
59
60+
61 def get_api_config():
62 """
63 Parse the client configuration file for API configuration data.
64@@ -304,4 +308,3 @@
65 data = json.load(fp)
66
67 return data['API']
68-
69
70=== modified file 'utah/client/result.py'
71--- utah/client/result.py 2012-08-02 16:03:40 +0000
72+++ utah/client/result.py 2012-08-16 12:03:20 +0000
73@@ -4,6 +4,7 @@
74
75 from .common import get_host_info
76
77+
78 class Result(object):
79 """
80 Result collection class.
81@@ -132,7 +133,8 @@
82 'uname': list(host_info['uname']),
83 'media-info': host_info['media-info'],
84 }
85- yaml.dump(data, sys.stdout, explicit_start='---', default_flow_style=False)
86+ yaml.dump(data, sys.stdout, explicit_start='---',
87+ default_flow_style=False)
88
89 status = self.status
90 self.clear_results()
91
92=== modified file 'utah/client/runner.py'
93--- utah/client/runner.py 2012-08-09 20:14:54 +0000
94+++ utah/client/runner.py 2012-08-16 12:03:20 +0000
95@@ -270,7 +270,8 @@
96
97 self.backup_runlist = os.path.join(self.testdir, 'master.run-reboot')
98
99- if os.path.exists(self.master_runlist) and self.master_runlist != self.backup_runlist:
100+ if (os.path.exists(self.master_runlist)
101+ and self.master_runlist != self.backup_runlist):
102 shutil.copyfile(self.master_runlist, self.backup_runlist)
103
104 state = {
105@@ -326,7 +327,7 @@
106 # local filename if needed (it might be a local file already or cached)
107 try:
108 local_filename = urllib.urlretrieve(runlist)[0]
109- except IOError as e:
110+ except IOError:
111 raise exceptions.MissingFile(runlist)
112
113 data = parse_yaml_file(local_filename)
114@@ -372,7 +373,8 @@
115
116 if name not in self.fetched_suites:
117 if fetch_cmd is not None:
118- self.result.add_result(run_cmd(fetch_cmd, cwd=name, cmd_type=CMD_TS_FETCH))
119+ self.result.add_result(run_cmd(fetch_cmd, cwd=name,
120+ cmd_type=CMD_TS_FETCH))
121 self.fetched_suites.append(name)
122
123 # If fetch_cmd failed move on to the next testsuite.
124
125=== modified file 'utah/client/testcase.py'
126--- utah/client/testcase.py 2012-08-10 17:12:13 +0000
127+++ utah/client/testcase.py 2012-08-16 12:03:20 +0000
128@@ -5,7 +5,6 @@
129 from common import run_cmd, parse_control_file
130 from common import do_nothing
131 from common import CMD_TC_BUILD, CMD_TC_SETUP, CMD_TC_TEST, CMD_TC_CLEANUP
132-from result import Result
133 from exceptions import MissingFile
134
135
136@@ -113,7 +112,8 @@
137 """
138 if self.status == 'NOTRUN':
139 self.set_status('BUILD')
140- result.add_result(run_cmd(self.build_cmd, cwd=self.working_dir, cmd_type=CMD_TC_BUILD))
141+ result.add_result(run_cmd(self.build_cmd, cwd=self.working_dir,
142+ cmd_type=CMD_TC_BUILD))
143
144 def setup(self, result):
145 """
146@@ -121,7 +121,8 @@
147 """
148 if self.status == 'BUILD' and result.status == 'PASS':
149 self.set_status('SETUP')
150- result.add_result(run_cmd(self.tc_setup, cwd=self.working_dir, cmd_type=CMD_TC_SETUP))
151+ result.add_result(run_cmd(self.tc_setup, cwd=self.working_dir,
152+ cmd_type=CMD_TC_SETUP))
153
154 def cleanup(self, result):
155 """
156@@ -129,7 +130,8 @@
157 """
158 if self.status == 'RUN':
159 self.set_status('CLEANUP')
160- result.add_result(run_cmd(self.tc_cleanup, cwd=self.working_dir, cmd_type=CMD_TC_CLEANUP))
161+ result.add_result(run_cmd(self.tc_cleanup, cwd=self.working_dir,
162+ cmd_type=CMD_TC_CLEANUP))
163
164 def run(self):
165 """
166
167=== modified file 'utah/client/tests/common.py'
168--- utah/client/tests/common.py 2012-08-09 20:14:54 +0000
169+++ utah/client/tests/common.py 2012-08-16 12:03:20 +0000
170@@ -1,7 +1,8 @@
171 import os
172 import shutil
173
174-from utah.client.common import UTAH_DIR, MASTER_RUNLIST, UTAH_CLIENT
175+from utah.client.common import UTAH_DIR, MASTER_RUNLIST
176+
177
178 def get_module_path():
179 """
180@@ -39,6 +40,7 @@
181 #examples_source = os.path.join(UTAH_CLIENT, 'examples')
182 examples_source = os.path.join(get_module_path(), 'client', 'examples')
183
184+
185 def setUp():
186 """
187 Set up a master.run file that will copy our 'examples' directory to the
188@@ -61,6 +63,7 @@
189 fp.write(master_runlist_content)
190 fp.close()
191
192+
193 def tearDown():
194 """
195 Cleanup after ourselves.
196
197=== modified file 'utah/client/tests/manual_privileges.py'
198--- utah/client/tests/manual_privileges.py 2012-08-01 17:25:20 +0000
199+++ utah/client/tests/manual_privileges.py 2012-08-16 12:03:20 +0000
200@@ -116,6 +116,7 @@
201 print_priv("after")
202 _do_cmd("id")
203
204+
205 class TestPriv(baseTestPriv):
206 def test_drop_priv(self):
207 """
208@@ -170,4 +171,3 @@
209 })
210
211 _do_cmd("id")
212-
213
214=== modified file 'utah/client/tests/test_common.py'
215--- utah/client/tests/test_common.py 2012-07-31 19:40:18 +0000
216+++ utah/client/tests/test_common.py 2012-08-16 12:03:20 +0000
217@@ -10,6 +10,7 @@
218 CONFIG,
219 )
220
221+
222 class TestCommon(unittest.TestCase):
223 """
224 Tests for utah.client.common.
225@@ -35,7 +36,7 @@
226 host_info = get_host_info()
227
228 print("host_info: {}".format(host_info))
229-
230+
231 self.assertTrue(host_info is not None)
232
233 def test_run_cmd(self):
234
235=== modified file 'utah/client/tests/test_jsonschema.py'
236--- utah/client/tests/test_jsonschema.py 2012-08-06 19:16:38 +0000
237+++ utah/client/tests/test_jsonschema.py 2012-08-16 12:03:20 +0000
238@@ -27,22 +27,23 @@
239 testsuties:
240 - name: testsuite1
241 fetch_cmd: fetch1
242-""", # typo
243+""", # typo
244 """---
245 timeout: 101
246 repeat_count: 99
247-""", # missing testsuites
248+""", # missing testsuites
249 """---
250 - name: blah
251 - name: blip
252-""", # missing fetch_cmds
253+""", # missing fetch_cmds
254 """---
255 testsuites:
256 - name: blah
257 - name: blip
258-""", # missing fetch_cmds
259+""", # missing fetch_cmds
260 ]
261
262+
263 class TestJSONSchema(unittest.TestCase):
264
265 def test_orig_schema(self):
266@@ -64,7 +65,8 @@
267 jsonschema.validate(data_new, Runner.MASTER_RUNLIST_SCHEMA)
268
269 def test_example_runlist(self):
270- example_runlist = os.path.join(os.path.dirname(__file__), "../examples/master.run")
271+ example_runlist = os.path.join(os.path.dirname(__file__),
272+ "../examples/master.run")
273
274 self.assertTrue(os.path.exists(example_runlist))
275
276@@ -74,7 +76,6 @@
277 jsonschema.validate(data, Runner.MASTER_RUNLIST_SCHEMA)
278 fp.close()
279
280-
281 def test_bad_schemas(self):
282 """
283 Test that required fields are enforced by the schema.
284@@ -83,4 +84,6 @@
285 for content in yaml_content_bad:
286 data = yaml.load(content)
287 print("data: {}".format(data))
288- self.assertRaises(jsonschema.ValidationError, jsonschema.validate, data, Runner.MASTER_RUNLIST_SCHEMA)
289+ self.assertRaises(jsonschema.ValidationError,
290+ jsonschema.validate,
291+ data, Runner.MASTER_RUNLIST_SCHEMA)
292
293=== modified file 'utah/client/tests/test_misc.py'
294--- utah/client/tests/test_misc.py 2012-08-06 19:40:22 +0000
295+++ utah/client/tests/test_misc.py 2012-08-16 12:03:20 +0000
296@@ -3,11 +3,13 @@
297
298 from .common import get_module_path
299
300+
301 class TestMisc(unittest.TestCase):
302 def test_get_module_path(self):
303
304 print("__file__: {}".format(__file__))
305
306 # assumes this file is in 'utah/client/tests'
307- file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))
308+ file_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
309+ "../../"))
310 self.assertEqual(file_path, get_module_path())
311
312=== modified file 'utah/client/tests/test_result.py'
313--- utah/client/tests/test_result.py 2012-07-30 14:27:12 +0000
314+++ utah/client/tests/test_result.py 2012-08-16 12:03:20 +0000
315@@ -6,6 +6,7 @@
316 ResultYAML,
317 )
318
319+
320 class TestResult(unittest.TestCase):
321 def setUp(self):
322 self.result_yaml = ResultYAML("result_yaml")
323@@ -118,4 +119,3 @@
324 self.assertEqual(result['returncode'], self.result['returncode'])
325 self.assertEqual(result['stdout'], self.result['stdout'])
326 self.assertEqual(result['stderr'], self.result['stderr'])
327-
328
329=== modified file 'utah/client/tests/test_runner.py'
330--- utah/client/tests/test_runner.py 2012-08-09 20:14:54 +0000
331+++ utah/client/tests/test_runner.py 2012-08-16 12:03:20 +0000
332@@ -8,15 +8,13 @@
333 from utah.client.common import RETURN_CODES
334 from utah.client import exceptions
335
336-from .common import setUp, tearDown
337-from .common import (
338+from .common import ( # NOQA
339+ setUp, # Used by nosetests
340+ tearDown, # Used by nosetests
341 master_runlist_content,
342- master_runlist,
343- master_runlist_bak,
344- examples_dir,
345- examples_source,
346 )
347
348+
349 class TestRunner(unittest.TestCase):
350 def setUp(self):
351 self.result_class = ResultYAML
352
353=== modified file 'utah/client/tests/test_state_agent.py'
354--- utah/client/tests/test_state_agent.py 2012-08-09 20:14:54 +0000
355+++ utah/client/tests/test_state_agent.py 2012-08-16 12:03:20 +0000
356@@ -6,14 +6,11 @@
357 from utah.client.state_agent import StateAgentYAML
358 from utah.client.runner import Runner
359 from utah.client.result import ResultYAML
360-from utah.client.common import (
361- run_cmd,
362- UTAH_DIR,
363- )
364+from utah.client.common import UTAH_DIR
365
366-from .common import (
367- setUp,
368- tearDown,
369+from .common import ( # NOQA
370+ setUp, # Used by nosetests
371+ tearDown, # Used by nosetests
372 get_module_path,
373 )
374
375@@ -70,6 +67,7 @@
376 ts_setup: null
377 """
378
379+
380 class TestStateAgentYAML(unittest.TestCase):
381 def setUp(self):
382 """
383
384=== modified file 'utah/client/tests/test_testcase.py'
385--- utah/client/tests/test_testcase.py 2012-08-09 20:14:54 +0000
386+++ utah/client/tests/test_testcase.py 2012-08-16 12:03:20 +0000
387@@ -7,11 +7,12 @@
388 )
389 from utah.client import testcase
390
391-from .common import (
392- setUp,
393- tearDown,
394+from .common import ( # NOQA
395+ setUp, # Used by nosetests
396+ tearDown, # Used by nosetests
397 )
398
399+
400 class TestTestCase(unittest.TestCase):
401 """
402 Tests for the TestCase class.
403
404=== modified file 'utah/client/tests/test_testsuite.py'
405--- utah/client/tests/test_testsuite.py 2012-08-09 20:14:54 +0000
406+++ utah/client/tests/test_testsuite.py 2012-08-16 12:03:20 +0000
407@@ -7,14 +7,16 @@
408 from utah.client.result import ResultYAML
409 from utah.client import testsuite
410
411-from .common import (
412- setUp,
413- tearDown,
414+from .common import ( # NOQA
415+ setUp, # Used by nosetests
416+ tearDown, # Used by nosetests
417 )
418
419+
420 def state_saver():
421 debug_print("Saving state", force=True)
422
423+
424 class TestTestSuite(unittest.TestCase):
425 """
426 Tests for the TestSuite class.
427
428=== modified file 'utah/client/tests/test_yaml.py'
429--- utah/client/tests/test_yaml.py 2012-07-27 19:42:26 +0000
430+++ utah/client/tests/test_yaml.py 2012-08-16 12:03:20 +0000
431@@ -1,18 +1,19 @@
432 import unittest
433 import yaml
434
435+
436 class TestYAML(unittest.TestCase):
437 def test_parts(self):
438 content = {}
439 content['metadata'] = {
440- 'runlist' : '/tmp/master.run',
441- 'host' : 'Ubuntu 12.04 LTS',
442+ 'runlist': '/tmp/master.run',
443+ 'host': 'Ubuntu 12.04 LTS',
444 }
445 content['commands'] = [
446 {
447- 'command' : 'rm -f blah',
448- 'stdout' : '',
449- 'stderr' : '',
450+ 'command': 'rm -f blah',
451+ 'stdout': '',
452+ 'stderr': '',
453 }
454 ]
455
456@@ -26,7 +27,7 @@
457
458 def test_parts_2(self):
459 content = {
460- 'file' : '/tmp/file'
461+ 'file': '/tmp/file'
462 }
463
464 extra_args = {
465@@ -63,7 +64,7 @@
466 extra_args = {}
467 content = [
468 {
469- 'file' : '/tmp/file',
470+ 'file': '/tmp/file',
471 },
472 [
473 {
474
475=== modified file 'utah/client/testsuite.py'
476--- utah/client/testsuite.py 2012-08-08 21:10:05 +0000
477+++ utah/client/testsuite.py 2012-08-16 12:03:20 +0000
478@@ -6,7 +6,6 @@
479 from common import DEFAULT_TSLIST, DEFAULT_TSCONTROL
480 from common import CMD_TS_BUILD, CMD_TS_SETUP, CMD_TS_CLEANUP
481 from common import do_nothing
482-from result import Result
483 import jsonschema
484
485 import os
486@@ -166,7 +165,8 @@
487 """
488 if self.status == 'NOTRUN':
489 self.set_status('BUILD')
490- result.add_result(run_cmd(self.build_cmd, cwd=self.name, cmd_type=CMD_TS_BUILD))
491+ result.add_result(run_cmd(self.build_cmd, cwd=self.name,
492+ cmd_type=CMD_TS_BUILD))
493
494 def setup(self, result):
495 """
496@@ -174,7 +174,8 @@
497 """
498 if self.status == 'BUILD' and result.status == 'PASS':
499 self.set_status('SETUP')
500- result.add_result(run_cmd(self.ts_setup, cwd=self.name, cmd_type=CMD_TS_SETUP))
501+ result.add_result(run_cmd(self.ts_setup, cwd=self.name,
502+ cmd_type=CMD_TS_SETUP))
503
504 def cleanup(self, result):
505 """
506@@ -182,7 +183,8 @@
507 """
508 if self.status == 'INPROGRESS':
509 self.set_status('CLEANUP')
510- result.add_result(run_cmd(self.ts_cleanup, cwd=self.name, cmd_type=CMD_TS_CLEANUP))
511+ result.add_result(run_cmd(self.ts_cleanup, cwd=self.name,
512+ cmd_type=CMD_TS_CLEANUP))
513
514 def run(self):
515 """
516
517=== modified file 'utah/provisioning/baremetal/cobbler.py'
518--- utah/provisioning/baremetal/cobbler.py 2012-08-03 21:44:39 +0000
519+++ utah/provisioning/baremetal/cobbler.py 2012-08-16 12:03:20 +0000
520@@ -132,7 +132,8 @@
521 for name in (dirnames + filenames):
522 filename = os.path.join(dirpath, name)
523 if not os.path.islink(filename):
524- self.logger.debug('Changing permissions of ' + filename)
525+ self.logger.debug('Changing permissions of '
526+ + filename)
527 os.chmod(filename, 0775)
528 shutil.rmtree(self.tmpdir)
529
530
531=== modified file 'utah/provisioning/provisioning.py'
532--- utah/provisioning/provisioning.py 2012-08-15 09:35:14 +0000
533+++ utah/provisioning/provisioning.py 2012-08-16 12:03:20 +0000
534@@ -504,14 +504,16 @@
535 self.logger.info('Uploading ' + localpath
536 + ' from the host to ' + target
537 + ' on the machine')
538- remotepath = os.path.join(target, os.path.basename(localpath))
539+ remotepath = os.path.join(target,
540+ os.path.basename(localpath))
541 sftp_client.put(localpath, remotepath)
542 else:
543 failed.append(localpath)
544 finally:
545 sftp_client.close()
546 if len(failed) > 0:
547- err = UTAHProvisioningException('Files do not exist: ' + ' '.join(failed))
548+ err = UTAHProvisioningException('Files do not exist: '
549+ + ' '.join(failed))
550 err.files = failed
551 raise err
552
553@@ -554,7 +556,8 @@
554 self.ssh_client.connect(self.name,
555 key_filename=config.sshprivatekey)
556 sftp_client = self.ssh_client.open_sftp()
557- files = [os.path.join(dirname, myfile) for myfile in sftp_client.listdir(dirname)]
558+ files = [os.path.join(dirname, myfile)
559+ for myfile in sftp_client.listdir(dirname)]
560 self.downloadfiles(files, target)
561
562 def destroy(self, *args, **kw):
563@@ -605,13 +608,15 @@
564 except socket.error as err:
565 raise UTAHProvisioningException(str(err), retry=True)
566
567- def sshpoll(self, timeout=config.boottimeout, checktimeout=config.checktimeout, logmethod=None):
568+ def sshpoll(self, timeout=config.boottimeout,
569+ checktimeout=config.checktimeout, logmethod=None):
570 """
571 Run sshcheck over and over until timeout expires.
572 """
573 if logmethod is None:
574- logmethod=self.logger.debug
575- utah.timeout.timeout(timeout, retry, self.sshcheck, checktimeout, logmethod=logmethod)
576+ logmethod = self.logger.debug
577+ utah.timeout.timeout(timeout, retry, self.sshcheck, checktimeout,
578+ logmethod=logmethod)
579
580
581 class CustomInstallMixin(object):
582
583=== modified file 'utah/provisioning/vm/libvirtvm.py'
584--- utah/provisioning/vm/libvirtvm.py 2012-08-14 16:50:47 +0000
585+++ utah/provisioning/vm/libvirtvm.py 2012-08-16 12:03:20 +0000
586@@ -6,7 +6,6 @@
587 import string
588 import subprocess
589 import tempfile
590-import time
591
592 from xml.etree import ElementTree
593
594@@ -24,7 +23,6 @@
595 )
596 from utah import config
597 from utah.process import ProcessChecker
598-import utah.timeout
599
600
601 class LibvirtVM(VM):
602@@ -336,7 +334,9 @@
603 for myfile in files:
604 self.logger.info('Uploading ' + myfile
605 + ' from the host to ' + target + ' on the VM')
606- if self._runargs(['vm-scp', '-f', '-p', self.name, myfile, target]) != 0:
607+ returncode = self._runargs(['vm-scp', '-f', '-p',
608+ self.name, myfile, target])
609+ if returncode != 0:
610 success = False
611 return success
612

Subscribers

People subscribed via source and target branches