Revision 58f6e5ca lib/backend.py
b/lib/backend.py | ||
---|---|---|
528 | 528 |
inst_os = OSFromDisk(instance.os) |
529 | 529 |
|
530 | 530 |
create_script = inst_os.create_script |
531 |
|
|
532 |
os_device = instance.FindDisk(os_disk) |
|
533 |
if os_device is None: |
|
534 |
logging.error("Can't find this device-visible name '%s'", os_disk) |
|
535 |
return False |
|
536 |
|
|
537 |
swap_device = instance.FindDisk(swap_disk) |
|
538 |
if swap_device is None: |
|
539 |
logging.error("Can't find this device-visible name '%s'", swap_disk) |
|
540 |
return False |
|
541 |
|
|
542 |
real_os_dev = _RecursiveFindBD(os_device) |
|
543 |
if real_os_dev is None: |
|
544 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
545 |
str(os_device)) |
|
546 |
real_os_dev.Open() |
|
547 |
|
|
548 |
real_swap_dev = _RecursiveFindBD(swap_device) |
|
549 |
if real_swap_dev is None: |
|
550 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
551 |
str(swap_device)) |
|
552 |
real_swap_dev.Open() |
|
531 |
create_env = OSEnvironment(instance) |
|
553 | 532 |
|
554 | 533 |
logfile = "%s/add-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, |
555 | 534 |
instance.name, int(time.time())) |
556 | 535 |
if not os.path.exists(constants.LOG_OS_DIR): |
557 | 536 |
os.mkdir(constants.LOG_OS_DIR, 0750) |
558 | 537 |
|
559 |
command = utils.BuildShellCmd("cd %s && %s -i %s -b %s -s %s &>%s", |
|
560 |
inst_os.path, create_script, instance.name, |
|
561 |
real_os_dev.dev_path, real_swap_dev.dev_path, |
|
562 |
logfile) |
|
563 |
env = {'HYPERVISOR': instance.hypervisor} |
|
538 |
command = utils.BuildShellCmd("cd %s && %s &>%s", |
|
539 |
inst_os.path, create_script, logfile) |
|
564 | 540 |
|
565 |
result = utils.RunCmd(command, env=env) |
|
541 |
result = utils.RunCmd(command, env=create_env)
|
|
566 | 542 |
if result.failed: |
567 | 543 |
logging.error("os create command '%s' returned error: %s, logfile: %s," |
568 | 544 |
" output: %s", command, result.fail_reason, logfile, |
Also available in: Unified diff