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)
+ cluster_name, dev_idx, debug)
@staticmethod
def perspective_finalize_export(params):
inst_s = params[0]
inst = objects.Instance.FromDict(inst_s)
reinstall = params[1]
- return backend.InstanceOsAdd(inst, reinstall)
+ debug = params[2]
+ return backend.InstanceOsAdd(inst, reinstall, debug)
@staticmethod
def perspective_instance_run_rename(params):
"""Runs the OS rename script for an instance.
"""
- inst_s, old_name = params
+ inst_s, old_name, debug = params
inst = objects.Instance.FromDict(inst_s)
- return backend.RunRenameInstance(inst, old_name)
+ 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 = params
+ 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)
+ cluster_name, debug)
@staticmethod
def perspective_instance_shutdown(params):
return output
-def InstanceOsAdd(instance, reinstall):
+def InstanceOsAdd(instance, reinstall, debug):
"""Add an OS to an instance.
@type instance: L{objects.Instance}
@param instance: Instance whose OS is to be installed
@type reinstall: boolean
@param reinstall: whether this is an instance reinstall
+ @type debug: integer
+ @param debug: debug level, passed to the OS scripts
@rtype: None
"""
inst_os = OSFromDisk(instance.os)
- create_env = OSEnvironment(instance, inst_os)
+ create_env = OSEnvironment(instance, inst_os, debug)
if reinstall:
create_env['INSTANCE_REINSTALL'] = "1"
" log file:\n%s", result.fail_reason, "\n".join(lines), log=False)
-def RunRenameInstance(instance, old_name):
+def RunRenameInstance(instance, old_name, debug):
"""Run the OS rename script for an instance.
@type instance: L{objects.Instance}
@param instance: Instance whose OS is to be installed
@type old_name: string
@param old_name: previous instance name
+ @type debug: integer
+ @param debug: debug level, passed to the OS scripts
@rtype: boolean
@return: the success of the operation
"""
inst_os = OSFromDisk(instance.os)
- rename_env = OSEnvironment(instance, inst_os)
+ rename_env = OSEnvironment(instance, inst_os, debug)
rename_env['OLD_INSTANCE_NAME'] = old_name
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os,
disk.unique_id, disk.dev_type)
-def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
+def ExportSnapshot(disk, dest_node, instance, cluster_name, idx, debug):
"""Export a block device snapshot to a remote node.
@type disk: L{objects.Disk}
@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)
+ export_env = OSEnvironment(instance, inst_os, debug)
export_script = inst_os.export_script
return config.Dumps()
-def ImportOSIntoInstance(instance, src_node, src_images, cluster_name):
+def ImportOSIntoInstance(instance, src_node, src_images, cluster_name, debug):
"""Import an os image into an instance.
@type instance: L{objects.Instance}
@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)
+ import_env = OSEnvironment(instance, inst_os, debug)
import_script = inst_os.import_script
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os,
_StartInstanceDisks(self, inst, None)
try:
feedback_fn("Running the instance OS create scripts...")
- result = self.rpc.call_instance_os_add(inst.primary_node, inst, True)
+ # FIXME: pass debug option from opcode to backend
+ result = self.rpc.call_instance_os_add(inst.primary_node, inst, True, 0)
result.Raise("Could not install OS for instance %s on node %s" %
(inst.name, inst.primary_node))
finally:
_StartInstanceDisks(self, inst, None)
try:
result = self.rpc.call_instance_run_rename(inst.primary_node, inst,
- old_name)
+ old_name, 0)
msg = result.fail_msg
if msg:
msg = ("Could not run OS rename script for instance %s on node %s"
if iobj.disk_template != constants.DT_DISKLESS:
if self.op.mode == constants.INSTANCE_CREATE:
feedback_fn("* running the instance OS create scripts...")
- result = self.rpc.call_instance_os_add(pnode_name, iobj, False)
+ # FIXME: pass debug option from opcode to backend
+ result = self.rpc.call_instance_os_add(pnode_name, iobj, False, 0)
result.Raise("Could not add os for instance %s"
" on node %s" % (instance, pnode_name))
src_node = self.op.src_node
src_images = self.src_images
cluster_name = self.cfg.GetClusterName()
+ # FIXME: pass debug option from opcode to backend
import_result = self.rpc.call_instance_os_import(pnode_name, iobj,
src_node, src_images,
- cluster_name)
+ cluster_name, 0)
msg = import_result.fail_msg
if msg:
self.LogWarning("Error while importing the disk images for instance"
feedback_fn("Exporting snapshot %s from %s to %s" %
(idx, src_node, dst_node.name))
if dev:
+ # FIXME: pass debug from opcode to backend
result = self.rpc.call_snapshot_export(src_node, dev, dst_node.name,
- instance, cluster_name, idx)
+ instance, cluster_name,
+ idx, 0)
msg = result.fail_msg
if msg:
self.LogWarning("Could not export disk/%s from node %s to"
[self._InstDict(inst), reboot_type,
shutdown_timeout])
- def call_instance_os_add(self, node, inst, reinstall):
+ def call_instance_os_add(self, node, inst, reinstall, debug):
"""Installs an OS on the given instance.
This is a single-node call.
"""
return self._SingleNodeCall(node, "instance_os_add",
- [self._InstDict(inst), reinstall])
+ [self._InstDict(inst), reinstall, debug])
- def call_instance_run_rename(self, node, inst, old_name):
+ def call_instance_run_rename(self, node, inst, old_name, debug):
"""Run the OS rename script for an instance.
This is a single-node call.
"""
return self._SingleNodeCall(node, "instance_run_rename",
- [self._InstDict(inst), old_name])
+ [self._InstDict(inst), old_name, debug])
def call_instance_info(self, node, instance, hname):
"""Returns information about a single instance.
return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()])
def call_snapshot_export(self, node, snap_bdev, dest_node, instance,
- cluster_name, idx):
+ 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])
+ self._InstDict(instance), cluster_name,
+ idx, debug])
def call_finalize_export(self, node, instance, snap_disks):
"""Request the completion of an export operation.
return self._SingleNodeCall(node, "export_info", [path])
def call_instance_os_import(self, node, inst, src_node, src_images,
- cluster_name):
+ 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])
+ cluster_name, debug])
def call_export_list(self, node_list):
"""Gets the stored exports list.