[et-mgmt-tools] [PATCH 2 of 5] Fix multiple disks
john.levon at sun.com
john.levon at sun.com
Wed Jul 9 18:29:36 UTC 2008
# HG changeset patch
# User john.levon at sun.com
# Date 1215627964 25200
# Node ID 96d74c328fd60b05c27af8ea1b4412756bf329db
# Parent c6d2254702a49d9674d6c549bd57cb87ac920e87
Fix multiple disks
Fix handling of multiple disks.
Signed-off-by: John Levon <john.levon at sun.com>
diff --git a/virtconv/parsers/virtimage.py b/virtconv/parsers/virtimage.py
--- a/virtconv/parsers/virtimage.py
+++ b/virtconv/parsers/virtimage.py
@@ -117,12 +117,12 @@
# FIXME: needs updating for later Xen enhancements; need to
# implement capabilities checking for max disks etc.
- pv_disks.append("""<drive disk="%s" target="xvd%s" />""" %
+ pv_disks.append("""<drive disk="%s" target="xvd%s" />\n""" %
(path, ascii_letters[number % 26]))
- hvm_disks.append("""<drive disk="%s" target="hd%s" />""" %
+ hvm_disks.append("""<drive disk="%s" target="hd%s" />\n""" %
(path, ascii_letters[number % 26]))
storage_disks.append(
- """<disk file="%s" use="system" format="raw"/>""" % path)
+ """<disk file="%s" use="system" format="raw"/>\n""" % path)
if vm.type == vmconfig.VM_TYPE_PV:
boot_template = pv_boot_template
diff --git a/virtconv/parsers/vmx.py b/virtconv/parsers/vmx.py
--- a/virtconv/parsers/vmx.py
+++ b/virtconv/parsers/vmx.py
@@ -60,6 +60,7 @@
lines.append(line)
config = {}
+ disks = []
# split out all remaining entries of key = value form
for (line_nr, line) in enumerate(lines):
@@ -69,6 +70,9 @@
value = after_eq.replace('"',"")
value = value.strip()
config[key] = value
+ # FIXME: this should probably be a lot smarter.
+ if value.endswith(".vmdk"):
+ disks += [ value ]
except:
raise Exception("Syntax error at line %d: %s" %
(line_nr + 1, line.strip()))
@@ -80,10 +84,6 @@
vm.memory = config.get("memsize")
vm.description = config.get("annotation")
vm.nr_vcpus = config.get("numvcpus")
-
- # FIXME: this should probably be a lot smarter. I don't think
- # this even gets disk numbering right.
- disks = [ d for d in config.values() if d.endswith(".vmdk") ]
for (number, path) in enumerate(disks):
vm.disks += [ vmconfig.disk(path, number, vmconfig.DISK_TYPE_VMDK) ]
More information about the et-mgmt-tools
mailing list