Revision ff38b6c0
b/lib/backend.py | ||
---|---|---|
585 | 585 |
inst_os = OSFromDisk(instance.os) |
586 | 586 |
|
587 | 587 |
script = inst_os.rename_script |
588 |
|
|
589 |
os_device = instance.FindDisk(os_disk) |
|
590 |
if os_device is None: |
|
591 |
logging.error("Can't find this device-visible name '%s'", os_disk) |
|
592 |
return False |
|
593 |
|
|
594 |
swap_device = instance.FindDisk(swap_disk) |
|
595 |
if swap_device is None: |
|
596 |
logging.error("Can't find this device-visible name '%s'", swap_disk) |
|
597 |
return False |
|
598 |
|
|
599 |
real_os_dev = _RecursiveFindBD(os_device) |
|
600 |
if real_os_dev is None: |
|
601 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
602 |
str(os_device)) |
|
603 |
real_os_dev.Open() |
|
604 |
|
|
605 |
real_swap_dev = _RecursiveFindBD(swap_device) |
|
606 |
if real_swap_dev is None: |
|
607 |
raise errors.BlockDeviceError("Block device '%s' is not set up" % |
|
608 |
str(swap_device)) |
|
609 |
real_swap_dev.Open() |
|
588 |
rename_env = OSEnvironment(instance) |
|
589 |
rename_env['OLD_INSTANCE_NAME'] = old_name |
|
610 | 590 |
|
611 | 591 |
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, |
612 | 592 |
old_name, |
... | ... | |
614 | 594 |
if not os.path.exists(constants.LOG_OS_DIR): |
615 | 595 |
os.mkdir(constants.LOG_OS_DIR, 0750) |
616 | 596 |
|
617 |
command = utils.BuildShellCmd("cd %s && %s -o %s -n %s -b %s -s %s &>%s", |
|
618 |
inst_os.path, script, old_name, instance.name, |
|
619 |
real_os_dev.dev_path, real_swap_dev.dev_path, |
|
620 |
logfile) |
|
597 |
command = utils.BuildShellCmd("cd %s && %s &>%s", |
|
598 |
inst_os.path, script, logfile) |
|
621 | 599 |
|
622 |
result = utils.RunCmd(command) |
|
600 |
result = utils.RunCmd(command, env=rename_env)
|
|
623 | 601 |
|
624 | 602 |
if result.failed: |
625 | 603 |
logging.error("os create command '%s' returned error: %s output: %s", |
Also available in: Unified diff