Merge lp:~xnox/utah/new-pep8 into lp:utah

Proposed by Dimitri John Ledkov
Status: Merged
Approved by: Javier Collado
Approved revision: 774
Merged at revision: 775
Proposed branch: lp:~xnox/utah/new-pep8
Merge into: lp:utah
Diff against target: 2328 lines (+551/-520)
37 files modified
examples/run_install_test.py (+21/-19)
examples/run_test_bamboo_feeder.py (+11/-11)
examples/run_test_cobbler.py (+12/-11)
examples/run_test_vm.py (+12/-11)
examples/run_utah_tests.py (+15/-14)
setup.py (+6/-5)
tests/test_parser.py (+1/-0)
utah/client/common.py (+26/-24)
utah/client/phoenix.py (+22/-21)
utah/client/result.py (+23/-23)
utah/client/runner.py (+32/-32)
utah/client/testcase.py (+51/-49)
utah/client/tests/__init__.py (+0/-1)
utah/client/tests/common.py (+7/-6)
utah/client/tests/manual_privileges.py (+2/-2)
utah/client/tests/test_common.py (+7/-7)
utah/client/tests/test_jsonschema.py (+6/-6)
utah/client/tests/test_phoenix.py (+10/-10)
utah/client/tests/test_result.py (+3/-3)
utah/client/tests/test_runner.py (+9/-8)
utah/client/tests/test_state_agent.py (+42/-37)
utah/client/tests/test_testcase.py (+33/-32)
utah/client/tests/test_testsuite.py (+32/-24)
utah/client/tests/test_yaml.py (+36/-36)
utah/client/testsuite.py (+10/-10)
utah/config.py (+15/-13)
utah/iso.py (+4/-4)
utah/isotest/iso_static_validation.py (+2/-2)
utah/orderedcollections.py (+2/-2)
utah/process.py (+5/-5)
utah/provisioning/baremetal/bamboofeeder.py (+30/-30)
utah/provisioning/baremetal/cobbler.py (+14/-15)
utah/provisioning/baremetal/power.py (+0/-1)
utah/provisioning/inventory/inventory.py (+5/-5)
utah/provisioning/inventory/sqlite.py (+29/-27)
utah/publish.py (+10/-10)
utah/timeout.py (+6/-4)
To merge this branch: bzr merge lp:~xnox/utah/new-pep8
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Review via email: mp+138850@code.launchpad.net

Description of the change

New pep8 in raring is more strict about whitespace.
Here are some fixes.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

