Signed-off-by: Agata Murawska <[email protected]>
---
 lib/ovf.py |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/ovf.py b/lib/ovf.py
index 87e79e3..f7f32ad 100644
--- a/lib/ovf.py
+++ b/lib/ovf.py
@@ -514,11 +514,11 @@ class OVFWriter(object):
   @ivar hardware_list: list of items prepared for VirtualHardwareSection
 
   """
-  def __init__(self, ganeti_opts):
+  def __init__(self, has_gnt_sec):
     """Initialize the writer - set the top element.
 
-    @type ganeti_opts: bool
-    @param ganeti_opts: if the Ganeti schema should be added - i.e. this means
+    @type has_gnt_sec: bool
+    @param has_gnt_sec: if the Ganeti schema should be added - i.e. this means
       that Ganeti section will be present
 
     """
@@ -530,7 +530,7 @@ class OVFWriter(object):
       "xmlns": OVF_SCHEMA,
       "xml:lang": "en-US",
     }
-    if ganeti_opts:
+    if has_gnt_sec:
       env_attribs["xmlns:gnt"] = GANETI_SCHEMA
     self.tree = ET.Element("Envelope", attrib=env_attribs)
     self.hardware_list = []
@@ -1391,10 +1391,10 @@ class OVFExporter(Converter):
     @type input_path: string
     @param input_path: absolute path to the config.ini input file
 
-    @raises errors.OpPrereqError: error when reading the config file
+    @raise errors.OpPrereqError: error when reading the config file
 
     """
-    (input_dir, _) = os.path.split(input_path)
+    input_dir = os.path.dirname(input_path)
     self.input_path = input_path
     self.input_dir = input_dir
     if self.options.output_dir:
@@ -1406,7 +1406,7 @@ class OVFExporter(Converter):
     try:
       self.config_parser.read(input_path)
     except ConfigParser.MissingSectionHeaderError, err:
-      raise errors.OpPrereqError("Error when trying to read %s\n\t%s" %
+      raise errors.OpPrereqError("Error when trying to read %s: %s" %
                                  (input_path, err))
     if self.options.ova_package:
       self.temp_dir = tempfile.mkdtemp()
@@ -1421,7 +1421,7 @@ class OVFExporter(Converter):
     @rtype: string
     @return: name of Ganeti instance
 
-    @raises errors.OpPrereqError: if name of the instance is not provided
+    @raise errors.OpPrereqError: if name of the instance is not provided
 
     """
     if self.options.name:
@@ -1438,7 +1438,7 @@ class OVFExporter(Converter):
     @rtype: int
     @return: number of virtual CPUs
 
-    @raises errors.OpPrereqError: if number of VCPUs equals 0
+    @raise errors.OpPrereqError: if number of VCPUs equals 0
 
     """
     vcpus = self.config_parser.getint(constants.INISECT_BEP, "vcpus")
@@ -1452,7 +1452,7 @@ class OVFExporter(Converter):
     @rtype: int
     @return: amount of memory in MB
 
-    @raises errors.OpPrereqError: if amount of memory equals 0
+    @raise errors.OpPrereqError: if amount of memory equals 0
 
     """
     memory = self.config_parser.getint(constants.INISECT_BEP, "memory")
@@ -1503,7 +1503,7 @@ class OVFExporter(Converter):
     @rtype: list
     @return: list of dictionaries of network options
 
-    @raises errors.OpPrereqError: then network mode is not recognized
+    @raise errors.OpPrereqError: then network mode is not recognized
 
     """
     nics_count = self.config_parser.getint(constants.INISECT_INS, "nic_count")
@@ -1583,7 +1583,7 @@ class OVFExporter(Converter):
     try:
       utils.Makedirs(self.output_dir)
     except OSError, err:
-      raise errors.OpPrereqError("Failed to create directory %s:\n\t%s" %
+      raise errors.OpPrereqError("Failed to create directory %s: %s" %
                                  (self.output_dir, err))
 
     self.references_files = []
@@ -1611,13 +1611,13 @@ class OVFExporter(Converter):
     logging.warning("Calculating SHA1 checksums, this may take a while")
     sha1_sums = utils.FingerprintFiles(files_list)
     for file_path, value in sha1_sums.iteritems():
-      _, file_name = os.path.split(file_path)
-      lines.append("SHA1(%s)= %s\n" % (file_name, value))
-    data = "".join(lines)
+      file_name = os.path.basename(file_path)
+      lines.append("SHA1(%s)= %s" % (file_name, value))
+    data = "\n".join(lines)
     try:
       utils.WriteFile(path, data=data)
     except errors.ProgrammerError, err:
-      raise errors.OpPrereqError("Saving the manifest file failed:\n\t%s" % 
err)
+      raise errors.OpPrereqError("Saving the manifest file failed: %s" % err)
 
   @staticmethod
   def _PrepareTarFile(tar_path, files_list):
@@ -1674,7 +1674,7 @@ class OVFExporter(Converter):
       try:
         utils.Makedirs(self.packed_dir)
       except OSError, err:
-        raise errors.OpPrereqError("Failed to create directory %s:\n\t%s" %
+        raise errors.OpPrereqError("Failed to create directory %s: %s" %
                                    (self.packed_dir, err))
       self._PrepareTarFile(packed_path, files_list)
     logging.info("Creation of the OVF package was successfull")
-- 
1.7.3.1

Reply via email to