Created
January 16, 2014 22:48
-
-
Save j-griffith/8465017 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@precise64 /opt/stack/cinder/cinder/volume/drivers $ git diff | |
diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py | |
index 0037632..645698d 100644 | |
--- a/cinder/brick/local_dev/lvm.py | |
+++ b/cinder/brick/local_dev/lvm.py | |
@@ -626,3 +626,22 @@ class LVM(executor.Executor): | |
LOG.error(_('StdOut :%s') % err.stdout) | |
LOG.error(_('StdErr :%s') % err.stderr) | |
raise | |
+ | |
+ def vg_mirror_free_space(self, mirror_count): | |
+ free_capacity = 0.0 | |
+ while True: | |
+ disks = sorted([a for a in self.pv_list if a > 0.0], reverse=True) | |
+ if len(disks) <= mirror_count: | |
+ break | |
+ # consume the smallest disk | |
+ disk = disks[-1] | |
+ disks = disks[:-1] | |
+ # match extents for each mirror on the largest disks | |
+ for index in range(self.configuration.lvm_mirrors): | |
+ disks[index] -= disk | |
+ free_capacity += disk | |
+ return free_capacity | |
+ | |
+ def vg_mirror_size(self, mirror_count): | |
+ return (float(self.vg_free_space.replace(',', '.')) / | |
+ (mirror_count + 1)) | |
diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py | |
index 7c4ac31..285fd92 100644 | |
--- a/cinder/volume/drivers/lvm.py | |
+++ b/cinder/volume/drivers/lvm.py | |
@@ -371,11 +371,16 @@ class LVMVolumeDriver(driver.VolumeDriver): | |
data["driver_version"] = self.VERSION | |
data["storage_protocol"] = self.protocol | |
- data['total_capacity_gb'] = float(self.vg.vg_size) | |
- data['free_capacity_gb'] = float(self.vg.vg_free_space) | |
- if self.configuration.lvm_type == 'thin': | |
+ if self.configuration.mirror_count > 0: | |
+ data['total_capacity_gb'] = float(self.vg.vg_mirror_size) | |
+ data['free_capacity_gb'] = float(self.vg.vg_mirror_free_space) | |
+ elif self.configuration.lvm_type == 'thin': | |
data['total_capacity_gb'] = float(self.vg.vg_thin_pool_size) | |
data['free_capacity_gb'] = float(self.vg.vg_thin_pool_free_space) | |
+ else: | |
+ data['total_capacity_gb'] = float(self.vg.vg_size) | |
+ data['free_capacity_gb'] = float(self.vg.vg_free_space) | |
+ | |
data['reserved_percentage'] = self.configuration.reserved_percentage | |
data['QoS_support'] = False | |
data['location_info'] =\ | |
vagrant@precise64 /opt/stack/cinder/cinder/volume/drivers $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment