# AllocationUnits values and conversion
ALLOCATION_UNITS = {
- 'b': ["bytes", "b"],
- 'kb': ["kilobytes", "kb", "byte * 2^10", "kibibytes", "kib"],
- 'mb': ["megabytes", "mb", "byte * 2^20", "mebibytes", "mib"],
- 'gb': ["gigabytes", "gb", "byte * 2^30", "gibibytes", "gib"],
+ "b": ["bytes", "b"],
+ "kb": ["kilobytes", "kb", "byte * 2^10", "kibibytes", "kib"],
+ "mb": ["megabytes", "mb", "byte * 2^20", "mebibytes", "mib"],
+ "gb": ["gigabytes", "gb", "byte * 2^30", "gibibytes", "gib"],
}
CONVERT_UNITS_TO_MB = {
- 'b': lambda x: x / (1024 * 1024),
- 'kb': lambda x: x / 1024,
- 'mb': lambda x: x,
- 'gb': lambda x: x * 1024,
+ "b": lambda x: x / (1024 * 1024),
+ "kb": lambda x: x / 1024,
+ "mb": lambda x: x,
+ "gb": lambda x: x * 1024,
}
# Names of the config fields
COW: "http://www.gnome.org/~markmc/qcow-image-format.html",
}
+
def CheckQemuImg():
""" Make sure that qemu-img is present before performing operations.
raise errors.OpPrereqError("qemu-img not found at build time, unable"
" to continue")
+
def LinkFile(old_path, prefix=None, suffix=None, directory=None):
"""Create link with a given prefix and suffix.
prefix=disk_name, dir=self.output_dir)
self.temp_file_manager.Add(new_disk_path)
args = [
- "qemu-img",
+ constants.QEMUIMG_PATH,
"convert",
"-O",
disk_format,
"""
CheckQemuImg()
- args = ["qemu-img", "info", disk_path]
+ args = [constants.QEMUIMG_PATH, "info", disk_path]
run_result = utils.RunCmd(args, cwd=os.getcwd())
if run_result.failed:
raise errors.OpPrereqError("Gathering info about the disk using qemu-img"
(disk_id, disk_desc["size"]))
new_path = utils.PathJoin(self.output_dir, str(disk_id))
args = [
- "qemu-img",
+ constants.QEMUIMG_PATH,
"create",
"-f",
"raw",