logging.error("os create command '%s' returned error: %s, logfile: %s,"
" output: %s", result.cmd, result.fail_reason, logfile,
result.output)
- lines = [val.encode("string_escape")
+ lines = [utils.SafeEncode(val)
for val in utils.TailFile(logfile, lines=20)]
return (False, "OS create script failed (%s), last lines in the"
" log file:\n%s" % (result.fail_reason, "\n".join(lines)))
if result.failed:
logging.error("os create command '%s' returned error: %s output: %s",
result.cmd, result.fail_reason, result.output)
- lines = [val.encode("string_escape")
+ lines = [utils.SafeEncode(val)
for val in utils.TailFile(logfile, lines=20)]
return (False, "OS rename script failed (%s), last lines in the"
" log file:\n%s" % (result.fail_reason, "\n".join(lines)))
result = {}
result['OS_API_VERSION'] = '%d' % constants.OS_API_VERSION
result['INSTANCE_NAME'] = instance.name
+ result['INSTANCE_OS'] = instance.os
result['HYPERVISOR'] = instance.hypervisor
result['DISK_COUNT'] = '%d' % len(instance.disks)
result['NIC_COUNT'] = '%d' % len(instance.nics)
real_disk.Open()
result['DISK_%d_PATH' % idx] = real_disk.dev_path
# FIXME: When disks will have read-only mode, populate this
- result['DISK_%d_ACCESS' % idx] = 'W'
+ result['DISK_%d_ACCESS' % idx] = disk.mode
if constants.HV_DISK_TYPE in instance.hvparams:
result['DISK_%d_FRONTEND_TYPE' % idx] = \
instance.hvparams[constants.HV_DISK_TYPE]
#logging.exception("Error while closing fd %s", fd)
pass
- return result == 0, output
+ return result == 0, utils.SafeEncode(output.strip())
def RunHooks(self, hpath, phase, env):
"""Run the scripts in the hooks directory.