[openstack-cinder/el6-grizzly] Implement get_volume_stats for GlusterFS driver
Eric Harney
eharney at fedoraproject.org
Mon Apr 8 20:37:35 UTC 2013
commit 64b09de18a2f42cc322fb011906eaabfad564fa4
Author: Eric Harney <eharney at redhat.com>
Date: Mon Apr 8 11:21:27 2013 -0400
Implement get_volume_stats for GlusterFS driver
adjust to support sqlalchemy-0.8.0
Updated patches from el6-grizzly-patches
...e-don-t-access-the-net-when-building-docs.patch | 8 +-
...ecated-assert_unicode-sqlalchemy-attribut.patch | 126 +++++++++++++++++
...ent-get_volume_stats-for-GlusterFS-driver.patch | 148 ++++++++++++++++++++
openstack-cinder.spec | 12 ++-
4 files changed, 288 insertions(+), 6 deletions(-)
---
diff --git a/0001-Ensure-we-don-t-access-the-net-when-building-docs.patch b/0001-Ensure-we-don-t-access-the-net-when-building-docs.patch
index 852bae3..d0aac9a 100644
--- a/0001-Ensure-we-don-t-access-the-net-when-building-docs.patch
+++ b/0001-Ensure-we-don-t-access-the-net-when-building-docs.patch
@@ -1,15 +1,15 @@
-From 632fb0194715d52f2b03c5b4b8697d4271bd81f7 Mon Sep 17 00:00:00 2001
+From dc92921a7fbecc609248a4e483ba44450a3821e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P at draigBrady.com>
Date: Fri, 21 Sep 2012 13:33:26 +0100
Subject: [PATCH] Ensure we don't access the net when building docs
(Note, this has not been sent upstream)
---
- doc/source/conf.py | 1 -
- 1 files changed, 0 insertions(+), 1 deletions(-)
+ doc/source/conf.py | 1 -
+ 1 file changed, 1 deletion(-)
diff --git a/doc/source/conf.py b/doc/source/conf.py
-index 7436039..9a5b826 100644
+index 40e564b..01bd3b4 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -29,7 +29,6 @@ sys.path.insert(0, os.path.abspath('./'))
diff --git a/0002-remove-deprecated-assert_unicode-sqlalchemy-attribut.patch b/0002-remove-deprecated-assert_unicode-sqlalchemy-attribut.patch
new file mode 100644
index 0000000..763d720
--- /dev/null
+++ b/0002-remove-deprecated-assert_unicode-sqlalchemy-attribut.patch
@@ -0,0 +1,126 @@
+From a7df1178d47dc126636d49b8ac13b4b229f58015 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?P=C3=A1draig=20Brady?= <pbrady at redhat.com>
+Date: Tue, 2 Apr 2013 14:44:51 +0100
+Subject: [PATCH] remove deprecated assert_unicode sqlalchemy attribute
+
+Removing this enables use with sqlalchemy 0.8.0
+The deprecation is described upstream at:
+http://docs.sqlalchemy.org/en/latest/changelog/changelog_08.html#change-ad44af79c886d1bb283042deb64f9cbe
+
+Change-Id: I305bfdbcd3c3669c41318ea34115624f729b3909
+---
+ cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py | 11 ++++-------
+ cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py | 11 -----------
+ 2 files changed, 4 insertions(+), 18 deletions(-)
+
+diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py b/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py
+index 9f5b643..fe911c0 100644
+--- a/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py
++++ b/cinder/db/sqlalchemy/migrate_repo/versions/002_quota_class.py
+@@ -37,14 +37,12 @@ def upgrade(migrate_engine):
+ Column('class_name',
+ String(length=255,
+ convert_unicode=True,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False),
+ index=True),
+ Column('resource',
+ String(length=255,
+ convert_unicode=True,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('hard_limit', Integer(), nullable=True),
+@@ -67,12 +65,12 @@ def upgrade(migrate_engine):
+ Column('id', Integer(), primary_key=True),
+ Column('project_id',
+ String(length=255, convert_unicode=True,
+- assert_unicode=None, unicode_error=None,
++ unicode_error=None,
+ _warn_on_bytestring=False),
+ index=True),
+ Column('resource',
+ String(length=255, convert_unicode=True,
+- assert_unicode=None, unicode_error=None,
++ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('in_use', Integer(), nullable=False),
+ Column('reserved', Integer(), nullable=False),
+@@ -97,7 +95,6 @@ def upgrade(migrate_engine):
+ Column('uuid',
+ String(length=36,
+ convert_unicode=True,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False),
+ nullable=False),
+@@ -107,12 +104,12 @@ def upgrade(migrate_engine):
+ nullable=False),
+ Column('project_id',
+ String(length=255, convert_unicode=True,
+- assert_unicode=None, unicode_error=None,
++ unicode_error=None,
+ _warn_on_bytestring=False),
+ index=True),
+ Column('resource',
+ String(length=255, convert_unicode=True,
+- assert_unicode=None, unicode_error=None,
++ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('delta', Integer(), nullable=False),
+ Column('expire', DateTime(timezone=False)),
+diff --git a/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py b/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
+index 4cc1689..5dfbed0 100644
+--- a/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
++++ b/cinder/db/sqlalchemy/migrate_repo/versions/008_add_backup.py
+@@ -37,49 +37,38 @@ def upgrade(migrate_engine):
+ Column('id', String(36), primary_key=True, nullable=False),
+ Column('volume_id', String(36), nullable=False),
+ Column('user_id', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('project_id', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('host', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('availability_zone', String(length=255,
+ convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('display_name', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('display_description', String(length=255,
+ convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('container', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('status', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('fail_reason', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('service_metadata', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('service', String(length=255, convert_unicode=False,
+- assert_unicode=None,
+ unicode_error=None,
+ _warn_on_bytestring=False)),
+ Column('size', Integer()),
diff --git a/0003-Implement-get_volume_stats-for-GlusterFS-driver.patch b/0003-Implement-get_volume_stats-for-GlusterFS-driver.patch
new file mode 100644
index 0000000..9fb5f69
--- /dev/null
+++ b/0003-Implement-get_volume_stats-for-GlusterFS-driver.patch
@@ -0,0 +1,148 @@
+From c4250743349f72f7fd860fec08684ac2981765d3 Mon Sep 17 00:00:00 2001
+From: Eric Harney <eharney at redhat.com>
+Date: Wed, 3 Apr 2013 14:39:38 -0400
+Subject: [PATCH] Implement get_volume_stats for GlusterFS driver
+
+Implement get_volume_stats(), so that the GlusterFS driver
+will work correctly with the scheduler.
+
+Fixes bug: 1164038
+
+Change-Id: Ib4db8bad897212227b39704e2e6cb5f07f2bb70e
+(cherry picked from commit d59094f316f0c41aaa7be63ee4e25e2dea4fa0a9)
+---
+ cinder/tests/test_glusterfs.py | 17 ++++++++--------
+ cinder/volume/drivers/glusterfs.py | 40 +++++++++++++++++++++++++++++++++++---
+ 2 files changed, 46 insertions(+), 11 deletions(-)
+
+diff --git a/cinder/tests/test_glusterfs.py b/cinder/tests/test_glusterfs.py
+index 4bf4040..4739caf 100644
+--- a/cinder/tests/test_glusterfs.py
++++ b/cinder/tests/test_glusterfs.py
+@@ -255,10 +255,11 @@ class GlusterFsDriverTestCase(test.TestCase):
+ mox = self._mox
+ drv = self._driver
+
++ df_total_size = 2620544
+ df_avail = 1490560
+ df_head = 'Filesystem 1K-blocks Used Available Use% Mounted on\n'
+- df_data = 'glusterfs-host:/export 2620544 996864 %d 41%% /mnt' % \
+- df_avail
++ df_data = 'glusterfs-host:/export %d 996864 %d 41%% /mnt' % \
++ (df_total_size, df_avail)
+ df_output = df_head + df_data
+
+ setattr(glusterfs.FLAGS, 'glusterfs_disk_util', 'df')
+@@ -274,7 +275,7 @@ class GlusterFsDriverTestCase(test.TestCase):
+
+ mox.ReplayAll()
+
+- self.assertEquals(df_avail,
++ self.assertEquals((df_avail, df_total_size),
+ drv._get_available_capacity(
+ self.TEST_EXPORT1))
+
+@@ -319,7 +320,7 @@ class GlusterFsDriverTestCase(test.TestCase):
+
+ mox.ReplayAll()
+
+- self.assertEquals(df_total_size - du_used,
++ self.assertEquals((df_total_size - du_used, df_total_size),
+ drv._get_available_capacity(
+ self.TEST_EXPORT1))
+
+@@ -450,9 +451,9 @@ class GlusterFsDriverTestCase(test.TestCase):
+
+ mox.StubOutWithMock(drv, '_get_available_capacity')
+ drv._get_available_capacity(self.TEST_EXPORT1).\
+- AndReturn(2 * self.ONE_GB_IN_BYTES)
++ AndReturn((2 * self.ONE_GB_IN_BYTES, 5 * self.ONE_GB_IN_BYTES))
+ drv._get_available_capacity(self.TEST_EXPORT2).\
+- AndReturn(3 * self.ONE_GB_IN_BYTES)
++ AndReturn((3 * self.ONE_GB_IN_BYTES, 10 * self.ONE_GB_IN_BYTES))
+
+ mox.ReplayAll()
+
+@@ -471,9 +472,9 @@ class GlusterFsDriverTestCase(test.TestCase):
+
+ mox.StubOutWithMock(drv, '_get_available_capacity')
+ drv._get_available_capacity(self.TEST_EXPORT1).\
+- AndReturn(0)
++ AndReturn((0, 5 * self.ONE_GB_IN_BYTES))
+ drv._get_available_capacity(self.TEST_EXPORT2).\
+- AndReturn(0)
++ AndReturn((0, 10 * self.ONE_GB_IN_BYTES))
+
+ mox.ReplayAll()
+
+diff --git a/cinder/volume/drivers/glusterfs.py b/cinder/volume/drivers/glusterfs.py
+index 6e127e1..5d1aced 100644
+--- a/cinder/volume/drivers/glusterfs.py
++++ b/cinder/volume/drivers/glusterfs.py
+@@ -200,7 +200,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
+ greatest_share = None
+
+ for glusterfs_share in self._mounted_shares:
+- capacity = self._get_available_capacity(glusterfs_share)
++ capacity = self._get_available_capacity(glusterfs_share)[0]
+ if capacity > greatest_size:
+ greatest_share = glusterfs_share
+ greatest_size = capacity
+@@ -229,17 +229,17 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
+
+ available = 0
+
++ size = int(out.split()[1])
+ if self.configuration.glusterfs_disk_util == 'df':
+ available = int(out.split()[3])
+ else:
+- size = int(out.split()[1])
+ out, _ = self._execute('du', '-sb', '--apparent-size',
+ '--exclude', '*snapshot*', mount_point,
+ run_as_root=True)
+ used = int(out.split()[0])
+ available = size - used
+
+- return available
++ return available, size
+
+ def _mount_glusterfs(self, glusterfs_share, mount_path, ensure=False):
+ """Mount GlusterFS share to mount path."""
+@@ -254,3 +254,37 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
+ LOG.warn(_("%s is already mounted"), glusterfs_share)
+ else:
+ raise
++
++ def get_volume_stats(self, refresh=False):
++ """Get volume stats.
++
++ If 'refresh' is True, update the stats first."""
++ if refresh or not self._stats:
++ self._update_volume_stats()
++
++ return self._stats
++
++ def _update_volume_stats(self):
++ """Retrieve stats info from volume group."""
++
++ data = {}
++ backend_name = self.configuration.safe_get('volume_backend_name')
++ data['volume_backend_name'] = backend_name or 'GlusterFS'
++ data['vendor_name'] = 'Open Source'
++ data['driver_version'] = '1.0'
++ data['storage_protocol'] = 'glusterfs'
++
++ self._ensure_shares_mounted()
++
++ global_capacity = 0
++ global_free = 0
++ for nfs_share in self._mounted_shares:
++ free, capacity = self._get_available_capacity(nfs_share)
++ global_capacity += capacity
++ global_free += free
++
++ data['total_capacity_gb'] = global_capacity / 1024.0 ** 3
++ data['free_capacity_gb'] = global_free / 1024.0 ** 3
++ data['reserved_percentage'] = 0
++ data['QoS_support'] = False
++ self._stats = data
diff --git a/openstack-cinder.spec b/openstack-cinder.spec
index 16b4773..fb64b05 100644
--- a/openstack-cinder.spec
+++ b/openstack-cinder.spec
@@ -2,7 +2,7 @@
Name: openstack-cinder
Version: 2013.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: OpenStack Volume service
Group: Applications/System
@@ -23,9 +23,11 @@ Source120: openstack-cinder-volume.upstart
Source20: cinder-sudoers
#
-# patches_base=grizzly-3
+# patches_base=2013.1
#
Patch0001: 0001-Ensure-we-don-t-access-the-net-when-building-docs.patch
+Patch0002: 0002-remove-deprecated-assert_unicode-sqlalchemy-attribut.patch
+Patch0003: 0003-Implement-get_volume_stats-for-GlusterFS-driver.patch
# This is EPEL specific and not upstream
Patch100: openstack-cinder-newdeps.patch
@@ -127,6 +129,8 @@ This package contains documentation files for cinder.
%setup -q -n cinder-%{version}
%patch0001 -p1
+%patch0002 -p1
+%patch0003 -p1
# Apply EPEL patch
%patch100 -p1
@@ -284,6 +288,10 @@ fi
%endif
%changelog
+* Mon Apr 08 2013 Eric Harney <eharney at redhat.com> - 2013.1-2
+- Backport fix for GlusterFS driver get_volume_stats
+- Adjust to support sqlalchemy-0.8.0
+
* Thu Apr 04 2013 Eric Harney <eharney at redhat.com> - 2013.1-1
- Update to Grizzly final release
More information about the scm-commits
mailing list