예제 #1
0
 def _check_for_existing_snapshot(self):
     """Check if an existing snapshot is alive"""
     if not self.snapshot and self.logical_volume:
         snapshot_lv = '%s/%s' % (self.logical_volume.vg_name,
                                  self.snapshot_name or
                                  self.logical_volume.lv_name + '_snapshot')
         LOGGER.info("Checking for outstanding snapshot: %s", snapshot_lv)
         try:
             self.snapshot = LogicalVolume.find_one(snapshot_lv)
         except:
             LOGGER.info("No outstanding snapshot found.")
예제 #2
0
    def start(self):
        """Start and initialize the snapshot process"""
        logging.info("Finding volume for directory: %s",
                     self.target_directory)
        mountpoint = getmount(self.target_directory)
        LOGGER.info("Mount point for directory: %s", mountpoint)
        self.relpath = relpath(self.target_directory, mountpoint)
        LOGGER.info("Path relative to snapshot mountpoint: %s", self.relpath)
        self.logical_volume = LogicalVolume.find_mounted(mountpoint)
        if not self.logical_volume:
            raise LVMError("No logical volume found for mountpoint=%r target_path=%r" % (mountpoint, self.target_directory))
        LOGGER.info("%r is on logical volume %s/%s",
                        self.target_directory,
                        self.logical_volume.vg_name,
                        self.logical_volume.lv_name)

        self.run_callback('init')
        return self.create_snapshot()