Revision 22efe1fe snf-tools/synnefo_tools/burnin.py
b/snf-tools/synnefo_tools/burnin.py | ||
---|---|---|
51 | 51 |
from IPy import IP |
52 | 52 |
from multiprocessing import Process, Queue |
53 | 53 |
from random import choice |
54 |
from optparse import OptionParser, OptionValueError |
|
54 | 55 |
|
55 | 56 |
from kamaki.clients.compute import ComputeClient |
56 | 57 |
from kamaki.clients.cyclades import CycladesClient |
... | ... | |
1334 | 1335 |
else: |
1335 | 1336 |
print >> sys.stderr, "Use --delete-stale to delete them." |
1336 | 1337 |
|
1338 |
def parse_comma(option, opt, value, parser): |
|
1339 |
tests=set(['all', 'auth', 'images', 'flavors', |
|
1340 |
'servers', 'server_spawn', 'network_spawn']) |
|
1341 |
parse_input = value.split(',') |
|
1342 |
|
|
1343 |
if not (set(parse_input)).issubset(tests): |
|
1344 |
raise OptionValueError("The selected set of tests is invalid") |
|
1345 |
|
|
1346 |
setattr(parser.values, option.dest, value.split(',')) |
|
1347 |
|
|
1337 | 1348 |
|
1338 | 1349 |
def parse_arguments(args): |
1339 |
from optparse import OptionParser |
|
1340 | 1350 |
|
1341 | 1351 |
kw = {} |
1342 | 1352 |
kw["usage"] = "%prog [options]" |
... | ... | |
1346 | 1356 |
|
1347 | 1357 |
parser = OptionParser(**kw) |
1348 | 1358 |
parser.disable_interspersed_args() |
1359 |
|
|
1360 |
|
|
1349 | 1361 |
parser.add_option("--api", |
1350 | 1362 |
action="store", type="string", dest="api", |
1351 | 1363 |
help="The API URI to use to reach the Synnefo API", |
... | ... | |
1434 | 1446 |
help="Define the absolute path where the output \ |
1435 | 1447 |
log is stored. ", |
1436 | 1448 |
default="/var/log/burnin/") |
1449 |
parser.add_option("--set-tests", |
|
1450 |
action="callback", |
|
1451 |
dest = "tests", |
|
1452 |
type="string", |
|
1453 |
help='Set comma seperated tests for this run. \ |
|
1454 |
Available tests: auth, images, flavors, \ |
|
1455 |
servers, server_spawn, network_spawn. \ |
|
1456 |
Default = all', |
|
1457 |
default='all', |
|
1458 |
callback=parse_comma) |
|
1459 |
|
|
1437 | 1460 |
|
1438 | 1461 |
# FIXME: Change the default for build-fanout to 10 |
1439 | 1462 |
# FIXME: Allow the user to specify a specific set of Images to test |
... | ... | |
1446 | 1469 |
|
1447 | 1470 |
if not opts.show_stale: |
1448 | 1471 |
if not opts.force_imageid: |
1449 |
print >>sys.stderr, "The --image-id argument is mandatory." |
|
1472 |
print >>sys.stderr, "The --image-id argument is mandatory. \n" |
|
1473 |
parser.print_help() |
|
1474 |
sys.exit(1) |
|
1475 |
|
|
1476 |
if not opts.token: |
|
1477 |
print >>sys.stderr, "The --token argument is mandatory. \n" |
|
1450 | 1478 |
parser.print_help() |
1451 | 1479 |
sys.exit(1) |
1452 | 1480 |
|
... | ... | |
1458 | 1486 |
"Use a valid id, or `all'." |
1459 | 1487 |
sys.exit(1) |
1460 | 1488 |
|
1489 |
|
|
1490 |
|
|
1461 | 1491 |
return (opts, args) |
1462 | 1492 |
|
1463 | 1493 |
|
... | ... | |
1488 | 1518 |
return 0 |
1489 | 1519 |
|
1490 | 1520 |
# Initialize a kamaki instance, get flavors, images |
1491 |
|
|
1492 | 1521 |
c = ComputeClient(API, TOKEN) |
1493 | 1522 |
|
1494 | 1523 |
DIMAGES = c.list_images(detail=True) |
... | ... | |
1504 | 1533 |
test_images = filter(lambda x: x["id"] == opts.force_imageid, DIMAGES) |
1505 | 1534 |
|
1506 | 1535 |
#New folder for log per image |
1507 |
|
|
1508 | 1536 |
if not os.path.exists(opts.log_folder): |
1509 | 1537 |
os.mkdir(opts.log_folder) |
1510 | 1538 |
|
... | ... | |
1562 | 1590 |
query_interval=opts.query_interval, |
1563 | 1591 |
) |
1564 | 1592 |
|
1565 |
seq_cases = [UnauthorizedTestCase, ImagesTestCase, FlavorsTestCase, |
|
1566 |
ServersTestCase, ServerTestCase, NetworkTestCase] |
|
1593 |
test_dict = {'auth':UnauthorizedTestCase, |
|
1594 |
'images':ImagesTestCase, |
|
1595 |
'flavors':FlavorsTestCase, |
|
1596 |
'servers':ServersTestCase, |
|
1597 |
'server_spawn':ServerTestCase, |
|
1598 |
'network_spawn':NetworkTestCase} |
|
1599 |
|
|
1600 |
seq_cases = [] |
|
1601 |
if 'all' in opts.tests: |
|
1602 |
seq_cases = [UnauthorizedTestCase, ImagesTestCase, FlavorsTestCase, |
|
1603 |
ServersTestCase, ServerTestCase, NetworkTestCase] |
|
1604 |
else: |
|
1605 |
for test in opts.tests: |
|
1606 |
seq_cases.append(test_dict[test]) |
|
1607 |
|
|
1608 |
print seq_cases |
|
1609 |
sys.exit() |
|
1610 |
|
|
1567 | 1611 |
|
1568 | 1612 |
#folder for each image |
1569 | 1613 |
image_folder = os.path.join(test_folder, imageid) |
Also available in: Unified diff