Revision a07ae57f
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 |
|
357 |
|
|
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) |
|
372 |
|
|
373 |
AssertCommand(["gnt-instance", "reinstall", |
|
374 |
"--os-parameters", "os-image=" + image, |
|
375 |
"-f", instance.name]) |
|
376 |
|
|
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 |
|
392 |
|
|
393 |
url = "http://localhost:%d/%s" % (port, os.path.basename(image)) |
|
394 |
AssertCommand(["gnt-instance", "reinstall", |
|
395 |
"--os-parameters", "os-image=" + url, |
|
396 |
"-f", instance.name]) |
|
397 |
|
|
398 |
AssertCommand(["rm", "-f", image]) |
|
399 |
finally: |
|
400 |
server_process.terminate() |
|
401 |
|
|
402 |
AssertCommand(["gnt-instance", "reinstall", |
|
403 |
"--os-parameters", "os-image=NonExistantOsForQa", |
|
404 |
"-f", instance.name], fail=True) |
|
405 |
|
|
406 |
AssertCommand(["gnt-instance", "reinstall", |
|
407 |
"--os-parameters", "os-image=http://NonExistantOsForQa", |
|
408 |
"-f", instance.name], fail=True) |
|
409 |
|
|
343 | 410 |
AssertCommand(["gnt-instance", "reinstall", "-f", instance.name]) |
344 | 411 |
|
345 | 412 |
# Test with non-existant OS definition |
... | ... | |
547 | 614 |
["--disk", "-1:remove", "--hotplug"], |
548 | 615 |
]) |
549 | 616 |
|
617 |
url = "http://example.com/busybox.img" |
|
618 |
args.extend([ |
|
619 |
["--os-parameters", "os-image=" + url], |
|
620 |
["--os-parameters", "os-image=default"] |
|
621 |
]) |
|
622 |
|
|
550 | 623 |
for alist in args: |
551 | 624 |
AssertCommand(["gnt-instance", "modify"] + alist + [instance.name]) |
552 | 625 |
|
Also available in: Unified diff