Looks good to me. Also, I've run the `pass.run` runlist with a desktop i386
image and worked fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/run_install_test.py'
--- examples/run_install_test.py 2012-12-03 15:49:35 +0000
+++ examples/run_install_test.py 2012-12-08 02:12:21 +0000
@@ -29,15 +29,15 @@
2929
30def get_parser():30def get_parser():
31 parser = argparse.ArgumentParser(31 parser = argparse.ArgumentParser(
32 description=('Provision a machine '32 description=('Provision a machine '
33 'and run one or more UTAH runlists there.'),33 'and run one or more UTAH runlists there.'),
34 epilog=("For example:\n"34 epilog=("For example:\n"
35 "Provision a VM using a precise server image "35 "Provision a VM using a precise server image "
36 "with i386 architecture and run the two given runlists\n"36 "with i386 architecture and run the two given runlists\n"
37 "\t%(prog)s -s precise -t server -a i386 \\\n"37 "\t%(prog)s -s precise -t server -a i386 \\\n"
38 "\t\t/usr/share/utah/client/examples/master.run \\\n"38 "\t\t/usr/share/utah/client/examples/master.run \\\n"
39 "\t\t'http://people.canonical.com/~max/max_test.run'"),39 "\t\t'http://people.canonical.com/~max/max_test.run'"),
40 formatter_class=argparse.RawDescriptionHelpFormatter)40 formatter_class=argparse.RawDescriptionHelpFormatter)
41 parser.add_argument('runlists', metavar='runlist', nargs='+',41 parser.add_argument('runlists', metavar='runlist', nargs='+',
42 type=url_argument, help='URLs of runlist files to run')42 type=url_argument, help='URLs of runlist files to run')
43 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',43 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',
@@ -82,9 +82,10 @@
82 help='Enable json logging (default is YAML)')82 help='Enable json logging (default is YAML)')
83 parser.add_argument('-f', '--files', action='append',83 parser.add_argument('-f', '--files', action='append',
84 help='File or directory to copy from test system ')84 help='File or directory to copy from test system ')
85 parser.add_argument('-o', '--outdir', 85 parser.add_argument('-o', '--outdir',
86 help=('Directory to store locally copied files '86 help=('Directory to store locally copied files '
87 '(Default is ' + config.logpath + '/machine-name)'))87 '(Default is ' + config.logpath +
88 '/machine-name)'))
88 parser.add_argument('--diskbus', metavar='DISKBUS',89 parser.add_argument('--diskbus', metavar='DISKBUS',
89 choices=('virtio', 'sata', 'ide'),90 choices=('virtio', 'sata', 'ide'),
90 help=('Disk bus to use for customvm installation '91 help=('Disk bus to use for customvm installation '
@@ -111,14 +112,15 @@
111112
112 try:113 try:
113 inventory = TinySQLiteInventory()114 inventory = TinySQLiteInventory()
114 machine = inventory.request(CustomVM,115 machine = inventory.request(
115 arch=args.arch, boot=args.boot, clean=(not args.no_destroy), 116 CustomVM,
116 debug=args.debug, diskbus=args.diskbus,117 arch=args.arch, boot=args.boot, clean=(not args.no_destroy),
117 disksizes=args.gigabytes, dlpercentincrement=10,118 debug=args.debug, diskbus=args.diskbus,
118 emulator=args.emulator, image=args.image, initrd=args.initrd,119 disksizes=args.gigabytes, dlpercentincrement=10,
119 installtype=args.type, kernel=args.kernel, new=True,120 emulator=args.emulator, image=args.image, initrd=args.initrd,
120 preseed=args.preseed, rewrite=args.rewrite,121 installtype=args.type, kernel=args.kernel, new=True,
121 series=args.series, xml=args.xml)122 preseed=args.preseed, rewrite=args.rewrite,
123 series=args.series, xml=args.xml)
122 exitstatus, locallogs = run_tests(args, machine)124 exitstatus, locallogs = run_tests(args, machine)
123125
124 except UTAHException as error:126 except UTAHException as error:
125127
=== modified file 'examples/run_test_bamboo_feeder.py'
--- examples/run_test_bamboo_feeder.py 2012-12-03 15:49:35 +0000
+++ examples/run_test_bamboo_feeder.py 2012-12-08 02:12:21 +0000
@@ -30,15 +30,15 @@
3030
31def get_parser():31def get_parser():
32 parser = argparse.ArgumentParser(32 parser = argparse.ArgumentParser(
33 description=('Provision a pandaboard in a bamboo-feeder setup '33 description=('Provision a pandaboard in a bamboo-feeder setup '
34 'and run one or more UTAH runlists there.'),34 'and run one or more UTAH runlists there.'),
35 epilog=("For example:\n"35 epilog=("For example:\n"
36 "Provision a machine using a precise server image "36 "Provision a machine using a precise server image "
37 "with i386 architecture and run the two given runlists\n"37 "with i386 architecture and run the two given runlists\n"
38 "\t%(prog)s -s precise -t server -a i386 \\\n"38 "\t%(prog)s -s precise -t server -a i386 \\\n"
39 "\t\t/usr/share/utah/client/examples/master.run \\\n"39 "\t\t/usr/share/utah/client/examples/master.run \\\n"
40 "\t\t'http://people.canonical.com/~max/max_test.run'"),40 "\t\t'http://people.canonical.com/~max/max_test.run'"),
41 formatter_class=argparse.RawDescriptionHelpFormatter)41 formatter_class=argparse.RawDescriptionHelpFormatter)
42 parser.add_argument('runlists', metavar='runlist', nargs='+',42 parser.add_argument('runlists', metavar='runlist', nargs='+',
43 help='URLs of runlist files to run')43 help='URLs of runlist files to run')
44 parser.add_argument('-s', '--series', metavar='SERIES',44 parser.add_argument('-s', '--series', metavar='SERIES',
@@ -82,8 +82,8 @@
8282
83 try:83 try:
84 inventory = ManualCobblerSQLiteInventory(84 inventory = ManualCobblerSQLiteInventory(
85 db=os.path.join('~', '.utah-bamboofeeder-inventory'),85 db=os.path.join('~', '.utah-bamboofeeder-inventory'),
86 lockfile=os.path.join('~', '.utah-bamboofeeder-lock'))86 lockfile=os.path.join('~', '.utah-bamboofeeder-lock'))
87 kw = {}87 kw = {}
88 for arg in ['image', 'preseed']:88 for arg in ['image', 'preseed']:
89 value = vars(args)[arg]89 value = vars(args)[arg]
9090
=== modified file 'examples/run_test_cobbler.py'
--- examples/run_test_cobbler.py 2012-12-03 15:49:35 +0000
+++ examples/run_test_cobbler.py 2012-12-08 02:12:21 +0000
@@ -28,15 +28,15 @@
2828
29def get_parser():29def get_parser():
30 parser = argparse.ArgumentParser(30 parser = argparse.ArgumentParser(
31 description=('Provision a machine using cobbler '31 description=('Provision a machine using cobbler '
32 'and run one or more UTAH runlists there.'),32 'and run one or more UTAH runlists there.'),
33 epilog=("For example:\n"33 epilog=("For example:\n"
34 "Provision a machine using a precise server image "34 "Provision a machine using a precise server image "
35 "with i386 architecture and run the two given runlists\n"35 "with i386 architecture and run the two given runlists\n"
36 "\t%(prog)s -s precise -t server -a i386 \\\n"36 "\t%(prog)s -s precise -t server -a i386 \\\n"
37 "\t\t/usr/share/utah/client/examples/master.run \\\n"37 "\t\t/usr/share/utah/client/examples/master.run \\\n"
38 "\t\t'http://people.canonical.com/~max/max_test.run'"),38 "\t\t'http://people.canonical.com/~max/max_test.run'"),
39 formatter_class=argparse.RawDescriptionHelpFormatter)39 formatter_class=argparse.RawDescriptionHelpFormatter)
40 parser.add_argument('runlists', metavar='runlist', nargs='+',40 parser.add_argument('runlists', metavar='runlist', nargs='+',
41 help='URLs of runlist files to run')41 help='URLs of runlist files to run')
42 parser.add_argument('-n', '--name', help='Name of machine to provision')42 parser.add_argument('-n', '--name', help='Name of machine to provision')
@@ -63,9 +63,10 @@
63 help='Enable json logging (default is YAML)')63 help='Enable json logging (default is YAML)')
64 parser.add_argument('-f', '--files', action='append',64 parser.add_argument('-f', '--files', action='append',
65 help='File or directory to copy from test system ')65 help='File or directory to copy from test system ')
66 parser.add_argument('-o', '--outdir', 66 parser.add_argument('-o', '--outdir',
67 help=('Directory to store locally copied files '67 help=('Directory to store locally copied files '
68 '(Default is ' + config.logpath + '/machine-name)'))68 '(Default is ' + config.logpath +
69 '/machine-name)'))
69 parser.add_argument('--rewrite', choices=('all', 'minimal', 'casperonly',70 parser.add_argument('--rewrite', choices=('all', 'minimal', 'casperonly',
70 'none'), help='Enable or disable automatic '71 'none'), help='Enable or disable automatic '
71 'configuration rewriting')72 'configuration rewriting')
7273
=== modified file 'examples/run_test_vm.py'
--- examples/run_test_vm.py 2012-12-03 15:49:35 +0000
+++ examples/run_test_vm.py 2012-12-08 02:12:21 +0000
@@ -27,15 +27,15 @@
2727
28def get_parser():28def get_parser():
29 parser = argparse.ArgumentParser(29 parser = argparse.ArgumentParser(
30 description=('Create a virtual machine '30 description=('Create a virtual machine '
31 'and run a UTAH runlist there.'),31 'and run a UTAH runlist there.'),
32 epilog=("For example:\n"32 epilog=("For example:\n"
33 "Provision a VM using a precise server image "33 "Provision a VM using a precise server image "
34 "with i386 architecture and run the two given runlists\n"34 "with i386 architecture and run the two given runlists\n"
35 "\t%(prog)s -s precise -t server -a i386 \\\n"35 "\t%(prog)s -s precise -t server -a i386 \\\n"
36 "\t\t/usr/share/utah/client/examples/master.run \\\n"36 "\t\t/usr/share/utah/client/examples/master.run \\\n"
37 "\t\t'http://people.canonical.com/~max/max_test.run'"),37 "\t\t'http://people.canonical.com/~max/max_test.run'"),
38 formatter_class=argparse.RawDescriptionHelpFormatter)38 formatter_class=argparse.RawDescriptionHelpFormatter)
39 parser.add_argument('runlists', metavar='runlist', nargs='+',39 parser.add_argument('runlists', metavar='runlist', nargs='+',
40 help='URLs of runlist files to run')40 help='URLs of runlist files to run')
41 parser.add_argument('-s', '--series', metavar='SERIES',41 parser.add_argument('-s', '--series', metavar='SERIES',
@@ -57,9 +57,10 @@
57 help='Enable json logging (default is YAML)')57 help='Enable json logging (default is YAML)')
58 parser.add_argument('-f', '--files', action='append',58 parser.add_argument('-f', '--files', action='append',
59 help='File or directory to copy from test system ')59 help='File or directory to copy from test system ')
60 parser.add_argument('-o', '--outdir', 60 parser.add_argument('-o', '--outdir',
61 help=('Directory to store locally copied files '61 help=('Directory to store locally copied files '
62 '(Default is ' + config.logpath + '/machine-name)'))62 '(Default is ' + config.logpath +
63 '/machine-name)'))
63 parser.add_argument('--dumplogs', action='store_true',64 parser.add_argument('--dumplogs', action='store_true',
64 help='Write client output logs to standard out')65 help='Write client output logs to standard out')
65 return parser66 return parser
6667
=== modified file 'examples/run_utah_tests.py'
--- examples/run_utah_tests.py 2012-12-03 15:49:35 +0000
+++ examples/run_utah_tests.py 2012-12-08 02:12:21 +0000
@@ -28,17 +28,17 @@
2828
29def get_parser():29def get_parser():
30 parser = argparse.ArgumentParser(30 parser = argparse.ArgumentParser(
31 description=('Provision a machine '31 description=('Provision a machine '
32 'and run one or more UTAH runlists there.\n\n'32 'and run one or more UTAH runlists there.\n\n'
33 'The appropriate run_*.py script will be called, '33 'The appropriate run_*.py script will be called, '
34 'depending on the parameters passed.'),34 'depending on the parameters passed.'),
35 epilog=("For example:\n"35 epilog=("For example:\n"
36 "Provision a VM using a precise server image "36 "Provision a VM using a precise server image "
37 "with i386 architecture and run the two given runlists\n"37 "with i386 architecture and run the two given runlists\n"
38 "\t%(prog)s -s precise -t server -a i386 \\\n"38 "\t%(prog)s -s precise -t server -a i386 \\\n"
39 "\t\t/usr/share/utah/client/examples/master.run \\\n"39 "\t\t/usr/share/utah/client/examples/master.run \\\n"
40 "\t\t'http://people.canonical.com/~max/max_test.run'"),40 "\t\t'http://people.canonical.com/~max/max_test.run'"),
41 formatter_class=argparse.RawDescriptionHelpFormatter)41 formatter_class=argparse.RawDescriptionHelpFormatter)
42 parser.add_argument('runlists', metavar='runlist', nargs='+',42 parser.add_argument('runlists', metavar='runlist', nargs='+',
43 type=url_argument, help='URLs of runlist files to run')43 type=url_argument, help='URLs of runlist files to run')
44 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',44 parser.add_argument('-m', '--machinetype', metavar='MACHINETYPE',
@@ -83,9 +83,10 @@
83 help='Enable json logging (default is YAML)')83 help='Enable json logging (default is YAML)')
84 parser.add_argument('-f', '--files', action='append',84 parser.add_argument('-f', '--files', action='append',
85 help='File or directory to copy from test system ')85 help='File or directory to copy from test system ')
86 parser.add_argument('-o', '--outdir', 86 parser.add_argument('-o', '--outdir',
87 help=('Directory to store locally copied files '87 help=('Directory to store locally copied files '
88 '(Default is ' + config.logpath + '/machine-name)'))88 '(Default is ' + config.logpath +
89 '/machine-name)'))
89 parser.add_argument('--diskbus', metavar='DISKBUS',90 parser.add_argument('--diskbus', metavar='DISKBUS',
90 choices=('virtio', 'sata', 'ide'),91 choices=('virtio', 'sata', 'ide'),
91 help=('Disk bus to use for customvm installation '92 help=('Disk bus to use for customvm installation '
@@ -125,7 +126,7 @@
125 # If machinetype is physical but arch isn't arm, use CobblerMachine126 # If machinetype is physical but arch isn't arm, use CobblerMachine
126 from run_test_cobbler import run_test_cobbler127 from run_test_cobbler import run_test_cobbler
127 function = run_test_cobbler128 function = run_test_cobbler
128 129
129 function(args=args)130 function(args=args)
130131
131if __name__ == '__main__':132if __name__ == '__main__':
132133
=== modified file 'setup.py'
--- setup.py 2012-12-03 15:49:35 +0000
+++ setup.py 2012-12-08 02:12:21 +0000
@@ -42,9 +42,10 @@
42 maintainer = maintainer_info.rsplit('<', 1)[0].strip()42 maintainer = maintainer_info.rsplit('<', 1)[0].strip()
43 maintainer_email = maintainer_info.rsplit('<', 1)[1].strip('>')43 maintainer_email = maintainer_info.rsplit('<', 1)[1].strip('>')
4444
45setup(name='utah',45setup(
46 version=version,46 name='utah',
47 packages=find_packages(),47 version=version,
48 maintainer=maintainer,48 packages=find_packages(),
49 maintainer_email=maintainer_email,49 maintainer=maintainer,
50 maintainer_email=maintainer_email,
50)51)
5152
=== modified file 'tests/test_parser.py'
--- tests/test_parser.py 2012-12-06 16:30:34 +0000
+++ tests/test_parser.py 2012-12-08 02:12:21 +0000
@@ -26,6 +26,7 @@
26 good:26 good:
27"""27"""
2828
29
29class TestParser(unittest.TestCase):30class TestParser(unittest.TestCase):
30 def setUp(self):31 def setUp(self):
31 self.logfile = '/tmp/utah.yaml'32 self.logfile = '/tmp/utah.yaml'
3233
=== modified file 'utah/client/common.py'
--- utah/client/common.py 2012-12-06 16:30:34 +0000
+++ utah/client/common.py 2012-12-08 02:12:21 +0000
@@ -31,9 +31,9 @@
31import jsonschema31import jsonschema
3232
33from utah.client.exceptions import (33from utah.client.exceptions import (
34 YAMLParsingError,34 YAMLParsingError,
35 YAMLEmptyFile,35 YAMLEmptyFile,
36 )36)
3737
3838
39PASS = 039PASS = 0
@@ -138,7 +138,7 @@
138 time_delta=str(time_delta),138 time_delta=str(time_delta),
139 cmd_type=cmd_type,139 cmd_type=cmd_type,
140 user=run_as,140 user=run_as,
141 )141 )
142142
143 time_delta = datetime.datetime.now() - start_time143 time_delta = datetime.datetime.now() - start_time
144144
@@ -150,7 +150,7 @@
150 time_delta=str(time_delta),150 time_delta=str(time_delta),
151 cmd_type=cmd_type,151 cmd_type=cmd_type,
152 user=run_as,152 user=run_as,
153 )153 )
154154
155155
156def normalize_encoding(value, encoding='utf-8'):156def normalize_encoding(value, encoding='utf-8'):
@@ -394,9 +394,9 @@
394 uname = platform.uname()394 uname = platform.uname()
395395
396 arch = {396 arch = {
397 'x86_64': 'amd64',397 'x86_64': 'amd64',
398 'x86': 'i386',398 'x86': 'i386',
399 }.get(uname[5]) # 5 == processor399 }.get(uname[5]) # 5 == processor
400400
401 return arch401 return arch
402402
@@ -404,7 +404,7 @@
404def get_arch():404def get_arch():
405 """405 """
406 The host's architecture.406 The host's architecture.
407 407
408 Returns the human readable architecture or 'unknown'.408 Returns the human readable architecture or 'unknown'.
409 """409 """
410 arches = {410 arches = {
@@ -415,6 +415,7 @@
415415
416 return arches.get(platform.machine(), 'unknown')416 return arches.get(platform.machine(), 'unknown')
417417
418
418def get_release():419def get_release():
419 """420 """
420 The host's release name (i.e. precise, quantal, etc.)421 The host's release name (i.e. precise, quantal, etc.)
@@ -493,18 +494,18 @@
493494
494 if branch:495 if branch:
495 self.get_command = "bzr branch {} {} {}".format(496 self.get_command = "bzr branch {} {} {}".format(
496 options,497 options,
497 self.repo,498 self.repo,
498 destination,499 destination,
499 )500 )
500501
501 self.rev_command = "bzr revno"502 self.rev_command = "bzr revno"
502 else:503 else:
503 self.get_command = "bzr export {} {} {}".format(504 self.get_command = "bzr export {} {} {}".format(
504 options,505 options,
505 destination,506 destination,
506 self.repo,507 self.repo,
507 )508 )
508509
509 self.rev_command = "bzr revno {}".format(self.repo)510 self.rev_command = "bzr revno {}".format(self.repo)
510511
@@ -520,13 +521,14 @@
520 self.destination = destination521 self.destination = destination
521522
522 self.get_command = "git clone {} {} {}".format(523 self.get_command = "git clone {} {} {}".format(
523 options,524 options,
524 self.repo,525 self.repo,
525 destination,526 destination,
526 )527 )
527528
528 self.rev_command = "git rev-parse HEAD"529 self.rev_command = "git rev-parse HEAD"
529530
531
530class DevHandler(VCSHandler):532class DevHandler(VCSHandler):
531 """ Copy from a local directory for development. """533 """ Copy from a local directory for development. """
532534
@@ -535,8 +537,8 @@
535 self.destination = destination537 self.destination = destination
536538
537 self.get_command = "cp -r {} {}".format(539 self.get_command = "cp -r {} {}".format(
538 self.repo,540 self.repo,
539 destination,541 destination,
540 )542 )
541543
542 self.rev_command = "echo 'DEVELOPMENT'"544 self.rev_command = "echo 'DEVELOPMENT'"
543545
=== modified file 'utah/client/phoenix.py'
--- utah/client/phoenix.py 2012-12-03 15:49:35 +0000
+++ utah/client/phoenix.py 2012-12-08 02:12:21 +0000
@@ -51,26 +51,26 @@
51timeout: 6051timeout: 60
52command: {0}52command: {0}
53run_as: {0}53run_as: {0}
54#build_cmd: 54#build_cmd:
55#tc_setup: 55#tc_setup:
56#tc_cleanup: 56#tc_cleanup:
57""".format(CHANGEME)57""".format(CHANGEME)
58 self.master_run_content = """---58 self.master_run_content = """---
59testsuites:59testsuites:
60"""60"""
6161
62 self.FILE_CONTENT = {62 self.FILE_CONTENT = {
63 TSLIST_NAME: self.tslist_content,63 TSLIST_NAME: self.tslist_content,
64 TS_CONTROL_NAME: self.ts_control_content,64 TS_CONTROL_NAME: self.ts_control_content,
65 TC_CONTROL_NAME: self.tc_control_content,65 TC_CONTROL_NAME: self.tc_control_content,
66 MASTER_NAME: self.master_run_content,66 MASTER_NAME: self.master_run_content,
67 }67 }
6868
69 self.FILES = [69 self.FILES = [
70 TSLIST_NAME,70 TSLIST_NAME,
71 TS_CONTROL_NAME,71 TS_CONTROL_NAME,
72 MASTER_NAME,72 MASTER_NAME,
73 ]73 ]
74 # Add testcase files74 # Add testcase files
75 for d in self.testcases:75 for d in self.testcases:
76 self.FILES.append(os.path.join(d, TC_CONTROL_NAME))76 self.FILES.append(os.path.join(d, TC_CONTROL_NAME))
@@ -78,9 +78,9 @@
7878
79 self.FILE_CONTENT[MASTER_NAME] += " - name: {}\n".format(testsuite)79 self.FILE_CONTENT[MASTER_NAME] += " - name: {}\n".format(testsuite)
80 self.FILE_CONTENT[MASTER_NAME] += \80 self.FILE_CONTENT[MASTER_NAME] += \
81 " fetch_method: {} # one of 'bzr', 'bzr-export', 'dev', 'git'\n".format(CHANGEME)81 " fetch_method: {} # one of 'bzr', 'bzr-export', 'dev', 'git'\n".format(CHANGEME)
82 self.FILE_CONTENT[MASTER_NAME] += \82 self.FILE_CONTENT[MASTER_NAME] += \
83 " fetch_location: {}\n".format(CHANGEME)83 " fetch_location: {}\n".format(CHANGEME)
8484
85 def debug(self):85 def debug(self):
86 for f in self.FILE_CONTENT.keys():86 for f in self.FILE_CONTENT.keys():
@@ -112,7 +112,8 @@
112112
113 # create the tslist.run file113 # create the tslist.run file
114 tslist_file = os.path.join(ts_dir, TSLIST_NAME)114 tslist_file = os.path.join(ts_dir, TSLIST_NAME)
115 self.create_file(tslist_file, self.FILE_CONTENT[TSLIST_NAME], append_if_exists=True)115 self.create_file(tslist_file, self.FILE_CONTENT[TSLIST_NAME],
116 append_if_exists=True)
116117
117 # create the test case directories118 # create the test case directories
118 for tc in self.testcases:119 for tc in self.testcases:
@@ -130,18 +131,18 @@
130131
131 parser = argparse.ArgumentParser(description='phoenix bootstrapper')132 parser = argparse.ArgumentParser(description='phoenix bootstrapper')
132 parser.add_argument('testsuite', metavar='TESTSUITE', type=str, nargs=1,133 parser.add_argument('testsuite', metavar='TESTSUITE', type=str, nargs=1,
133 help='name of the testsuite to create')134 help='name of the testsuite to create')
134 parser.add_argument('testcases', metavar='TESTCASE', type=str, nargs='*',135 parser.add_argument('testcases', metavar='TESTCASE', type=str, nargs='*',
135 help='names of testcases to create')136 help='names of testcases to create')
136 parser.add_argument('--directory', '-D', dest='directory', default='.',137 parser.add_argument('--directory', '-D', dest='directory', default='.',
137 help='where to create the testsuite')138 help='where to create the testsuite')
138139
139 args = parser.parse_args()140 args = parser.parse_args()
140141
141 phoenix = Phoenix(args.testsuite[0],142 phoenix = Phoenix(args.testsuite[0],
142 directory=args.directory,143 directory=args.directory,
143 testcases=args.testcases,144 testcases=args.testcases,
144 )145 )
145 phoenix.build_suite()146 phoenix.build_suite()
146147
147if __name__ == "__main__":148if __name__ == "__main__":
148149
=== modified file 'utah/client/result.py'
--- utah/client/result.py 2012-12-06 16:30:34 +0000
+++ utah/client/result.py 2012-12-08 02:12:21 +0000
@@ -18,11 +18,11 @@
18import yaml18import yaml
1919
20from .common import (20from .common import (
21 get_host_info,21 get_host_info,
22 get_build_number,22 get_build_number,
23 get_release,23 get_release,
24 get_arch,24 get_arch,
25 )25)
2626
2727
28def get_smoke_data(_result):28def get_smoke_data(_result):
@@ -48,9 +48,9 @@
48 return None48 return None
4949
50 type_map = {50 type_map = {
51 'smoke': get_smoke_data,51 'smoke': get_smoke_data,
52 'kernel-sru': get_kernel_sru_data,52 'kernel-sru': get_kernel_sru_data,
53 }53 }
5454
55 if publish_type and publish_type in type_map.iterkeys():55 if publish_type and publish_type in type_map.iterkeys():
56 return type_map[publish_type](result)56 return type_map[publish_type](result)
@@ -61,7 +61,7 @@
61 Result collection class.61 Result collection class.
62 """62 """
63 def __init__(self, name=None, testsuite=None, testcase=None,63 def __init__(self, name=None, testsuite=None, testcase=None,
64 runlist=None, publish_type=None, install_type=None):64 runlist=None, publish_type=None, install_type=None):
65 self.results = []65 self.results = []
66 self.status = 'PASS'66 self.status = 'PASS'
67 self.name = name67 self.name = name
@@ -188,20 +188,20 @@
188 """188 """
189 host_info = get_host_info()189 host_info = get_host_info()
190 data = {190 data = {
191 'runlist': self.runlist,191 'runlist': self.runlist,
192 'commands': self.results,192 'commands': self.results,
193 'errors': self.errors,193 'errors': self.errors,
194 'failures': self.failures,194 'failures': self.failures,
195 'fetch_errors': self.fetch_errors,195 'fetch_errors': self.fetch_errors,
196 'passes': self.passes,196 'passes': self.passes,
197 'uname': list(host_info['uname']),197 'uname': list(host_info['uname']),
198 'media-info': host_info['media-info'],198 'media-info': host_info['media-info'],
199 'install_type': self.install_type,199 'install_type': self.install_type,
200 'build_number': get_build_number(),200 'build_number': get_build_number(),
201 'release': get_release(),201 'release': get_release(),
202 'ran_at': self.results[0]['start_time'],202 'ran_at': self.results[0]['start_time'],
203 'arch': get_arch(),203 'arch': get_arch(),
204 'name': self.name,204 'name': self.name,
205 }205 }
206206
207 if self.publish is not None:207 if self.publish is not None:
208208
=== modified file 'utah/client/runner.py'
--- utah/client/runner.py 2012-12-06 16:30:34 +0000
+++ utah/client/runner.py 2012-12-08 02:12:21 +0000
@@ -26,15 +26,15 @@
26import jsonschema26import jsonschema
2727
28from utah.client.common import (28from utah.client.common import (
29 MASTER_RUNLIST,29 MASTER_RUNLIST,
30 UTAH_DIR,30 UTAH_DIR,
31 DEFAULT_STATE_FILE,31 DEFAULT_STATE_FILE,
32 RETURN_CODES,32 RETURN_CODES,
33 parse_yaml_file,33 parse_yaml_file,
34 BzrHandler,34 BzrHandler,
35 DevHandler,35 DevHandler,
36 GitHandler,36 GitHandler,
37 )37)
3838
39RC_LOCAL = '/etc/rc.local'39RC_LOCAL = '/etc/rc.local'
40RC_LOCAL_BACKUP = '%s-utah.bak' % RC_LOCAL40RC_LOCAL_BACKUP = '%s-utah.bak' % RC_LOCAL
@@ -63,24 +63,24 @@
63 'name': {63 'name': {
64 'type': 'string',64 'type': 'string',
65 'required': True,65 'required': True,
66 },66 },
67 'fetch_method': {67 'fetch_method': {
68 'type': 'string',68 'type': 'string',
69 'enum': ['bzr', 'bzr-export', 'dev', 'git'],69 'enum': ['bzr', 'bzr-export', 'dev', 'git'],
70 'required': True,70 'required': True,
71 },71 },
72 'fetch_location': {72 'fetch_location': {
73 'type': 'string',73 'type': 'string',
74 'required': True,74 'required': True,
75 },75 },
76 'include_tests': {76 'include_tests': {
77 'type': 'array',77 'type': 'array',
78 'items': {'type': 'string'},78 'items': {'type': 'string'},
79 },79 },
80 'exclude_tests': {80 'exclude_tests': {
81 'type': 'array',81 'type': 'array',
82 'items': {'type': 'string'},82 'items': {'type': 'string'},
83 },83 },
84 },84 },
85 }85 }
8686
@@ -99,7 +99,7 @@
99 'items': {99 'items': {
100 'type': [TESTSUITE_ENTRY_SCHEMA, TESTSUITE_INCLUDE_SCHEMA],100 'type': [TESTSUITE_ENTRY_SCHEMA, TESTSUITE_INCLUDE_SCHEMA],
101 'required': True,101 'required': True,
102 },102 },
103 }103 }
104104
105 MASTER_RUNLIST_SCHEMA_NEW = {105 MASTER_RUNLIST_SCHEMA_NEW = {
@@ -108,33 +108,33 @@
108 "timeout": {108 "timeout": {
109 "type": "integer",109 "type": "integer",
110 "minimum": 0,110 "minimum": 0,
111 },111 },
112 "repeat_count": {112 "repeat_count": {
113 "type": "integer",113 "type": "integer",
114 "minimum": 0,114 "minimum": 0,
115 },115 },
116 "type": {116 "type": {
117 'type': 'string',117 'type': 'string',
118 'enum': ['smoke', 'kernel-sru', 'bootspeed', 'upgrade'],118 'enum': ['smoke', 'kernel-sru', 'bootspeed', 'upgrade'],
119 },119 },
120 "name": {120 "name": {
121 'type': 'string',121 'type': 'string',
122 },122 },
123 "testsuites": {123 "testsuites": {
124 # must be a list to accept a schema rather than a simple type124 # must be a list to accept a schema rather than a simple type
125 "type": [MASTER_RUNLIST_SCHEMA_ORIG],125 "type": [MASTER_RUNLIST_SCHEMA_ORIG],
126 "required": True,126 "required": True,
127 },127 },
128 }
129 }128 }
129 }
130130
131 MASTER_RUNLIST_SCHEMA = {131 MASTER_RUNLIST_SCHEMA = {
132 'type': [MASTER_RUNLIST_SCHEMA_ORIG, MASTER_RUNLIST_SCHEMA_NEW],132 'type': [MASTER_RUNLIST_SCHEMA_ORIG, MASTER_RUNLIST_SCHEMA_NEW],
133 'required': True,133 'required': True,
134 }134 }
135135
136 def __init__(self, install_type, runlist=None, result_class=Result,136 def __init__(self, install_type, runlist=None, result_class=Result,
137 testdir=UTAH_DIR, state_agent=None, resume=False):137 testdir=UTAH_DIR, state_agent=None, resume=False):
138138
139 # Runlist URL passed through the command line139 # Runlist URL passed through the command line
140 self.testdir = testdir140 self.testdir = testdir
@@ -318,8 +318,9 @@
318318
319 self.backup_runlist = os.path.join(self.testdir, 'master.run-reboot')319 self.backup_runlist = os.path.join(self.testdir, 'master.run-reboot')
320320
321 if (os.path.exists(self.master_runlist)321 if (os.path.exists(
322 and self.master_runlist != self.backup_runlist):322 self.master_runlist)
323 and self.master_runlist != self.backup_runlist):
323 shutil.copyfile(self.master_runlist, self.backup_runlist)324 shutil.copyfile(self.master_runlist, self.backup_runlist)
324325
325 state = {326 state = {
@@ -374,9 +375,9 @@
374 jsonschema.validate(data, self.MASTER_RUNLIST_SCHEMA)375 jsonschema.validate(data, self.MASTER_RUNLIST_SCHEMA)
375 except jsonschema.ValidationError as exception:376 except jsonschema.ValidationError as exception:
376 raise exceptions.ValidationError(377 raise exceptions.ValidationError(
377 'Master runlist failed to validate: {!r}\n'378 'Master runlist failed to validate: {!r}\n'
378 'Detailed information: {}'379 'Detailed information: {}'
379 .format(local_filename, exception))380 .format(local_filename, exception))
380381
381 if 'timeout' in data:382 if 'timeout' in data:
382 self.timeout = int(data['timeout'])383 self.timeout = int(data['timeout'])
@@ -417,7 +418,7 @@
417 vcs_handler = BzrHandler(repo=fetch_location, destination=name)418 vcs_handler = BzrHandler(repo=fetch_location, destination=name)
418 elif fetch_method == 'bzr-export':419 elif fetch_method == 'bzr-export':
419 vcs_handler = BzrHandler(branch=False,420 vcs_handler = BzrHandler(branch=False,
420 repo=fetch_location, destination=name)421 repo=fetch_location, destination=name)
421 elif fetch_method == 'dev':422 elif fetch_method == 'dev':
422 vcs_handler = DevHandler(repo=fetch_location, destination=name)423 vcs_handler = DevHandler(repo=fetch_location, destination=name)
423 else:424 else:
@@ -467,7 +468,6 @@
467 _reboot_callback=self.reboot)468 _reboot_callback=self.reboot)
468 self.add_suite(s)469 self.add_suite(s)
469470
470
471 def get_next_suite(self):471 def get_next_suite(self):
472 """472 """
473 Return the next suite to be run.473 Return the next suite to be run.
474474
=== modified file 'utah/client/testcase.py'
--- utah/client/testcase.py 2012-12-06 16:30:34 +0000
+++ utah/client/testcase.py 2012-12-08 02:12:21 +0000
@@ -19,19 +19,19 @@
19import jsonschema19import jsonschema
2020
21from utah.client.common import (21from utah.client.common import (
22 run_cmd,22 run_cmd,
23 parse_control_file,23 parse_control_file,
24 do_nothing,24 do_nothing,
25 CMD_TC_BUILD,25 CMD_TC_BUILD,
26 CMD_TC_SETUP,26 CMD_TC_SETUP,
27 CMD_TC_TEST,27 CMD_TC_TEST,
28 CMD_TC_CLEANUP,28 CMD_TC_CLEANUP,
29 )29)
30from utah.client.exceptions import (30from utah.client.exceptions import (
31 MissingFile,31 MissingFile,
32 ValidationError,32 ValidationError,
33 MissingData,33 MissingData,
34 )34)
3535
3636
37class TestCase(object):37class TestCase(object):
@@ -42,7 +42,7 @@
42 """42 """
4343
44 status = 'NOTRUN'44 status = 'NOTRUN'
45 summary = 'PASS' # 'PASS', 'FAIL', of 'ERROR'45 summary = 'PASS' # 'PASS', 'FAIL', of 'ERROR'
46 build_cmd = None46 build_cmd = None
47 tc_setup = None47 tc_setup = None
48 tc_cleanup = None48 tc_cleanup = None
@@ -57,41 +57,41 @@
57 'description': {57 'description': {
58 'type': 'string',58 'type': 'string',
59 'required': True,59 'required': True,
60 },60 },
61 'dependencies': {61 'dependencies': {
62 'type': 'string',62 'type': 'string',
63 'required': True,63 'required': True,
64 },64 },
65 'action': {65 'action': {
66 'type': 'string',66 'type': 'string',
67 'required': True,67 'required': True,
68 },68 },
69 'expected_results': {69 'expected_results': {
70 'type': 'string',70 'type': 'string',
71 'required': True,71 'required': True,
72 },72 },
73 'type': {73 'type': {
74 'type': 'string',74 'type': 'string',
75 'enum': ['userland']75 'enum': ['userland']
76 },76 },
77 'timeout': {'type': 'integer'},77 'timeout': {'type': 'integer'},
78 'build_cmd': {'type': 'string'},78 'build_cmd': {'type': 'string'},
79 'command': {79 'command': {
80 'type': 'string',80 'type': 'string',
81 'required': True,81 'required': True,
82 },82 },
83 'run_as': {83 'run_as': {
84 'type': 'string',84 'type': 'string',
85 'required': True,85 'required': True,
86 },86 },
87 'tc_setup': {'type': 'string'},87 'tc_setup': {'type': 'string'},
88 'tc_cleanup': {'type': 'string'},88 'tc_cleanup': {'type': 'string'},
89 'reboot': {89 'reboot': {
90 'type': 'string',90 'type': 'string',
91 'enum': ['always', 'pass', 'never'],91 'enum': ['always', 'pass', 'never'],
92 },
93 },92 },
94 }93 },
94 }
9595
96 def __init__(self, name, path, result, command=None, timeout=None,96 def __init__(self, name, path, result, command=None, timeout=None,
97 _control_data=None, _save_state_callback=None,97 _control_data=None, _save_state_callback=None,
@@ -131,9 +131,9 @@
131 self.CONTROL_SCHEMA)131 self.CONTROL_SCHEMA)
132 except jsonschema.ValidationError as exception:132 except jsonschema.ValidationError as exception:
133 raise ValidationError(133 raise ValidationError(
134 '{!r} test case control file invalid: {!r}\n'134 '{!r} test case control file invalid: {!r}\n'
135 'Detailed information: {}'135 'Detailed information: {}'
136 .format(self.name, self.filename, exception))136 .format(self.name, self.filename, exception))
137 else:137 else:
138 raise MissingFile(self.filename)138 raise MissingFile(self.filename)
139 else:139 else:
@@ -239,20 +239,20 @@
239 self.status = "RUN"239 self.status = "RUN"
240 self.save_state_callback()240 self.save_state_callback()
241 extra_info = {241 extra_info = {
242 'description': self.description,242 'description': self.description,
243 'dependencies': self.dependencies,243 'dependencies': self.dependencies,
244 'action': self.action,244 'action': self.action,
245 'expected_results': self.expected_results,245 'expected_results': self.expected_results,
246 }246 }
247 result.add_result(run_cmd(self.command,247 result.add_result(run_cmd(self.command,
248 timeout=timeout,248 timeout=timeout,
249 cwd=self.working_dir,249 cwd=self.working_dir,
250 cmd_type=CMD_TC_TEST,250 cmd_type=CMD_TC_TEST,
251 run_as=self.run_as,251 run_as=self.run_as,
252 ),252 ),
253 extra_info=extra_info)253 extra_info=extra_info)
254254
255 # only if we haven't failed or errored so far do 255 # only if we haven't failed or errored so far do
256 # we set the summary for the testcase.256 # we set the summary for the testcase.
257 if self.summary == 'PASS':257 if self.summary == 'PASS':
258 self.summary = result.status258 self.summary = result.status
@@ -261,9 +261,11 @@
261 self.cleanup(result)261 self.cleanup(result)
262262
263 need_reboot = False263 need_reboot = False
264 if (self.reboot == 'always'264 if (
265 or self.reboot == 'pass'265 self.reboot == 'always'
266 and result.status == 'PASS'):266 or self.reboot == 'pass'
267 and result.status == 'PASS'
268 ):
267 need_reboot = True269 need_reboot = True
268270
269 result.status = 'PASS'271 result.status = 'PASS'
@@ -299,20 +301,20 @@
299 Returns a dictionary representing the test's state.301 Returns a dictionary representing the test's state.
300 """302 """
301 state = {303 state = {
302 'name': self.name,304 'name': self.name,
303 'path': self.path,305 'path': self.path,
304 'command': self.command,306 'command': self.command,
305 'timeout': self.timeout,307 'timeout': self.timeout,
306 'status': self.status,308 'status': self.status,
307 'summary': self.summary,309 'summary': self.summary,
308 'build_cmd': self.build_cmd,310 'build_cmd': self.build_cmd,
309 'tc_setup': self.tc_setup,311 'tc_setup': self.tc_setup,
310 'tc_cleanup': self.tc_cleanup,312 'tc_cleanup': self.tc_cleanup,
311 'type': self.type,313 'type': self.type,
312 'description': self.description,314 'description': self.description,
313 'dependencies': self.dependencies,315 'dependencies': self.dependencies,
314 'action': self.action,316 'action': self.action,
315 'expected_results': self.expected_results,317 'expected_results': self.expected_results,
316 }318 }
317319
318 return state320 return state
319321
=== modified file 'utah/client/tests/__init__.py'
--- utah/client/tests/__init__.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/__init__.py 2012-12-08 02:12:21 +0000
@@ -12,4 +12,3 @@
1212
13# You should have received a copy of the GNU General Public License along13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15
1615
=== modified file 'utah/client/tests/common.py'
--- utah/client/tests/common.py 2012-12-06 16:30:34 +0000
+++ utah/client/tests/common.py 2012-12-08 02:12:21 +0000
@@ -105,6 +105,7 @@
105 if os.path.exists(examples_dir):105 if os.path.exists(examples_dir):
106 shutil.rmtree(examples_dir)106 shutil.rmtree(examples_dir)
107107
108
108def _get_partial_state_file(filename):109def _get_partial_state_file(filename):
109 """110 """
110 Read a partial state file from disk.111 Read a partial state file from disk.
@@ -118,16 +119,16 @@
118 return state119 return state
119120
120partial_state_file_content = _get_partial_state_file(121partial_state_file_content = _get_partial_state_file(
121 os.path.join(os.path.dirname(__file__), "..", "examples",122 os.path.join(os.path.dirname(__file__), "..", "examples",
122 "test_state_partial_inprogress.yaml")123 "test_state_partial_inprogress.yaml")
123)124)
124125
125partial_state_file_content_run_all = _get_partial_state_file(126partial_state_file_content_run_all = _get_partial_state_file(
126 os.path.join(os.path.dirname(__file__), "..", "examples",127 os.path.join(os.path.dirname(__file__), "..", "examples",
127 "test_state_partial_run_all.yaml")128 "test_state_partial_run_all.yaml")
128)129)
129130
130partial_state_file_content_done_all_failed = _get_partial_state_file(131partial_state_file_content_done_all_failed = _get_partial_state_file(
131 os.path.join(os.path.dirname(__file__), "..", "examples",132 os.path.join(os.path.dirname(__file__), "..", "examples",
132 "test_state_partial_all_failed.yaml")133 "test_state_partial_all_failed.yaml")
133)134)
134135
=== modified file 'utah/client/tests/manual_privileges.py'
--- utah/client/tests/manual_privileges.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/manual_privileges.py 2012-12-08 02:12:21 +0000
@@ -87,7 +87,7 @@
8787
88def stat_file(filename=TMP_FILENAME):88def stat_file(filename=TMP_FILENAME):
89 proc = subprocess.Popen(['ls', '-al', filename], stdout=subprocess.PIPE,89 proc = subprocess.Popen(['ls', '-al', filename], stdout=subprocess.PIPE,
90 stderr=subprocess.PIPE)90 stderr=subprocess.PIPE)
9191
92 stdout, _stderr = proc.communicate()92 stdout, _stderr = proc.communicate()
93 print("{}: {}".format(filename, stdout))93 print("{}: {}".format(filename, stdout))
@@ -183,6 +183,6 @@
183 'euid': NOBODY_UID,183 'euid': NOBODY_UID,
184 'gid': NOGROUP_GID,184 'gid': NOGROUP_GID,
185 'egid': NOGROUP_GID,185 'egid': NOGROUP_GID,
186 })186 })
187187
188 _do_cmd("id")188 _do_cmd("id")
189189
=== modified file 'utah/client/tests/test_common.py'
--- utah/client/tests/test_common.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_common.py 2012-12-08 02:12:21 +0000
@@ -18,13 +18,13 @@
1818
19# REQUIRES that the top level utah package be in the Python path.19# REQUIRES that the top level utah package be in the Python path.
20from utah.client.common import (20from utah.client.common import (
21 get_media_info,21 get_media_info,
22 get_product_uuid,22 get_product_uuid,
23 get_host_info,23 get_host_info,
24 run_cmd,24 run_cmd,
25 debug_print,25 debug_print,
26 CONFIG,26 CONFIG,
27 )27)
2828
2929
30class TestCommon(unittest.TestCase):30class TestCommon(unittest.TestCase):
3131
=== modified file 'utah/client/tests/test_jsonschema.py'
--- utah/client/tests/test_jsonschema.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_jsonschema.py 2012-12-08 02:12:21 +0000
@@ -54,28 +54,28 @@
54"""54"""
5555
56yaml_content_bad = [56yaml_content_bad = [
57"""---57 """---
58testsuties:58testsuties:
59 - name: testsuite159 - name: testsuite1
60 fetch_method: bzr60 fetch_method: bzr
61 fetch_location: lp:utah61 fetch_location: lp:utah
62""", # typo62""", # typo
63"""---63 """---
64timeout: 10164timeout: 101
65repeat_count: 9965repeat_count: 99
66""", # missing testsuites66""", # missing testsuites
67"""---67 """---
68- name: blah68- name: blah
69- name: blip69- name: blip
70""", # missing fetch options70""", # missing fetch options
71"""---71 """---
72testsuites:72testsuites:
73 - name: blah73 - name: blah
74 - name: blip74 - name: blip
75""", # missing fetch options75""", # missing fetch options
76"""---76 """---
77testsuites:77testsuites:
78""", # no testsuites78""", # no testsuites
79]79]
8080
8181
8282
=== modified file 'utah/client/tests/test_phoenix.py'
--- utah/client/tests/test_phoenix.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_phoenix.py 2012-12-08 02:12:21 +0000
@@ -39,19 +39,19 @@
3939
40 def setUp(self):40 def setUp(self):
41 self.phoenix = Phoenix(41 self.phoenix = Phoenix(
42 self.testsuite_name,42 self.testsuite_name,
43 directory=self.directory_name,43 directory=self.directory_name,
44 testcases=self.testcases,44 testcases=self.testcases,
45 )45 )
4646
47 def test_missing_required_args(self):47 def test_missing_required_args(self):
48 """48 """
49 Test that __init__ fails without the required arguments49 Test that __init__ fails without the required arguments
50 """50 """
51 self.assertRaises(51 self.assertRaises(
52 TypeError,52 TypeError,
53 Phoenix,53 Phoenix,
54 )54 )
5555
56 def test_providing_required_args(self):56 def test_providing_required_args(self):
57 """57 """
@@ -109,13 +109,13 @@
109 tc_paths.append(os.path.join(ts_path, tc))109 tc_paths.append(os.path.join(ts_path, tc))
110110
111 self.assertTrue(os.path.exists(dir_path),111 self.assertTrue(os.path.exists(dir_path),
112 "{} doesn't exist".format(dir_path))112 "{} doesn't exist".format(dir_path))
113 self.assertTrue(os.path.exists(ts_path),113 self.assertTrue(os.path.exists(ts_path),
114 "{} doesn't exist".format(ts_path))114 "{} doesn't exist".format(ts_path))
115115
116 for path in tc_paths:116 for path in tc_paths:
117 self.assertTrue(os.path.exists(path),117 self.assertTrue(os.path.exists(path),
118 "{} doesn't exist".format(path))118 "{} doesn't exist".format(path))
119119
120 def test_create_file(self):120 def test_create_file(self):
121 """121 """
122122
=== modified file 'utah/client/tests/test_result.py'
--- utah/client/tests/test_result.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_result.py 2012-12-08 02:12:21 +0000
@@ -17,9 +17,9 @@
17import yaml17import yaml
1818
19from utah.client.result import (19from utah.client.result import (
20 Result,20 Result,
21 ResultYAML,21 ResultYAML,
22 )22)
2323
2424
25class TestResult(unittest.TestCase):25class TestResult(unittest.TestCase):
2626
=== modified file 'utah/client/tests/test_runner.py'
--- utah/client/tests/test_runner.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_runner.py 2012-12-08 02:12:21 +0000
@@ -24,12 +24,13 @@
24from utah.client.common import RETURN_CODES24from utah.client.common import RETURN_CODES
25from utah.client import exceptions25from utah.client import exceptions
2626
27from .common import ( # NOQA27from .common import (
28 setUp, # Used by nosetests28 # NOQA
29 tearDown, # Used by nosetests29 setUp, # Used by nosetests
30 master_runlist_content,30 tearDown, # Used by nosetests
31 get_module_path,31 master_runlist_content,
32 )32 get_module_path,
33)
3334
3435
35class TestRunner(unittest.TestCase):36class TestRunner(unittest.TestCase):
@@ -43,7 +44,7 @@
43 self.bad_dir = "/tmp/does_not_exist"44 self.bad_dir = "/tmp/does_not_exist"
4445
45 self.assertFalse(os.path.exists(self.bad_dir),46 self.assertFalse(os.path.exists(self.bad_dir),
46 "{} shouldn't exist".format(self.bad_dir))47 "{} shouldn't exist".format(self.bad_dir))
4748
48 def tearDown(self):49 def tearDown(self):
4950
@@ -73,7 +74,7 @@
73 fp.close()74 fp.close()
7475
75 runner = Runner(install_type='desktop', result_class=self.result_class,76 runner = Runner(install_type='desktop', result_class=self.result_class,
76 state_agent=self.state_agent, runlist=runlist)77 state_agent=self.state_agent, runlist=runlist)
7778
78 # remove the runlist as early as possible to avoid leaving it79 # remove the runlist as early as possible to avoid leaving it
79 # laying around if this test fails.80 # laying around if this test fails.
8081
=== modified file 'utah/client/tests/test_state_agent.py'
--- utah/client/tests/test_state_agent.py 2012-12-06 16:30:34 +0000
+++ utah/client/tests/test_state_agent.py 2012-12-08 02:12:21 +0000
@@ -23,15 +23,15 @@
23from utah.client.result import ResultYAML23from utah.client.result import ResultYAML
24from utah.client.common import UTAH_DIR24from utah.client.common import UTAH_DIR
2525
26from .common import ( # NOQA26from .common import (
27 setUp, # Used by nosetests27 # NOQA
28 tearDown, # Used by nosetests28 setUp, # Used by nosetests
29 get_module_path,29 tearDown, # Used by nosetests
30 partial_state_file_content,30 get_module_path,
31 partial_state_file_content_run_all,31 partial_state_file_content,
32 partial_state_file_content_done_all_failed,32 partial_state_file_content_run_all,
33 )33 partial_state_file_content_done_all_failed,
3434)
3535
3636
37class TestStateAgentYAML(unittest.TestCase):37class TestStateAgentYAML(unittest.TestCase):
@@ -42,15 +42,19 @@
42 self.state_file = '/tmp/state.yaml'42 self.state_file = '/tmp/state.yaml'
4343
44 # Fail if there is already a test state file.44 # Fail if there is already a test state file.
45 self.assertFalse(os.path.exists(self.state_file),45 self.assertFalse(
46 "state file (%s) already exists" % self.state_file)46 os.path.exists(self.state_file),
47 "state file (%s) already exists" % self.state_file)
4748
48 self.state_agent = StateAgentYAML(state_file=self.state_file)49 self.state_agent = StateAgentYAML(state_file=self.state_file)
49 self.runner = Runner(install_type="desktop", result_class=ResultYAML,50 self.runner = Runner(
50 state_agent=self.state_agent)51 install_type="desktop", result_class=ResultYAML,
52 state_agent=self.state_agent)
51 self.partial_state_file_content = partial_state_file_content53 self.partial_state_file_content = partial_state_file_content
52 self.partial_state_file_content_run_all = partial_state_file_content_run_all54 self.partial_state_file_content_run_all = \
53 self.partial_state_file_content_done_all_failed = partial_state_file_content_done_all_failed55 partial_state_file_content_run_all
56 self.partial_state_file_content_done_all_failed = \
57 partial_state_file_content_done_all_failed
5458
55 def tearDown(self):59 def tearDown(self):
56 """60 """
@@ -112,7 +116,7 @@
112116
113 # Need to set up utah_tests since we're simulating a restart117 # Need to set up utah_tests since we're simulating a restart
114 test_src = os.path.join(get_module_path(), 'client',118 test_src = os.path.join(get_module_path(), 'client',
115 'examples', 'utah_tests')119 'examples', 'utah_tests')
116 test_dir = os.path.join(UTAH_DIR, 'testsuites',120 test_dir = os.path.join(UTAH_DIR, 'testsuites',
117 'utah_tests', 'utah_tests')121 'utah_tests', 'utah_tests')
118 if not os.path.exists(test_dir):122 if not os.path.exists(test_dir):
@@ -120,17 +124,18 @@
120124
121 # Need to set up utah_tests_sample since we're simulating a restart125 # Need to set up utah_tests_sample since we're simulating a restart
122 test_src = os.path.join(get_module_path(), 'client',126 test_src = os.path.join(get_module_path(), 'client',
123 'examples', 'utah_tests_sample')127 'examples', 'utah_tests_sample')
124 test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests_sample',128 test_dir = os.path.join(UTAH_DIR, 'testsuites',
125 'utah_tests_sample')129 'utah_tests_sample', 'utah_tests_sample')
126 if not os.path.exists(test_dir):130 if not os.path.exists(test_dir):
127 shutil.copytree(test_src, test_dir)131 shutil.copytree(test_src, test_dir)
128132
129 state_agent = StateAgentYAML(state_file=self.state_file)133 state_agent = StateAgentYAML(state_file=self.state_file)
130 runner = Runner(install_type="desktop",134 runner = Runner(
131 state_agent=state_agent,135 install_type="desktop",
132 result_class=ResultYAML,136 state_agent=state_agent,
133 resume=True)137 result_class=ResultYAML,
138 resume=True)
134139
135 self.assertEqual(runner.status, 'RUN')140 self.assertEqual(runner.status, 'RUN')
136 self.assertEqual(runner.count_suites(), 3)141 self.assertEqual(runner.count_suites(), 3)
@@ -157,7 +162,7 @@
157162
158 # Need to set up utah_tests since we're simulating a restart163 # Need to set up utah_tests since we're simulating a restart
159 test_src = os.path.join(get_module_path(), 'client',164 test_src = os.path.join(get_module_path(), 'client',
160 'examples', 'utah_tests')165 'examples', 'utah_tests')
161 test_dir = os.path.join(UTAH_DIR, 'testsuites',166 test_dir = os.path.join(UTAH_DIR, 'testsuites',
162 'utah_tests', 'utah_tests')167 'utah_tests', 'utah_tests')
163 if not os.path.exists(test_dir):168 if not os.path.exists(test_dir):
@@ -165,17 +170,17 @@
165170
166 # Need to set up utah_tests_sample since we're simulating a restart171 # Need to set up utah_tests_sample since we're simulating a restart
167 test_src = os.path.join(get_module_path(), 'client',172 test_src = os.path.join(get_module_path(), 'client',
168 'examples', 'utah_tests_sample')173 'examples', 'utah_tests_sample')
169 test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests_sample',174 test_dir = os.path.join(UTAH_DIR, 'testsuites',
170 'utah_tests_sample')175 'utah_tests_sample', 'utah_tests_sample')
171 if not os.path.exists(test_dir):176 if not os.path.exists(test_dir):
172 shutil.copytree(test_src, test_dir)177 shutil.copytree(test_src, test_dir)
173178
174 state_agent = StateAgentYAML(state_file=self.state_file)179 state_agent = StateAgentYAML(state_file=self.state_file)
175 runner = Runner(install_type="desktop",180 runner = Runner(install_type="desktop",
176 state_agent=state_agent,181 state_agent=state_agent,
177 result_class=ResultYAML,182 result_class=ResultYAML,
178 resume=True)183 resume=True)
179184
180 self.assertEqual(runner.status, 'RUN')185 self.assertEqual(runner.status, 'RUN')
181 self.assertEqual(runner.count_suites(), 3)186 self.assertEqual(runner.count_suites(), 3)
@@ -202,7 +207,7 @@
202207
203 # Need to set up utah_tests since we're simulating a restart208 # Need to set up utah_tests since we're simulating a restart
204 test_src = os.path.join(get_module_path(), 'client',209 test_src = os.path.join(get_module_path(), 'client',
205 'examples', 'utah_tests')210 'examples', 'utah_tests')
206 test_dir = os.path.join(UTAH_DIR, 'testsuites',211 test_dir = os.path.join(UTAH_DIR, 'testsuites',
207 'utah_tests', 'utah_tests')212 'utah_tests', 'utah_tests')
208 if not os.path.exists(test_dir):213 if not os.path.exists(test_dir):
@@ -210,17 +215,17 @@
210215
211 # Need to set up utah_tests_sample since we're simulating a restart216 # Need to set up utah_tests_sample since we're simulating a restart
212 test_src = os.path.join(get_module_path(), 'client',217 test_src = os.path.join(get_module_path(), 'client',
213 'examples', 'utah_tests_sample')218 'examples', 'utah_tests_sample')
214 test_dir = os.path.join(UTAH_DIR, 'testsuites', 'utah_tests_sample',219 test_dir = os.path.join(UTAH_DIR, 'testsuites',
215 'utah_tests_sample')220 'utah_tests_sample', 'utah_tests_sample')
216 if not os.path.exists(test_dir):221 if not os.path.exists(test_dir):
217 shutil.copytree(test_src, test_dir)222 shutil.copytree(test_src, test_dir)
218223
219 state_agent = StateAgentYAML(state_file=self.state_file)224 state_agent = StateAgentYAML(state_file=self.state_file)
220 runner = Runner(install_type="desktop",225 runner = Runner(install_type="desktop",
221 state_agent=state_agent,226 state_agent=state_agent,
222 result_class=ResultYAML,227 result_class=ResultYAML,
223 resume=True)228 resume=True)
224229
225 self.assertEqual(runner.status, 'RUN')230 self.assertEqual(runner.status, 'RUN')
226 self.assertEqual(runner.count_suites(), 3)231 self.assertEqual(runner.count_suites(), 3)
227232
=== modified file 'utah/client/tests/test_testcase.py'
--- utah/client/tests/test_testcase.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_testcase.py 2012-12-08 02:12:21 +0000
@@ -19,14 +19,15 @@
19from utah.client.exceptions import MissingData19from utah.client.exceptions import MissingData
20from utah.client.result import ResultYAML20from utah.client.result import ResultYAML
21from utah.client.common import (21from utah.client.common import (
22 UTAH_DIR,22 UTAH_DIR,
23 )23)
24from utah.client import testcase24from utah.client import testcase
2525
26from .common import ( # NOQA26from .common import (
27 setUp, # Used by nosetests27 # NOQA
28 tearDown, # Used by nosetests28 setUp, # Used by nosetests
29 )29 tearDown, # Used by nosetests
30)
3031
3132
32class TestTestCase(unittest.TestCase):33class TestTestCase(unittest.TestCase):
@@ -79,9 +80,9 @@
79 state = self.case.save_state()80 state = self.case.save_state()
8081
81 case = testcase.TestCase(82 case = testcase.TestCase(
82 name=self.name,83 name=self.name,
83 path=self.path,84 path=self.path,
84 result=ResultYAML()85 result=ResultYAML()
85 )86 )
86 case.load_state(state)87 case.load_state(state)
8788
@@ -99,10 +100,10 @@
99 def test_timeout_override(self):100 def test_timeout_override(self):
100 timeout = 99101 timeout = 99
101 case = testcase.TestCase(102 case = testcase.TestCase(
102 name=self.name,103 name=self.name,
103 path=self.path,104 path=self.path,
104 timeout=timeout,105 timeout=timeout,
105 result=ResultYAML()106 result=ResultYAML()
106 )107 )
107108
108 self.assertEqual(timeout, case.timeout)109 self.assertEqual(timeout, case.timeout)
@@ -113,21 +114,21 @@
113 doesn't raise an exception.114 doesn't raise an exception.
114 """115 """
115 control_data = {116 control_data = {
116 'description': 'a test case',117 'description': 'a test case',
117 'command': '/bin/true',118 'command': '/bin/true',
118 'dependencies': 'n/a',119 'dependencies': 'n/a',
119 'action': 'n/a',120 'action': 'n/a',
120 'expected_results': 'n/a',121 'expected_results': 'n/a',
121 }122 }
122123
123 result = ResultYAML()124 result = ResultYAML()
124125
125 case = testcase.TestCase(126 case = testcase.TestCase(
126 name=self.name,127 name=self.name,
127 path=self.path,128 path=self.path,
128 result=result,129 result=result,
129 _control_data=control_data,130 _control_data=control_data,
130 )131 )
131132
132 case.run()133 case.run()
133 print result134 print result
@@ -141,18 +142,18 @@
141 does raise an exception.142 does raise an exception.
142 """143 """
143 control_data = {144 control_data = {
144 'description': 'a test case',145 'description': 'a test case',
145 'command': '/bin/true',146 'command': '/bin/true',
146 }147 }
147148
148 result = ResultYAML()149 result = ResultYAML()
149150
150 case = testcase.TestCase(151 case = testcase.TestCase(
151 name=self.name,152 name=self.name,
152 path=self.path,153 path=self.path,
153 result=result,154 result=result,
154 _control_data=control_data,155 _control_data=control_data,
155 )156 )
156157
157 with self.assertRaises(MissingData):158 with self.assertRaises(MissingData):
158 case.run()159 case.run()
159160
=== modified file 'utah/client/tests/test_testsuite.py'
--- utah/client/tests/test_testsuite.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_testsuite.py 2012-12-08 02:12:21 +0000
@@ -17,15 +17,16 @@
17import unittest17import unittest
1818
19from utah.client.common import (19from utah.client.common import (
20 debug_print,20 debug_print,
21 )21)
22from utah.client.result import ResultYAML22from utah.client.result import ResultYAML
23from utah.client import testsuite23from utah.client import testsuite
2424
25from .common import ( # NOQA25from .common import (
26 setUp, # Used by nosetests26 # NOQA
27 tearDown, # Used by nosetests27 setUp, # Used by nosetests
28 )28 tearDown, # Used by nosetests
29)
2930
3031
31def state_saver():32def state_saver():
@@ -81,11 +82,12 @@
81 def test_timeout_override(self):82 def test_timeout_override(self):
82 timeout = 10183 timeout = 101
83 suite = testsuite.TestSuite(84 suite = testsuite.TestSuite(
84 name=self.name,85 name=self.name,
85 path=self.path,86 path=self.path,
86 timeout=timeout,87 timeout=timeout,
87 result=ResultYAML(),88 result=ResultYAML(),
88 _save_state_callback=state_saver)89 _save_state_callback=state_saver
90 )
8991
90 self.assertEqual(timeout, suite.timeout)92 self.assertEqual(timeout, suite.timeout)
9193
@@ -96,10 +98,12 @@
96 """Included tests are executed"""98 """Included tests are executed"""
97 included_test_name = 'test_one'99 included_test_name = 'test_one'
98100
99 suite = testsuite.TestSuite(name=self.name,101 suite = testsuite.TestSuite(
100 includes=[included_test_name],102 name=self.name,
101 path=self.path,103 includes=[included_test_name],
102 result=ResultYAML())104 path=self.path,
105 result=ResultYAML()
106 )
103107
104 # Make sure just one test case has been selected108 # Make sure just one test case has been selected
105 self.assertEqual(len(suite.tests), 1)109 self.assertEqual(len(suite.tests), 1)
@@ -112,10 +116,12 @@
112 """Excluded tests are *not* executed"""116 """Excluded tests are *not* executed"""
113 excluded_test_name = 'test_two'117 excluded_test_name = 'test_two'
114118
115 suite = testsuite.TestSuite(name=self.name,119 suite = testsuite.TestSuite(
116 excludes=[excluded_test_name],120 name=self.name,
117 path=self.path,121 excludes=[excluded_test_name],
118 result=ResultYAML())122 path=self.path,
123 result=ResultYAML()
124 )
119125
120 # Make sure just one test case has been selected126 # Make sure just one test case has been selected
121 self.assertEqual(len(suite.tests), 1)127 self.assertEqual(len(suite.tests), 1)
@@ -129,11 +135,13 @@
129 included_test_name = 'test_one'135 included_test_name = 'test_one'
130 excluded_test_name = 'test_two'136 excluded_test_name = 'test_two'
131137
132 suite = testsuite.TestSuite(name=self.name,138 suite = testsuite.TestSuite(
133 includes=[included_test_name],139 name=self.name,
134 excludes=[excluded_test_name],140 includes=[included_test_name],
135 path=self.path,141 excludes=[excluded_test_name],
136 result=ResultYAML())142 path=self.path,
143 result=ResultYAML()
144 )
137145
138 # Make sure just one test case has been selected146 # Make sure just one test case has been selected
139 self.assertEqual(len(suite.tests), 1)147 self.assertEqual(len(suite.tests), 1)
140148
=== modified file 'utah/client/tests/test_yaml.py'
--- utah/client/tests/test_yaml.py 2012-12-03 14:02:18 +0000
+++ utah/client/tests/test_yaml.py 2012-12-08 02:12:21 +0000
@@ -21,15 +21,15 @@
21 def test_parts(self):21 def test_parts(self):
22 content = {}22 content = {}
23 content['metadata'] = {23 content['metadata'] = {
24 'runlist': '/tmp/master.run',24 'runlist': '/tmp/master.run',
25 'host': 'Ubuntu 12.04 LTS',25 'host': 'Ubuntu 12.04 LTS',
26 }26 }
27 content['commands'] = [27 content['commands'] = [
28 {28 {
29 'command': 'rm -f blah',29 'command': 'rm -f blah',
30 'stdout': '',30 'stdout': '',
31 'stderr': '',31 'stderr': '',
32 }32 }
33 ]33 ]
3434
35 enc_data = yaml.dump(content, default_flow_style=False)35 enc_data = yaml.dump(content, default_flow_style=False)
@@ -42,28 +42,28 @@
4242
43 def test_parts_2(self):43 def test_parts_2(self):
44 content = {44 content = {
45 'file': '/tmp/file'45 'file': '/tmp/file'
46 }46 }
4747
48 extra_args = {48 extra_args = {
49 #'explicit_start': '---',49 #'explicit_start': '---',
50 #'explicit_end': '...',50 #'explicit_end': '...',
51 }51 }
5252
53 enc_data = yaml.dump(content, default_flow_style=False, **extra_args)53 enc_data = yaml.dump(content, default_flow_style=False, **extra_args)
5454
55 content = {55 content = {
56 'commands':56 'commands':
57 [57 [
58 {58 {
59 'size': 100,59 'size': 100,
60 'perms': 'rwxr-xr-x',60 'perms': 'rwxr-xr-x',
61 },61 },
62 {62 {
63 'size': 120,63 'size': 120,
64 'perms': 'rwxr-xr-x',64 'perms': 'rwxr-xr-x',
65 },65 },
66 ]66 ]
67 }67 }
6868
69 enc_data += yaml.dump(content, default_flow_style=False, **extra_args)69 enc_data += yaml.dump(content, default_flow_style=False, **extra_args)
@@ -78,19 +78,19 @@
78 def test_parts_3(self):78 def test_parts_3(self):
79 extra_args = {}79 extra_args = {}
80 content = [80 content = [
81 {81 {
82 'file': '/tmp/file',82 'file': '/tmp/file',
83 },83 },
84 [84 [
85 {85 {
86 'size': 100,86 'size': 100,
87 'perms': 'rwxr-xr-x',87 'perms': 'rwxr-xr-x',
88 },88 },
89 {89 {
90 'size': 120,90 'size': 120,
91 'perms': 'rwxr-xr-x',91 'perms': 'rwxr-xr-x',
92 },92 },
93 ]93 ]
94 ]94 ]
95 enc_data = yaml.dump(content, default_flow_style=False, **extra_args)95 enc_data = yaml.dump(content, default_flow_style=False, **extra_args)
96 print(enc_data)96 print(enc_data)
9797
=== modified file 'utah/client/testsuite.py'
--- utah/client/testsuite.py 2012-12-06 16:30:34 +0000
+++ utah/client/testsuite.py 2012-12-08 02:12:21 +0000
@@ -64,11 +64,11 @@
64 'test': {64 'test': {
65 'type': 'string',65 'type': 'string',
66 'required': True,66 'required': True,
67 },
68 'overrides': {'type': 'object'},
69 },67 },
68 'overrides': {'type': 'object'},
70 },69 },
71 }70 },
71 }
7272
73 CONTROL_SCHEMA = {73 CONTROL_SCHEMA = {
74 'type': 'object',74 'type': 'object',
@@ -77,8 +77,8 @@
77 'timeout': {'type': 'integer'},77 'timeout': {'type': 'integer'},
78 'ts_setup': {'type': 'string'},78 'ts_setup': {'type': 'string'},
79 'ts_cleanup': {'type': 'string'},79 'ts_cleanup': {'type': 'string'},
80 }
81 }80 }
81 }
8282
83 def __init__(self, name, path, result, runlist_file=DEFAULT_TSLIST,83 def __init__(self, name, path, result, runlist_file=DEFAULT_TSLIST,
84 control_file=DEFAULT_TSCONTROL, includes=None, excludes=None,84 control_file=DEFAULT_TSCONTROL, includes=None, excludes=None,
@@ -128,9 +128,9 @@
128 control_data = None128 control_data = None
129 except jsonschema.ValidationError as exception:129 except jsonschema.ValidationError as exception:
130 raise ValidationError(130 raise ValidationError(
131 '{!r} test suite control file invalid: {!r}\n'131 '{!r} test suite control file invalid: {!r}\n1'
132 'Detailed information: {}'132 'Detailed information: {}'
133 .format(self.name, self.control_file, exception))133 .format(self.name, self.control_file, exception))
134134
135 if control_data is not None:135 if control_data is not None:
136 # already initialized136 # already initialized
@@ -146,9 +146,9 @@
146 runlist_data = parse_runlist_file(self.runlist_file)146 runlist_data = parse_runlist_file(self.runlist_file)
147 except jsonschema.ValidationError as exception:147 except jsonschema.ValidationError as exception:
148 raise ValidationError(148 raise ValidationError(
149 '{!r} test suite runlist invalid: {!r}\n'149 '{!r} test suite runlist invalid: {!r}\n'
150 'Detailed information: {}'150 'Detailed information: {}'
151 .format(self.name, self.runlist_file, exception))151 .format(self.name, self.runlist_file, exception))
152 else:152 else:
153 raise MissingFile('File not found: {}'.format(self.runlist_file))153 raise MissingFile('File not found: {}'.format(self.runlist_file))
154154
155155
=== modified file 'utah/config.py'
--- utah/config.py 2012-12-03 15:49:35 +0000
+++ utah/config.py 2012-12-08 02:12:21 +0000
@@ -113,14 +113,15 @@
113 # Default setting for configuration rewriting113 # Default setting for configuration rewriting
114 rewrite='all',114 rewrite='all',
115 # Available releases115 # Available releases
116 serieschoices=[ # Remember to update uqt-vm-tools.conf as well116 serieschoices=[
117 'hardy',117 # Remember to update uqt-vm-tools.conf as well
118 'lucid',118 'hardy',
119 'oneiric',119 'lucid',
120 'precise',120 'oneiric',
121 'quantal',121 'precise',
122 'raring',122 'quantal',
123 ],123 'raring',
124 ],
124 # Default machine template125 # Default machine template
125 template=None,126 template=None,
126 # Directory to hold web-accessible files127 # Directory to hold web-accessible files
@@ -155,8 +156,9 @@
155 LOCALDEFAULTS['hostname'] + '.log')156 LOCALDEFAULTS['hostname'] + '.log')
156# Default logfile is /var/log/utah/{hostname}-debug.log157# Default logfile is /var/log/utah/{hostname}-debug.log
157# Set to None to disable separate debug log158# Set to None to disable separate debug log
158LOCALDEFAULTS['debuglog'] = os.path.join(DEFAULTS['logpath'],159LOCALDEFAULTS['debuglog'] = os.path.join(
159 LOCALDEFAULTS['hostname'] + '-debug.log')160 DEFAULTS['logpath'],
161 LOCALDEFAULTS['hostname'] + '-debug.log')
160162
161# This depends on a binary that may not be installed.163# This depends on a binary that may not be installed.
162# Also, the null thing may seem obvious, but I found it here:164# Also, the null thing may seem obvious, but I found it here:
@@ -167,18 +169,18 @@
167 stdout=fnull, stderr=fnull) == 0:169 stdout=fnull, stderr=fnull) == 0:
168 # If dpkg-architecture is available, default to current host arch170 # If dpkg-architecture is available, default to current host arch
169 LOCALDEFAULTS['arch'] = subprocess.check_output(171 LOCALDEFAULTS['arch'] = subprocess.check_output(
170 ['dpkg-architecture', '-qDEB_HOST_ARCH']).strip()172 ['dpkg-architecture', '-qDEB_HOST_ARCH']).strip()
171 else:173 else:
172 # Otherwise, default to i386174 # Otherwise, default to i386
173 LOCALDEFAULTS['arch'] = 'i386'175 LOCALDEFAULTS['arch'] = 'i386'
174 176
175# I'm not sure lsb_release is always around177# I'm not sure lsb_release is always around
176with open(os.devnull, 'w') as fnull:178with open(os.devnull, 'w') as fnull:
177 if subprocess.call(['which', 'lsb_release'],179 if subprocess.call(['which', 'lsb_release'],
178 stdout=fnull, stderr=fnull) == 0:180 stdout=fnull, stderr=fnull) == 0:
179 # If lsb_release is available, default to current series181 # If lsb_release is available, default to current series
180 LOCALDEFAULTS['series'] = subprocess.check_output(182 LOCALDEFAULTS['series'] = subprocess.check_output(
181 ['lsb_release', '-sc']).strip()183 ['lsb_release', '-sc']).strip()
182 else:184 else:
183 # Otherwise, default to precise185 # Otherwise, default to precise
184 LOCALDEFAULTS['series'] = 'precise'186 LOCALDEFAULTS['series'] = 'precise'
185187
=== modified file 'utah/iso.py'
--- utah/iso.py 2012-12-07 11:10:30 +0000
+++ utah/iso.py 2012-12-08 02:12:21 +0000
@@ -108,7 +108,7 @@
108 if config.debuglog is not None:108 if config.debuglog is not None:
109 self.logger.setLevel(logging.DEBUG)109 self.logger.setLevel(logging.DEBUG)
110 self.debughandler = (110 self.debughandler = (
111 logging.handlers.WatchedFileHandler(config.debuglog))111 logging.handlers.WatchedFileHandler(config.debuglog))
112 self.debughandler.setFormatter(file_formatter)112 self.debughandler.setFormatter(file_formatter)
113 self.debughandler.setLevel(logging.DEBUG)113 self.debughandler.setLevel(logging.DEBUG)
114 self.logger.addHandler(self.debughandler)114 self.logger.addHandler(self.debughandler)
@@ -242,7 +242,7 @@
242 if '-O' in cmd:242 if '-O' in cmd:
243 cmd.remove('-O')243 cmd.remove('-O')
244 return subprocess.Popen(cmd, stdout=subprocess.PIPE,244 return subprocess.Popen(cmd, stdout=subprocess.PIPE,
245 stderr=subprocess.PIPE, **kw).communicate()245 stderr=subprocess.PIPE, **kw).communicate()
246 else:246 else:
247 cmd = self.getrealfile(filename)247 cmd = self.getrealfile(filename)
248 return subprocess.call(cmd, stdout=open(outfile, 'w'), **kw)248 return subprocess.call(cmd, stdout=open(outfile, 'w'), **kw)
@@ -325,8 +325,8 @@
325 # Set the path to our files and the name of the iso we want325 # Set the path to our files and the name of the iso we want
326 if installtype == 'mini':326 if installtype == 'mini':
327 remotepath = ('http://archive.ubuntu.com/ubuntu/dists/'327 remotepath = ('http://archive.ubuntu.com/ubuntu/dists/'
328 '{series}/main/installer-{arch}/current/'328 '{series}/main/installer-{arch}/current/'
329 'images/'.format(arch=arch, series=series))329 'images/'.format(arch=arch, series=series))
330 isopattern = 'netboot/mini.iso'330 isopattern = 'netboot/mini.iso'
331 else:331 else:
332 remotepath = ('http://releases.ubuntu.com/'332 remotepath = ('http://releases.ubuntu.com/'
333333
=== modified file 'utah/isotest/iso_static_validation.py'
--- utah/isotest/iso_static_validation.py 2012-12-06 16:30:34 +0000
+++ utah/isotest/iso_static_validation.py 2012-12-08 02:12:21 +0000
@@ -204,7 +204,7 @@
204204
205 # Test if the manfest is the same as that is given in the server205 # Test if the manfest is the same as that is given in the server
206 @unittest.skipUnless(ubiquity_image,206 @unittest.skipUnless(ubiquity_image,
207 "manifest only for ubiquity based images")207 "manifest only for ubiquity based images")
208 def test_manifest(self):208 def test_manifest(self):
209 manifest_url = os.path.join(self.url, 'current',209 manifest_url = os.path.join(self.url, 'current',
210 self.st_release + '-' +210 self.st_release + '-' +
@@ -304,7 +304,7 @@
304304
305 # Test if the relevant important files are present in the iso for dvd iso305 # Test if the relevant important files are present in the iso for dvd iso
306 @unittest.skipUnless(st_variant == 'dvd',306 @unittest.skipUnless(st_variant == 'dvd',
307 "This file list test is only specific for dvd")307 "This file list test is only specific for dvd")
308 def test_files_ubiquity_dvd(self):308 def test_files_ubiquity_dvd(self):
309 (stdout, stderr) = self.iso.listfiles()309 (stdout, stderr) = self.iso.listfiles()
310 logging.debug('Check for error in extracting file list from the iso')310 logging.debug('Check for error in extracting file list from the iso')
311311
=== modified file 'utah/orderedcollections.py'
--- utah/orderedcollections.py 2012-12-03 14:02:18 +0000
+++ utah/orderedcollections.py 2012-12-08 02:12:21 +0000
@@ -26,7 +26,7 @@
26class OrderedSet(collections.MutableSet):26class OrderedSet(collections.MutableSet):
2727
28 def __init__(self, iterable=None):28 def __init__(self, iterable=None):
29 self.end = end = [] 29 self.end = end = []
30 end += [None, end, end] # sentinel node for doubly linked list30 end += [None, end, end] # sentinel node for doubly linked list
31 self.map = {} # key --> [key, prev, next]31 self.map = {} # key --> [key, prev, next]
32 if iterable is not None:32 if iterable is not None:
@@ -45,7 +45,7 @@
45 curr[NEXT] = end[PREV] = self.map[key] = [key, curr, end]45 curr[NEXT] = end[PREV] = self.map[key] = [key, curr, end]
4646
47 def discard(self, key):47 def discard(self, key):
48 if key in self.map: 48 if key in self.map:
49 key, prev, next = self.map.pop(key)49 key, prev, next = self.map.pop(key)
50 prev[NEXT] = next50 prev[NEXT] = next
51 next[PREV] = prev51 next[PREV] = prev
5252
=== modified file 'utah/process.py'
--- utah/process.py 2012-12-03 14:02:18 +0000
+++ utah/process.py 2012-12-08 02:12:21 +0000
@@ -23,11 +23,11 @@
23 """23 """
24 Check all running process looking for a given pattern24 Check all running process looking for a given pattern
25 """25 """
26 MESSAGE_TEMPLATE = \26 MESSAGE_TEMPLATE = (
27 ("{app} application is running.\n"27 "{app} application is running.\n"
28 "Please stop it before launching utah since "28 "Please stop it before launching utah since "
29 "it won't interact properly with KVM "29 "it won't interact properly with KVM "
30 "(Kernel-based Virtual Machine)\n")30 "(Kernel-based Virtual Machine)\n")
3131
32 def check_cmdline(self, pattern):32 def check_cmdline(self, pattern):
33 """33 """
3434
=== modified file 'utah/provisioning/baremetal/bamboofeeder.py'
--- utah/provisioning/baremetal/bamboofeeder.py 2012-12-06 16:30:34 +0000
+++ utah/provisioning/baremetal/bamboofeeder.py 2012-12-08 02:12:21 +0000
@@ -26,10 +26,10 @@
2626
27from utah import config27from utah import config
28from utah.provisioning.provisioning import (28from utah.provisioning.provisioning import (
29 CustomInstallMixin,29 CustomInstallMixin,
30 Machine,30 Machine,
31 SSHMixin,31 SSHMixin,
32 )32)
33from utah.provisioning.baremetal.power import PowerMixin33from utah.provisioning.baremetal.power import PowerMixin
34from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException34from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException
35from utah.retry import retry35from utah.retry import retry
@@ -45,7 +45,7 @@
45 # TODO: respect rewrite setting45 # TODO: respect rewrite setting
46 if name is None:46 if name is None:
47 raise UTAHBMProvisioningException(47 raise UTAHBMProvisioningException(
48 'Machine name reqired for bamboo-feeder machine')48 'Machine name reqired for bamboo-feeder machine')
49 if powercmd is not None:49 if powercmd is not None:
50 self.powercmd = powercmd50 self.powercmd = powercmd
51 elif cargs is not None:51 elif cargs is not None:
@@ -55,12 +55,12 @@
55 self.power[item] = cargs[item]55 self.power[item] = cargs[item]
56 else:56 else:
57 raise UTAHBMProvisioningException(57 raise UTAHBMProvisioningException(
58 'No power control information specified')58 'No power control information specified')
59 try:59 try:
60 self.macaddress = cargs['mac-address']60 self.macaddress = cargs['mac-address']
61 except AttributeError:61 except AttributeError:
62 raise UTAHBMProvisioningException(62 raise UTAHBMProvisioningException(
63 'No MAC address specified')63 'No MAC address specified')
64 self.inventory = inventory64 self.inventory = inventory
65 super(BambooFeederMachine, self).__init__(*args, name=name, **kw)65 super(BambooFeederMachine, self).__init__(*args, name=name, **kw)
66 if self.inventory is not None:66 if self.inventory is not None:
@@ -68,7 +68,7 @@
68 self._depcheck()68 self._depcheck()
69 if self.image is None:69 if self.image is None:
70 raise UTAHBMProvisioningException(70 raise UTAHBMProvisioningException(
71 'Image file required for bamboo-feeder installation')71 'Image file required for bamboo-feeder installation')
72 try:72 try:
73 iface = config.wwwiface73 iface = config.wwwiface
74 except AttributeError:74 except AttributeError:
@@ -108,9 +108,10 @@
108 self.imagedir = os.path.join(self.tmpdir, 'image.d')108 self.imagedir = os.path.join(self.tmpdir, 'image.d')
109 if not os.path.isdir(self.imagedir):109 if not os.path.isdir(self.imagedir):
110 os.makedirs(self.imagedir)110 os.makedirs(self.imagedir)
111 self.sector = int(subprocess.check_output(['file',111 self.sector = int(
112 self.wwwimage]112 subprocess.check_output(
113 ).strip().split(';')[1].split(',')[3].split()[1])113 ['file', self.wwwimage]
114 ).strip().split(';')[1].split(',')[3].split()[1])
114 self.logger.debug('Image start sector is ' + str(self.sector))115 self.logger.debug('Image start sector is ' + str(self.sector))
115 self.cleanfunction(self._umountimage)116 self.cleanfunction(self._umountimage)
116 self.logger.debug('Mounting ' + self.wwwimage + ' at ' +117 self.logger.debug('Mounting ' + self.wwwimage + ' at ' +
@@ -167,15 +168,15 @@
167 pipe.copy('/dev/null', initrd)168 pipe.copy('/dev/null', initrd)
168 self.logger.debug('Creating uInitrd with mkimage')169 self.logger.debug('Creating uInitrd with mkimage')
169 self._runargs(['mkimage',170 self._runargs(['mkimage',
170 '-A', 'arm',171 '-A', 'arm',
171 '-O', 'linux',172 '-O', 'linux',
172 '-T', 'ramdisk',173 '-T', 'ramdisk',
173 '-C', 'gzip',174 '-C', 'gzip',
174 '-a', '0',175 '-a', '0',
175 '-e', '0',176 '-e', '0',
176 '-n', 'initramfs',177 '-n', 'initramfs',
177 '-d', initrd,178 '-d', initrd,
178 self.initrd])179 self.initrd])
179180
180 def _umountimage(self):181 def _umountimage(self):
181 """182 """
@@ -206,8 +207,7 @@
206 ('log_port', '10514'),207 ('log_port', '10514'),
207 ('netcfg/choose_interface', 'auto'),208 ('netcfg/choose_interface', 'auto'),
208 ('url', 'http://' + self.ip + '/utah/' + self.name +209 ('url', 'http://' + self.ip + '/utah/' + self.name +
209 '.cfg'),210 '.cfg')):
210 ):
211 if parameter[0] not in self.cmdline:211 if parameter[0] not in self.cmdline:
212 self.logger.info('Adding boot option: ' + '='.join(parameter))212 self.logger.info('Adding boot option: ' + '='.join(parameter))
213 self.cmdline += ' ' + '='.join(parameter)213 self.cmdline += ' ' + '='.join(parameter)
@@ -234,7 +234,7 @@
234 open(tmppxefile, 'w').write(pxeconfig)234 open(tmppxefile, 'w').write(pxeconfig)
235 self.logger.debug('PXE info written to ' + tmppxefile)235 self.logger.debug('PXE info written to ' + tmppxefile)
236 pxefile = os.path.join(config.pxedir,236 pxefile = os.path.join(config.pxedir,
237 '01-' + self.macaddress.replace(':', '-'))237 '01-' + self.macaddress.replace(':', '-'))
238 self.cleancommand(('sudo', 'rm', '-f', pxefile))238 self.cleancommand(('sudo', 'rm', '-f', pxefile))
239 self.logger.debug('Copying ' + tmppxefile + ' to ' + pxefile)239 self.logger.debug('Copying ' + tmppxefile + ' to ' + pxefile)
240 self._runargs(['sudo', 'cp', tmppxefile, pxefile])240 self._runargs(['sudo', 'cp', tmppxefile, pxefile])
@@ -270,8 +270,7 @@
270 self.logger.info('Configuring latecommand for desktop')270 self.logger.info('Configuring latecommand for desktop')
271 myfile = open(os.path.join(self.tmpdir, 'initrd.d',271 myfile = open(os.path.join(self.tmpdir, 'initrd.d',
272 'utah-latecommand'), 'a')272 'utah-latecommand'), 'a')
273 myfile.write(273 myfile.write("""
274"""
275chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'274chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'
276""")275""")
277 myfile.close()276 myfile.close()
@@ -300,12 +299,13 @@
300 if self.run(uuid_check_command)[0] != 0:299 if self.run(uuid_check_command)[0] != 0:
301 self.provisioned = False300 self.provisioned = False
302 raise UTAHBMProvisioningException(301 raise UTAHBMProvisioningException(
303 'Installed UUID differs from Machine UUID; '302 'Installed UUID differs from Machine UUID; '
304 'installation probably failed. '303 'installation probably failed. '
305 'Try restarting cobbler or running cobbler sync')304 'Try restarting cobbler or running cobbler sync')
306 self.logger.info('System installed')305 self.logger.info('System installed')
307 self.cleanfunction(self.run, ('dd', 'bs=512k', 'count=10',306 self.cleanfunction(self.run, (
308 'if=/dev/zero', 'of=/dev/mmcblk0'), root=True)307 'dd', 'bs=512k', 'count=10', 'if=/dev/zero', 'of=/dev/mmcblk0'),
308 root=True)
309 return True309 return True
310310
311 def _depcheck(self):311 def _depcheck(self):
312312
=== modified file 'utah/provisioning/baremetal/cobbler.py'
--- utah/provisioning/baremetal/cobbler.py 2012-12-06 16:30:34 +0000
+++ utah/provisioning/baremetal/cobbler.py 2012-12-08 02:12:21 +0000
@@ -26,10 +26,10 @@
2626
27from utah import config27from utah import config
28from utah.provisioning.provisioning import (28from utah.provisioning.provisioning import (
29 CustomInstallMixin,29 CustomInstallMixin,
30 Machine,30 Machine,
31 SSHMixin,31 SSHMixin,
32 )32)
33from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException33from utah.provisioning.baremetal.exceptions import UTAHBMProvisioningException
34from utah.provisioning.baremetal.power import PowerMixin34from utah.provisioning.baremetal.power import PowerMixin
35from utah.retry import retry35from utah.retry import retry
@@ -44,10 +44,10 @@
44 *args, **kw):44 *args, **kw):
45 if name is None:45 if name is None:
46 raise UTAHBMProvisioningException(46 raise UTAHBMProvisioningException(
47 'Machine name reqired for cobbler machine')47 'Machine name reqired for cobbler machine')
48 if cargs is None:48 if cargs is None:
49 raise UTAHBMProvisioningException(49 raise UTAHBMProvisioningException(
50 'No cobbler arguments given for machine creation')50 'No cobbler arguments given for machine creation')
51 else:51 else:
52 self.cargs = cargs52 self.cargs = cargs
53 self.power = {}53 self.power = {}
@@ -61,7 +61,7 @@
61 preseed=preseed, **kw)61 preseed=preseed, **kw)
62 if self.image is None:62 if self.image is None:
63 raise UTAHBMProvisioningException(63 raise UTAHBMProvisioningException(
64 'Image file required for cobbler installation')64 'Image file required for cobbler installation')
65 self._custominit()65 self._custominit()
66 # TODO: verify we have nfs support for desktop image66 # TODO: verify we have nfs support for desktop image
6767
@@ -106,8 +106,7 @@
106 self.logger.info('Configuring latecommand for desktop')106 self.logger.info('Configuring latecommand for desktop')
107 myfile = open(os.path.join(self.tmpdir, 'initrd.d',107 myfile = open(os.path.join(self.tmpdir, 'initrd.d',
108 'utah-latecommand'), 'a')108 'utah-latecommand'), 'a')
109 myfile.write(109 myfile.write("""
110"""
111chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'110chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'
112""")111""")
113 myfile.close()112 myfile.close()
@@ -152,7 +151,7 @@
152 pipe.append('sudo tee -a ' + str(config.nfsconfigfile) +151 pipe.append('sudo tee -a ' + str(config.nfsconfigfile) +
153 ' >/dev/null', '-.')152 ' >/dev/null', '-.')
154 pipe.open('/dev/null', 'w').write(self.tmpdir + ' ' +153 pipe.open('/dev/null', 'w').write(self.tmpdir + ' ' +
155 config.nfsoptions + "\n")154 config.nfsoptions + "\n")
156 self.logger.debug('Reloading NFS config')155 self.logger.debug('Reloading NFS config')
157 self._runargs(config.nfscommand)156 self._runargs(config.nfscommand)
158 self.logger.debug('Adding NFS boot options')157 self.logger.debug('Adding NFS boot options')
@@ -176,8 +175,8 @@
176 self.logger.info('Adding system')175 self.logger.info('Adding system')
177 self._cobble(['system', 'add', '--name=' + self.name,176 self._cobble(['system', 'add', '--name=' + self.name,
178 '--profile=' + self.cname, '--netboot-enabled=Y']177 '--profile=' + self.cname, '--netboot-enabled=Y']
179 + ['--' + arg + '=' + self.cargs[arg]178 + ['--' + arg + '=' + self.cargs[arg]
180 for arg in self.cargs])179 for arg in self.cargs])
181180
182 # Things seem to be working fine without this,181 # Things seem to be working fine without this,
183 # but sometimes things still get broken182 # but sometimes things still get broken
@@ -219,9 +218,9 @@
219 if self.run(uuid_check_command)[0] != 0:218 if self.run(uuid_check_command)[0] != 0:
220 self.provisioned = False219 self.provisioned = False
221 raise UTAHBMProvisioningException(220 raise UTAHBMProvisioningException(
222 'Installed UUID differs from CobblerMachine UUID; '221 'Installed UUID differs from CobblerMachine UUID; '
223 'installation probably failed. '222 'installation probably failed. '
224 'Try restarting cobbler or running cobbler sync')223 'Try restarting cobbler or running cobbler sync')
225 self.logger.info('System installed')224 self.logger.info('System installed')
226 return True225 return True
227226
228227
=== modified file 'utah/provisioning/baremetal/power.py'
--- utah/provisioning/baremetal/power.py 2012-12-03 14:02:18 +0000
+++ utah/provisioning/baremetal/power.py 2012-12-08 02:12:21 +0000
@@ -72,4 +72,3 @@
72 self.logger.debug('Waiting ' + str(config.powertimeout) + ' seconds')72 self.logger.debug('Waiting ' + str(config.powertimeout) + ' seconds')
73 time.sleep(config.powertimeout)73 time.sleep(config.powertimeout)
74 self._start()74 self._start()
75
7675
=== modified file 'utah/provisioning/inventory/inventory.py'
--- utah/provisioning/inventory/inventory.py 2012-12-03 15:49:35 +0000
+++ utah/provisioning/inventory/inventory.py 2012-12-08 02:12:21 +0000
@@ -17,7 +17,7 @@
1717
18import os18import os
19from utah.provisioning.inventory.exceptions import \19from utah.provisioning.inventory.exceptions import \
20 UTAHProvisioningInventoryException20 UTAHProvisioningInventoryException
2121
2222
23class Inventory(object):23class Inventory(object):
@@ -50,9 +50,9 @@
50 lockfile.close()50 lockfile.close()
51 if inventory != userinventory:51 if inventory != userinventory:
52 raise UTAHProvisioningInventoryException(52 raise UTAHProvisioningInventoryException(
53 'Different inventory in use: ' + userinventory53 'Different inventory in use: ' + userinventory
54 + "\nDelete " + self.lockfile54 + "\nDelete " + self.lockfile
55 + ' if you are sure it is no longer valid')55 + ' if you are sure it is no longer valid')
56 else:56 else:
57 lockfile = open(self.lockfile, 'w')57 lockfile = open(self.lockfile, 'w')
58 lockfile.write(inventory)58 lockfile.write(inventory)
@@ -91,7 +91,7 @@
91 send all arguments to that constructor.91 send all arguments to that constructor.
92 """92 """
93 raise UTAHProvisioningInventoryException(93 raise UTAHProvisioningInventoryException(
94 'Method not defined for this inventory')94 'Method not defined for this inventory')
9595
96 def release(self):96 def release(self):
97 """97 """
9898
=== modified file 'utah/provisioning/inventory/sqlite.py'
--- utah/provisioning/inventory/sqlite.py 2012-12-03 15:49:35 +0000
+++ utah/provisioning/inventory/sqlite.py 2012-12-08 02:12:21 +0000
@@ -19,7 +19,7 @@
19import os19import os
20import psutil20import psutil
21from utah.provisioning.inventory.exceptions import \21from utah.provisioning.inventory.exceptions import \
22 UTAHProvisioningInventoryException22 UTAHProvisioningInventoryException
23from utah.provisioning.inventory.inventory import Inventory23from utah.provisioning.inventory.inventory import Inventory
24from utah.provisioning.vm.libvirtvm import CustomVM24from utah.provisioning.vm.libvirtvm import CustomVM
25from utah.provisioning.baremetal.cobbler import CobblerMachine25from utah.provisioning.baremetal.cobbler import CobblerMachine
@@ -55,8 +55,8 @@
55 """55 """
56 super(TinySQLiteInventory, self).__init__(*args, **kw)56 super(TinySQLiteInventory, self).__init__(*args, **kw)
57 self.connection.execute(57 self.connection.execute(
58 'CREATE TABLE IF NOT EXISTS '58 'CREATE TABLE IF NOT EXISTS '
59 'machines(machineid INTEGER PRIMARY KEY, state TEXT)')59 'machines(machineid INTEGER PRIMARY KEY, state TEXT)')
6060
61 def request(self, machinetype=CustomVM, *args, **kw):61 def request(self, machinetype=CustomVM, *args, **kw):
62 """62 """
@@ -106,9 +106,10 @@
106 lockfile = os.path.expanduser(lockfile)106 lockfile = os.path.expanduser(lockfile)
107 if not os.path.isfile(db):107 if not os.path.isfile(db):
108 raise UTAHProvisioningInventoryException(108 raise UTAHProvisioningInventoryException(
109 'No machine database found at ' + db)109 'No machine database found at ' + db)
110 super(ManualCobblerSQLiteInventory, self).__init__(*args, db=db,110 super(ManualCobblerSQLiteInventory, self).__init__(*args, db=db,
111 lockfile=lockfile, **kw)111 lockfile=lockfile,
112 **kw)
112 machines_count = (self.connection113 machines_count = (self.connection
113 .execute('SELECT COUNT(*) FROM machines')114 .execute('SELECT COUNT(*) FROM machines')
114 .fetchall()[0][0])115 .fetchall()[0][0])
@@ -125,7 +126,7 @@
125 result = self.connection.execute(query, queryvars).fetchall()126 result = self.connection.execute(query, queryvars).fetchall()
126 if result is None:127 if result is None:
127 raise UTAHProvisioningInventoryException(128 raise UTAHProvisioningInventoryException(
128 'No machines meet criteria')129 'No machines meet criteria')
129 else:130 else:
130 for machineinfo in result:131 for machineinfo in result:
131 cargs = dict(machineinfo)132 cargs = dict(machineinfo)
@@ -135,16 +136,16 @@
135 cargs = dict(machineinfo)136 cargs = dict(machineinfo)
136 pid = cargs['pid']137 pid = cargs['pid']
137 try:138 try:
138 if not (psutil.pid_exists(pid) and ('utah' in 139 if not (psutil.pid_exists(pid) and ('utah' in
139 ' '.join(psutil.Process(pid).cmdline)140 ' '.join(psutil.Process(pid).cmdline)
140 or 'run_test_cobbler.py' in 141 or 'run_test_cobbler.py' in
141 ' '.join(psutil.Process(pid).cmdline))):142 ' '.join(psutil.Process(pid).cmdline))):
142 return self._take(cargs, *args, **kw)143 return self._take(cargs, *args, **kw)
143 except ValueError:144 except ValueError:
144 continue145 continue
145146
146 raise UTAHProvisioningInventoryException(147 raise UTAHProvisioningInventoryException(
147 'All machines meeting criteria are currently unavailable')148 'All machines meeting criteria are currently unavailable')
148149
149 def _take(self, cargs, *args, **kw):150 def _take(self, cargs, *args, **kw):
150 machineid = cargs.pop('machineid')151 machineid = cargs.pop('machineid')
@@ -152,33 +153,34 @@
152 state = cargs.pop('state')153 state = cargs.pop('state')
153 pid = cargs.pop('pid')154 pid = cargs.pop('pid')
154 update = self.connection.execute(155 update = self.connection.execute(
155 "UPDATE machines SET pid=?, state='provisioned' WHERE machineid=? AND state=?",156 "UPDATE machines SET pid=?, state='provisioned' WHERE machineid=?"
156 [os.getpid(), machineid, state]).rowcount157 "AND state=?",
158 [os.getpid(), machineid, state]).rowcount
157 if update == 1:159 if update == 1:
158 machine = CobblerMachine(*args, cargs=cargs,160 machine = CobblerMachine(*args, cargs=cargs,
159 inventory=self, name=name, **kw)161 inventory=self, name=name, **kw)
160 self.machines.append(machine)162 self.machines.append(machine)
161 return machine163 return machine
162 elif update == 0:164 elif update == 0:
163 raise UTAHProvisioningInventoryException(165 raise UTAHProvisioningInventoryException(
164 'Machine was requested by another process '166 'Machine was requested by another process '
165 'before we could request it')167 'before we could request it')
166 elif update > 1:168 elif update > 1:
167 raise UTAHProvisioningInventoryException(169 raise UTAHProvisioningInventoryException(
168 'Multiple machines exist '170 'Multiple machines exist '
169 'matching those criteria; '171 'matching those criteria; '
170 'database ' + self.db + ' may be corrupt')172 'database ' + self.db + ' may be corrupt')
171 else:173 else:
172 raise UTAHProvisioningInventoryException(174 raise UTAHProvisioningInventoryException(
173 'Negative rowcount returned '175 'Negative rowcount returned '
174 'when attempting to request machine')176 'when attempting to request machine')
175177
176 def release(self, machine=None, name=None):178 def release(self, machine=None, name=None):
177 if machine is not None:179 if machine is not None:
178 name = machine.name180 name = machine.name
179 if name is None:181 if name is None:
180 raise UTAHProvisioningInventoryException(182 raise UTAHProvisioningInventoryException(
181 'name required to release a machine')183 'name required to release a machine')
182 query = "UPDATE machines SET state='available' WHERE name=?"184 query = "UPDATE machines SET state='available' WHERE name=?"
183 queryvars = [name]185 queryvars = [name]
184 update = self.connection.execute(query, queryvars).rowcount186 update = self.connection.execute(query, queryvars).rowcount
@@ -188,17 +190,17 @@
188 self.machines.remove(machine)190 self.machines.remove(machine)
189 elif update == 0:191 elif update == 0:
190 raise UTAHProvisioningInventoryException(192 raise UTAHProvisioningInventoryException(
191 'SERIOUS ERROR: Another process released this machine '193 'SERIOUS ERROR: Another process released this machine '
192 'before we could, which means two processes provisioned '194 'before we could, which means two processes provisioned '
193 'the same machine simultaneously')195 'the same machine simultaneously')
194 elif update > 1:196 elif update > 1:
195 raise UTAHProvisioningInventoryException(197 raise UTAHProvisioningInventoryException(
196 'Multiple machines exist matching those criteria; '198 'Multiple machines exist matching those criteria; '
197 'database ' + self.db + ' may be corrupt')199 'database ' + self.db + ' may be corrupt')
198 else:200 else:
199 raise UTAHProvisioningInventoryException(201 raise UTAHProvisioningInventoryException(
200 'Negative rowcount returned '202 'Negative rowcount returned '
201 'when attempting to release machine')203 'when attempting to release machine')
202204
203 # Here is how I currently create the database:205 # Here is how I currently create the database:
204 # CREATE TABLE machines (machineid INTEGER PRIMARY KEY,206 # CREATE TABLE machines (machineid INTEGER PRIMARY KEY,
205207
=== modified file 'utah/publish.py'
--- utah/publish.py 2012-12-03 14:02:18 +0000
+++ utah/publish.py 2012-12-08 02:12:21 +0000
@@ -47,41 +47,41 @@
47 'runlist': {47 'runlist': {
48 'type': 'string',48 'type': 'string',
49 'required': True,49 'required': True,
50 },50 },
51 'commands': {51 'commands': {
52 'type': 'array',52 'type': 'array',
53 'items': {'type': COMMAND_SCHEMA},53 'items': {'type': COMMAND_SCHEMA},
54 'required': True,54 'required': True,
55 },55 },
56 'fetch_errors': {56 'fetch_errors': {
57 'type': 'integer',57 'type': 'integer',
58 'required': True,58 'required': True,
59 },59 },
60 'errors': {60 'errors': {
61 'type': 'integer',61 'type': 'integer',
62 'required': True,62 'required': True,
63 },63 },
64 'failures': {64 'failures': {
65 'type': 'integer',65 'type': 'integer',
66 'required': True,66 'required': True,
67 },67 },
68 'passes': {68 'passes': {
69 'type': 'integer',69 'type': 'integer',
70 'required': True,70 'required': True,
71 },71 },
72 'uname': {72 'uname': {
73 'type': 'array',73 'type': 'array',
74 'items': {'type': 'string'},74 'items': {'type': 'string'},
75 'required': True,75 'required': True,
76 },76 },
77 'media-info': {77 'media-info': {
78 'type': 'string',78 'type': 'string',
79 'required': True,79 'required': True,
80 },80 },
81 'install_type': {81 'install_type': {
82 'type': 'string',82 'type': 'string',
83 'required': True,83 'required': True,
84 },84 },
85 },85 },
86}86}
8787
@@ -135,7 +135,7 @@
135135
136if __name__ == "__main__":136if __name__ == "__main__":
137 parser = argparse.ArgumentParser(137 parser = argparse.ArgumentParser(
138 description='utah results publisher'138 description='utah results publisher'
139 )139 )
140 parser.add_argument('logfile', metavar='LOGFILE', type=str,140 parser.add_argument('logfile', metavar='LOGFILE', type=str,
141 help="utah client results log")141 help="utah client results log")
142142
=== modified file 'utah/timeout.py'
--- utah/timeout.py 2012-12-03 14:02:18 +0000
+++ utah/timeout.py 2012-12-08 02:12:21 +0000
@@ -53,8 +53,9 @@
53 try:53 try:
54 return command(*args, **kw)54 return command(*args, **kw)
55 except UTAHTimeout:55 except UTAHTimeout:
56 raise UTAHTimeout(commandstr(command, *args, **kw)56 raise UTAHTimeout(
57 + ' timed out after ' + str(timeout) + ' seconds')57 commandstr(command, *args, **kw)
58 + ' timed out after ' + str(timeout) + ' seconds')
58 else:59 else:
59 signal.signal(signal.SIGALRM, alarm_handler)60 signal.signal(signal.SIGALRM, alarm_handler)
60 signal.alarm(timeout)61 signal.alarm(timeout)
@@ -64,8 +65,9 @@
64 signal.alarm(0)65 signal.alarm(0)
65 return retval66 return retval
66 except UTAHTimeout:67 except UTAHTimeout:
67 raise UTAHTimeout(commandstr(command, *args, **kw)68 raise UTAHTimeout(
68 + ' timed out after ' + str(timeout) + ' seconds')69 commandstr(command, *args, **kw)
70 + ' timed out after ' + str(timeout) + ' seconds')
6971
7072
71def subprocesstimeout(timeout, *args, **kw):73def subprocesstimeout(timeout, *args, **kw):

Subscribers

People subscribed via source and target branches