Revision 4000d692 snf-tools/synnefo_tools/burnin/__init__.py

b/snf-tools/synnefo_tools/burnin/__init__.py
45 45
from synnefo_tools.burnin.images_tests import \
46 46
    FlavorsTestSuite, ImagesTestSuite
47 47
from synnefo_tools.burnin.pithos_tests import PithosTestSuite
48
from synnefo_tools.burnin.server_tests import ServerTestSuite
48 49

  
49 50

  
50 51
# --------------------------------------------------------------------
......
54 55
    FlavorsTestSuite,
55 56
    ImagesTestSuite,
56 57
    PithosTestSuite,
58
    ServerTestSuite,
57 59
    ]
58 60

  
59 61
TSUITES_NAMES = [tsuite.__name__ for tsuite in TESTSUITES]
......
68 70
# Parse arguments
69 71
def parse_comma(option, _, value, parser):
70 72
    """Parse comma separated arguments"""
71
    tests = set(TSUITES_NAMES)
72
    parse_input = value.split(',')
73

  
74
    if not (set(parse_input)).issubset(tests):
75
        raise optparse.OptionValueError("The selected set of tests is invalid")
76

  
77
    setattr(parser.values, option.dest, value.split(','))
73
    parse_input = [p.strip() for p in value.split(',')]
74
    setattr(parser.values, option.dest, parse_input)
78 75

  
79 76

  
80 77
def parse_arguments(args):
......
120 117
        help="Query server status when requests are pending "
121 118
             "every INTERVAL seconds")
122 119
    parser.add_option(
123
        "--force-flavor", action="store",
124
        type="string", default=None, dest="force_flavor", metavar="FLAVOR",
125
        help="Force all server creations to use the specified FLAVOR "
120
        "--flavors", action="callback", callback=parse_comma,
121
        type="string", default=None, dest="flavors", metavar="FLAVORS",
122
        help="Force all server creations to use one of the specified FLAVORS "
126 123
             "instead of a randomly chosen one. Supports both search by name "
127 124
             "(reg expression) with \"name:flavor name\" or by id with "
128 125
             "\"id:flavor id\"")
129 126
    parser.add_option(
130
        "--force-image", action="store",
131
        type="string", default=None, dest="force_image", metavar="IMAGE",
132
        help="Force all server creations to use the specified IMAGE "
127
        "--images", action="callback", callback=parse_comma,
128
        type="string", default=None, dest="images", metavar="IMAGES",
129
        help="Force all server creations to use one of the specified IMAGES "
133 130
             "instead of the default one (a Debian Base image). Just like the "
134
             "--force-flavor option, it supports both search by name and id")
131
             "--flavors option, it supports both search by name and id")
135 132
    parser.add_option(
136 133
        "--system-user", action="store",
137 134
        type="string", default=None, dest="system_user",
......
203 200
    if opts.final_report:
204 201
        opts.quiet = True
205 202

  
203
    # Check `--set-tests' and `--exclude-tests' options
204
    if opts.tests != "all" and \
205
            not (set(opts.tests)).issubset(set(TSUITES_NAMES)):
206
        raise optparse.OptionValueError("The selected set of tests is invalid")
207
    if opts.exclude_tests is not None and \
208
            not (set(opts.exclude_tests)).issubset(set(TSUITES_NAMES)):
209
        raise optparse.OptionValueError("The selected set of tests is invalid")
210

  
206 211
    # `token' is mandatory
207 212
    mandatory_argument(opts.token, "--token")
208 213
    # `auth_url' is mandatory
......
245 250

  
246 251
    # Run burnin
247 252
    # The return value denotes the success status
248
    return common.run(testsuites, failfast=opts.failfast,
249
                      final_report=opts.final_report)
253
    return common.run_burnin(testsuites, failfast=opts.failfast,
254
                             final_report=opts.final_report)
250 255

  
251 256

  
252 257
if __name__ == "__main__":

Also available in: Unified diff