Streamlining handling of spindles and default templates
[ganeti-local] / lib / ovf.py
index dc58133..be611d8 100644 (file)
@@ -537,7 +537,7 @@ class OVFReader(object):
                                                          GANETI_SCHEMA)
         ganeti_data["link"] = network_ganeti_data.findtext("{%s}Link" %
                                                            GANETI_SCHEMA)
-        ganeti_data["network"] = network_ganeti_data.findtext("{%s}Network" %
+        ganeti_data["network"] = network_ganeti_data.findtext("{%s}Net" %
                                                               GANETI_SCHEMA)
       mac_data = None
       if network_data:
@@ -760,7 +760,7 @@ class OVFWriter(object):
       SubElementText(nic, "gnt:MACAddress", network["mac"])
       SubElementText(nic, "gnt:IPAddress", network["ip"])
       SubElementText(nic, "gnt:Link", network["link"])
-      SubElementText(nic, "gnt:Network", network["network"])
+      SubElementText(nic, "gnt:Net", network["network"])
 
   def SaveVirtualSystemData(self, name, vcpus, memory):
     """Convert virtual system information to OVF sections.
@@ -833,8 +833,8 @@ class OVFWriter(object):
     raw_string = ET.tostring(self.tree)
     parsed_xml = xml.dom.minidom.parseString(raw_string)
     xml_string = parsed_xml.toprettyxml(indent="  ")
-    text_re = re.compile(">\n\s+([^<>\s].*?)\n\s+</", re.DOTALL)
-    return text_re.sub(">\g<1></", xml_string)
+    text_re = re.compile(r">\n\s+([^<>\s].*?)\n\s+</", re.DOTALL)
+    return text_re.sub(r">\g<1></", xml_string)
 
 
 class Converter(object):
@@ -1408,7 +1408,7 @@ class OVFImporter(Converter):
         _, disk_path = self._CompressDisk(disk_path, disk_compression,
                                           DECOMPRESS)
         disk, _ = os.path.splitext(disk)
-      if self._GetDiskQemuInfo(disk_path, "file format: (\S+)") != "raw":
+      if self._GetDiskQemuInfo(disk_path, r"file format: (\S+)") != "raw":
         logging.info("Conversion to raw format is required")
       ext, new_disk_path = self._ConvertDisk("raw", disk_path)
 
@@ -1665,7 +1665,8 @@ class OVFExporter(Converter):
     counter = 0
     while True:
       data_link = \
-        self.config_parser.get(constants.INISECT_INS, "nic%s_network" % counter)
+        self.config_parser.get(constants.INISECT_INS,
+                               "nic%s_link" % counter)
       if data_link is None:
         break
       results.append({
@@ -1675,9 +1676,9 @@ class OVFExporter(Converter):
                                       "nic%s_mac" % counter),
         "ip": self.config_parser.get(constants.INISECT_INS,
                                      "nic%s_ip" % counter),
-        "link": self.config_parser.get(constants.INISECT_INS,
-                                       "nic%s_link" % counter),
-        "network": data_link,
+        "network": self.config_parser.get(constants.INISECT_INS,
+                                          "nic%s_network" % counter),
+        "link": data_link,
       })
       if results[counter]["mode"] not in constants.NIC_VALID_MODES:
         raise errors.OpPrereqError("Network mode %s not recognized"
@@ -1709,7 +1710,7 @@ class OVFExporter(Converter):
     ext, new_disk_path = self._ConvertDisk(self.options.disk_format, disk_path)
     results["format"] = self.options.disk_format
     results["virt-size"] = self._GetDiskQemuInfo(
-      new_disk_path, "virtual size: \S+ \((\d+) bytes\)")
+      new_disk_path, r"virtual size: \S+ \((\d+) bytes\)")
     if compression:
       ext2, new_disk_path = self._CompressDisk(new_disk_path, "gzip",
                                                COMPRESS)