Exemplo n.º 1
0
    def _run_pre_backup(self):
        """
        Before performing the actual backup we need to make sure that
        there is enough space to store the backups. The backup size
        is the sum of the size of the databases and if it is an online
        backup, the size of the archived logs is also factored in.
        """
        backup_size_bytes = self.estimate_backup_size()
        log_size_bytes = self.estimate_log_size()
        total_backup_size_gb = utils.to_gb(backup_size_bytes + log_size_bytes)
        free_bytes = operating_system.get_bytes_free_on_fs(system.MOUNT_POINT)
        free_gb = utils.to_gb(free_bytes)

        if total_backup_size_gb > free_gb:
            raise exception.InsufficientSpaceForBackup % {
                'backup_size': total_backup_size_gb,
                'free': free_gb
            }
        self.run_backup()
Exemplo n.º 2
0
    def _run_pre_backup(self):
        """
        Before performing the actual backup we need to make sure that
        there is enough space to store the backups. The backup size
        is the sum of the size of the databases and if it is an online
        backup, the size of the archived logs is also factored in.
        """
        backup_size_bytes = self.estimate_backup_size()
        log_size_bytes = self.estimate_log_size()
        total_backup_size_gb = utils.to_gb(backup_size_bytes + log_size_bytes)
        free_bytes = operating_system.get_bytes_free_on_fs(system.MOUNT_POINT)
        free_gb = utils.to_gb(free_bytes)

        if total_backup_size_gb > free_gb:
            raise exception.InsufficientSpaceForBackup % {
                'backup_size': total_backup_size_gb,
                'free': free_gb
            }
        self.run_backup()
Exemplo n.º 3
0
def get_filesystem_volume_stats(fs_path):
    try:
        stats = os.statvfs(fs_path)
    except OSError:
        raise RuntimeError("Filesystem not found (%s)" % fs_path)

    total = stats.f_blocks * stats.f_bsize
    free = stats.f_bfree * stats.f_bsize
    # return the size in GB
    used_gb = utils.to_gb(total - free)
    total_gb = utils.to_gb(total)

    output = {
        'block_size': stats.f_bsize,
        'total_blocks': stats.f_blocks,
        'free_blocks': stats.f_bfree,
        'total': total_gb,
        'free': free,
        'used': used_gb
    }
    return output
Exemplo n.º 4
0
def get_filesystem_volume_stats(fs_path):
    try:
        stats = os.statvfs(fs_path)
    except OSError:
        LOG.exception(_("Error getting volume stats."))
        raise RuntimeError(_("Filesystem not found (%s)") % fs_path)

    total = stats.f_blocks * stats.f_bsize
    free = stats.f_bfree * stats.f_bsize
    # return the size in GB
    used_gb = utils.to_gb(total - free)
    total_gb = utils.to_gb(total)

    output = {
        'block_size': stats.f_bsize,
        'total_blocks': stats.f_blocks,
        'free_blocks': stats.f_bfree,
        'total': total_gb,
        'free': free,
        'used': used_gb
    }
    return output
Exemplo n.º 5
0
 def test_to_gb_zero(self):
     result = utils.to_gb(0)
     self.assertEqual(0.0, result)
Exemplo n.º 6
0
 def test_to_gb_small(self):
     result = utils.to_gb(2)
     self.assertEqual(0.01, result)
Exemplo n.º 7
0
 def test_to_gb(self):
     result = utils.to_gb(123456789)
     self.assertEqual(0.11, result)