From 0607699d0bf6d5f8426fc3c74138ea34ce10d2ac Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 22 Oct 2008 14:09:11 +0000 Subject: [PATCH] Convert ExportSnapshot to OS API 10 We pass the data via the environment rather than on the command line, as API 10 says. All the rest remains the same, and we export just one disk, as the master calls this function for every snapshotted disk. Reviewed-by: iustinp --- lib/backend.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 6aa8c8362..2ac24e019 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1343,9 +1343,7 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name): True if successful, False otherwise. """ - # TODO(ultrotter): Import/Export still to be converted to OS API 10 - logging.error("Import/Export still to be converted to OS API 10") - return False + export_env = OSEnvironment(instance) inst_os = OSFromDisk(instance.os) export_script = inst_os.export_script @@ -1354,12 +1352,13 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name): instance.name, int(time.time())) if not os.path.exists(constants.LOG_OS_DIR): os.mkdir(constants.LOG_OS_DIR, 0750) - - real_os_dev = _RecursiveFindBD(disk) - if real_os_dev is None: + real_disk = _RecursiveFindBD(disk) + if real_disk is None: raise errors.BlockDeviceError("Block device '%s' is not set up" % str(disk)) - real_os_dev.Open() + real_disk.Open() + + export_env['EXPORT_DEVICE'] = real_disk.dev_path destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new") destfile = disk.physical_id[1] @@ -1367,10 +1366,8 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name): # the target command is built out of three individual commands, # which are joined by pipes; we check each individual command for # valid parameters - - expcmd = utils.BuildShellCmd("cd %s; %s -i %s -b %s 2>%s", inst_os.path, - export_script, instance.name, - real_os_dev.dev_path, logfile) + expcmd = utils.BuildShellCmd("cd %s; %s 2>%s", inst_os.path, + export_script, logfile) comprcmd = "gzip" @@ -1383,7 +1380,7 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name): # all commands have been checked, so we're safe to combine them command = '|'.join([expcmd, comprcmd, utils.ShellQuoteArgs(remotecmd)]) - result = utils.RunCmd(command) + result = utils.RunCmd(command, env=export_env) if result.failed: logging.error("os snapshot export command '%s' returned error: %s" -- GitLab