diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index fe6a0df8366fbbd369ff3f88c760a1c04227c8fe..ef7851348b76192e6926fbc2084dbd2d4ae2e2a8 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -352,20 +352,6 @@ class NodeHttpServer(http.server.HttpServer): # export/import -------------------------- - @staticmethod - def perspective_snapshot_export(params): - """Export a given snapshot. - - """ - disk = objects.Disk.FromDict(params[0]) - dest_node = params[1] - instance = objects.Instance.FromDict(params[2]) - cluster_name = params[3] - dev_idx = params[4] - debug = params[5] - return backend.ExportSnapshot(disk, dest_node, instance, - cluster_name, dev_idx, debug) - @staticmethod def perspective_finalize_export(params): """Expose the finalize export functionality. @@ -487,16 +473,6 @@ class NodeHttpServer(http.server.HttpServer): inst = objects.Instance.FromDict(inst_s) return backend.RunRenameInstance(inst, old_name, debug) - @staticmethod - def perspective_instance_os_import(params): - """Run the import function of an OS onto a given instance. - - """ - inst_s, src_node, src_images, cluster_name, debug = params - inst = objects.Instance.FromDict(inst_s) - return backend.ImportOSIntoInstance(inst, src_node, src_images, - cluster_name, debug) - @staticmethod def perspective_instance_shutdown(params): """Shutdown an instance. diff --git a/lib/backend.py b/lib/backend.py index 897b557cb47affb7ad8eac435c03ee7be180d39b..968195ca7224643e228befc98be9a84a620930e8 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2016,66 +2016,6 @@ def BlockdevSnapshot(disk): disk.unique_id, disk.dev_type) -def ExportSnapshot(disk, dest_node, instance, cluster_name, idx, debug): - """Export a block device snapshot to a remote node. - - @type disk: L{objects.Disk} - @param disk: the description of the disk to export - @type dest_node: str - @param dest_node: the destination node to export to - @type instance: L{objects.Instance} - @param instance: the instance object to whom the disk belongs - @type cluster_name: str - @param cluster_name: the cluster name, needed for SSH hostalias - @type idx: int - @param idx: the index of the disk in the instance's disk list, - used to export to the OS scripts environment - @type debug: integer - @param debug: debug level, passed to the OS scripts - @rtype: None - - """ - inst_os = OSFromDisk(instance.os) - export_env = OSEnvironment(instance, inst_os, debug) - - export_script = inst_os.export_script - - logfile = _InstanceLogName("export", inst_os.name, instance.name) - if not os.path.exists(constants.LOG_OS_DIR): - os.mkdir(constants.LOG_OS_DIR, 0750) - - real_disk = _OpenRealBD(disk) - - export_env['EXPORT_DEVICE'] = real_disk.dev_path - export_env['EXPORT_INDEX'] = str(idx) - - destdir = utils.PathJoin(constants.EXPORT_DIR, instance.name + ".new") - destfile = disk.physical_id[1] - - # 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("set -e; set -o pipefail; cd %s; %s 2>%s", - inst_os.path, export_script, logfile) - - comprcmd = "gzip" - - destcmd = utils.BuildShellCmd("mkdir -p %s && cat > %s", - destdir, utils.PathJoin(destdir, destfile)) - remotecmd = _GetSshRunner(cluster_name).BuildCmd(dest_node, - constants.GANETI_RUNAS, - destcmd) - - # all commands have been checked, so we're safe to combine them - command = '|'.join([expcmd, comprcmd, utils.ShellQuoteArgs(remotecmd)]) - - result = utils.RunCmd(["bash", "-c", command], env=export_env) - - if result.failed: - _Fail("OS snapshot export command '%s' returned error: %s" - " output: %s", command, result.fail_reason, result.output) - - def FinalizeExport(instance, snap_disks): """Write out the export configuration information. @@ -2175,55 +2115,6 @@ def ExportInfo(dest): return config.Dumps() -def ImportOSIntoInstance(instance, src_node, src_images, cluster_name, debug): - """Import an os image into an instance. - - @type instance: L{objects.Instance} - @param instance: instance to import the disks into - @type src_node: string - @param src_node: source node for the disk images - @type src_images: list of string - @param src_images: absolute paths of the disk images - @type debug: integer - @param debug: debug level, passed to the OS scripts - @rtype: list of boolean - @return: each boolean represent the success of importing the n-th disk - - """ - inst_os = OSFromDisk(instance.os) - import_env = OSEnvironment(instance, inst_os, debug) - import_script = inst_os.import_script - - logfile = _InstanceLogName("import", instance.os, instance.name) - if not os.path.exists(constants.LOG_OS_DIR): - os.mkdir(constants.LOG_OS_DIR, 0750) - - comprcmd = "gunzip" - impcmd = utils.BuildShellCmd("(cd %s; %s >%s 2>&1)", inst_os.path, - import_script, logfile) - - final_result = [] - for idx, image in enumerate(src_images): - if image: - destcmd = utils.BuildShellCmd('cat %s', image) - remotecmd = _GetSshRunner(cluster_name).BuildCmd(src_node, - constants.GANETI_RUNAS, - destcmd) - command = '|'.join([utils.ShellQuoteArgs(remotecmd), comprcmd, impcmd]) - import_env['IMPORT_DEVICE'] = import_env['DISK_%d_PATH' % idx] - import_env['IMPORT_INDEX'] = str(idx) - result = utils.RunCmd(command, env=import_env) - if result.failed: - logging.error("Disk import command '%s' returned error: %s" - " output: %s", command, result.fail_reason, - result.output) - final_result.append("error importing disk %d: %s, %s" % - (idx, result.fail_reason, result.output[-100])) - - if final_result: - _Fail("; ".join(final_result), log=False) - - def ListExports(): """Return a list of exports currently available on this machine. diff --git a/lib/rpc.py b/lib/rpc.py index 724db859d372e34399bd2f122a8ff526f4e3942f..c6e7cb20f9dfecfa9ff79dcd9631b1950dce6881 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -1002,18 +1002,6 @@ class RpcRunner(object): """ return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()]) - def call_snapshot_export(self, node, snap_bdev, dest_node, instance, - cluster_name, idx, debug): - """Request the export of a given snapshot. - - This is a single-node call. - - """ - return self._SingleNodeCall(node, "snapshot_export", - [snap_bdev.ToDict(), dest_node, - self._InstDict(instance), cluster_name, - idx, debug]) - def call_finalize_export(self, node, instance, snap_disks): """Request the completion of an export operation. @@ -1040,17 +1028,6 @@ class RpcRunner(object): """ return self._SingleNodeCall(node, "export_info", [path]) - def call_instance_os_import(self, node, inst, src_node, src_images, - cluster_name, debug): - """Request the import of a backup into an instance. - - This is a single-node call. - - """ - return self._SingleNodeCall(node, "instance_os_import", - [self._InstDict(inst), src_node, src_images, - cluster_name, debug]) - def call_export_list(self, node_list): """Gets the stored exports list.