Commits

Rodrigo Bistolfi committed a7d0bfb

Added logs to partitioning.py

Comments (0)

Files changed (1)

vinstall/backend/partitioning.py

 import parted
 import unittest, tempfile, os
 from vinstall.backend import media
+from vinstall.core import log
+
 
 __author__ = "Moises Henriquez"
 __email__ = "moc.liamg@xnl.e0m"[::-1]
 __date__ = "2012-06-05"
 
 
+LOG = log.get_logger(__name__)
+
+
 class DiskPartitioner(object):
     """ Class used to modify the partition table on the given disk
 
 
         """
         self.disk = disk
+        LOG.debug("Partitioning %s" % disk)
 
     def has_partition_table(self):
         """Find if there is a partition table. PTs start at position 0x1BE and
             f.seek(0x1BE)
             data = f.read(16)
             if data == "\x00" * 16:
+                LOG.debug("Disk has no partition table")
                 return False
             else:
+                LOG.debug("Disk has partition table")
                 return True
 
     def create_partition_table(self, table_type="msdos"):
         never been partitioned before.
 
         """
+        LOG.debug("Creating partition table in %s" % self.disk._device)
         self.disk._disk = parted.freshDisk(self.disk._device, "msdos")
         self.disk._disk.has_partition_table = True
 
         """ Delete all partitions from drive
 
         """
+        LOG.debug("Deleting all partitions")
         #self.disk._disk.deleteAllPartitions()
         self.disk._disk = parted.freshDisk(self.disk._device, "msdos")
         self.disk._disk.has_partition_table = True
                units = partition units (MB, GB, MiB, GiB), (defaults to MiB)
 
         """
+        LOG.debug("Adding partition of size %s%s" % (size, units))
         mypsize = parted.sizeToSectors(size, units, self.disk._device.sectorSize)
         # first partition starts at sector 1
         # find out where the free space is
                     start_marker = max(i.start, 2048)
                 else:
                     start_marker = i.start
+                LOG.debug("Start: %s" % start_marker)
                 break
         else:
             raise RuntimeError("There is no free space for partition")
     def write_changes(self):
         """Finalize changes to the disk.  This needs to be called
         after creating partitions or deleting partitions to make sure
-        the changes are actually written to the disk."""
+        the changes are actually written to the disk.
+        
+        """
+        LOG.debug("Commiting changes")
         self.disk._disk.commit()