Revision 9bd52012
b/qa/qa_instance.py | ||
---|---|---|
340 | 340 |
print qa_utils.FormatInfo("Test not supported for diskless instances") |
341 | 341 |
return |
342 | 342 |
|
343 |
master = qa_config.GetMasterNode() |
|
344 |
|
|
345 |
AssertCommand(["gnt-backup", "export", "-n", master.primary, instance.name]) |
|
346 |
|
|
347 |
instance_info = GetInstanceInfo(instance.name) |
|
348 |
disk0 = None |
|
349 |
|
|
350 |
for volume in instance_info["volumes"]: |
|
351 |
if "disk0" in volume: |
|
352 |
i = volume.find("/") |
|
353 |
if i >= 0: |
|
354 |
disk0_id = volume[(i + 1):] |
|
355 |
else: |
|
356 |
disk0_id = volume |
|
343 |
qa_storage = qa_config.get("qa-storage") |
|
357 | 344 |
|
358 |
disk0_path = "/srv/ganeti/export/%s/%s.snap" % (instance.name, disk0_id) |
|
359 |
|
|
360 |
try: |
|
361 |
AssertCommand(["stat", disk0_path]) |
|
362 |
disk0 = disk0_path |
|
363 |
break |
|
364 |
except qa_error.Error: |
|
365 |
pass |
|
366 |
|
|
367 |
if disk0 is None: |
|
368 |
raise qa_error.Error("Could not determine exported disk for instance '%s'" % |
|
369 |
instance.name) |
|
370 |
|
|
371 |
image = qa_utils.BackupFile(master.primary, disk0) |
|
345 |
if qa_storage is None: |
|
346 |
print qa_utils.FormatInfo("Test not supported because the additional QA" |
|
347 |
" storage is not available") |
|
348 |
else: |
|
349 |
# Reinstall with OS image from QA storage |
|
350 |
url = "%s/busybox.img" % qa_storage |
|
351 |
AssertCommand(["gnt-instance", "reinstall", |
|
352 |
"--os-parameters", "os-image=" + url, |
|
353 |
"-f", instance.name]) |
|
372 | 354 |
|
373 |
AssertCommand(["gnt-instance", "reinstall", |
|
374 |
"--os-parameters", "os-image=" + image, |
|
375 |
"-f", instance.name]) |
|
355 |
# Reinstall with OS image as local file on the node |
|
356 |
pnode = _GetInstanceField(instance.name, "pnode") |
|
376 | 357 |
|
377 |
try: |
|
378 |
port = 8000 |
|
379 |
|
|
380 |
while True: |
|
381 |
cmd = "( cd /srv/ganeti/export; python -m SimpleHTTPServer %d )" % port |
|
382 |
ssh_cmd = qa_utils.GetSSHCommand(master.primary, cmd) |
|
383 |
|
|
384 |
try: |
|
385 |
server_process = qa_utils.StartLocalCommand(ssh_cmd) |
|
386 |
break |
|
387 |
except OSError: |
|
388 |
if port < 9000: |
|
389 |
port += 1 |
|
390 |
else: |
|
391 |
raise |
|
358 |
cmd = ("wget -O busybox.img %s &> /dev/null &&" |
|
359 |
" echo $(pwd)/busybox.img") % url |
|
360 |
image = qa_utils.GetCommandOutput(pnode, cmd).strip() |
|
392 | 361 |
|
393 |
url = "http://localhost:%d/%s" % (port, os.path.basename(image)) |
|
394 | 362 |
AssertCommand(["gnt-instance", "reinstall", |
395 |
"--os-parameters", "os-image=" + url,
|
|
363 |
"--os-parameters", "os-image=" + image,
|
|
396 | 364 |
"-f", instance.name]) |
397 | 365 |
|
398 |
AssertCommand(["rm", "-f", image]) |
|
399 |
finally: |
|
400 |
server_process.terminate() |
|
401 |
|
|
366 |
# Reinstall non existing local file |
|
402 | 367 |
AssertCommand(["gnt-instance", "reinstall", |
403 | 368 |
"--os-parameters", "os-image=NonExistantOsForQa", |
404 | 369 |
"-f", instance.name], fail=True) |
405 | 370 |
|
371 |
# Reinstall non existing URL |
|
406 | 372 |
AssertCommand(["gnt-instance", "reinstall", |
407 | 373 |
"--os-parameters", "os-image=http://NonExistantOsForQa", |
408 | 374 |
"-f", instance.name], fail=True) |
409 | 375 |
|
376 |
# Reinstall using OS scripts |
|
410 | 377 |
AssertCommand(["gnt-instance", "reinstall", "-f", instance.name]) |
411 | 378 |
|
412 | 379 |
# Test with non-existant OS definition |
Also available in: Unified diff