Aravinda VK has uploaded a new change for review.
Change subject: gluster: [WIP]Get size information of gluster volume ......................................................................
gluster: [WIP]Get size information of gluster volume
Change-Id: I358d4f3bf793ecc1a01e0592d68919d1405f6e19 Signed-off-by: Aravinda VK avishwan@redhat.com --- M client/vdsClientGluster.py M vdsm.spec.in M vdsm/gluster/Makefile.am M vdsm/gluster/__init__.py M vdsm/gluster/api.py A vdsm/gluster/gfapi.py 6 files changed, 100 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/17822/1
diff --git a/client/vdsClientGluster.py b/client/vdsClientGluster.py index 90af83e..644bfe3 100644 --- a/client/vdsClientGluster.py +++ b/client/vdsClientGluster.py @@ -424,6 +424,17 @@ pp.pprint(status) return status['status']['code'], status['status']['message']
+ def do_glusterVolumeSize(self, args): + params = self._eqSplit(args) + try: + volumeName = params.get('volumeName', '') + except: + raise ValueError + + status = self.s.glusterVolumeSize(volumeName) + pp.pprint(status) + return status['status']['code'], status['status']['message'] +
def getGlusterCmdDict(serv): return \ @@ -705,4 +716,9 @@ 'not set' '(swift, glusterd, smb, memcached)' )), + 'glusterVolumeSize': ( + serv.do_glusterVolumeSize, + ('volumeName=<volume name>', + 'Returns total, available and used space status of gluster volume' + )), } diff --git a/vdsm.spec.in b/vdsm.spec.in index 21b3565..e49e102 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -1271,6 +1271,7 @@ %doc COPYING %{_datadir}/%{vdsm_name}/gluster/api.py* %{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json +%{_datadir}/%{vdsm_name}/gluster/gfapi.py* %{_datadir}/%{vdsm_name}/gluster/hooks.py* %{_datadir}/%{vdsm_name}/gluster/services.py* %endif diff --git a/vdsm/gluster/Makefile.am b/vdsm/gluster/Makefile.am index dd5434d..9c2989f 100644 --- a/vdsm/gluster/Makefile.am +++ b/vdsm/gluster/Makefile.am @@ -26,6 +26,7 @@ api.py \ cli.py \ exception.py \ + gfapi.py \ hooks.py \ hostname.py \ services.py \ diff --git a/vdsm/gluster/__init__.py b/vdsm/gluster/__init__.py index bec70ea..e5a2fd6 100644 --- a/vdsm/gluster/__init__.py +++ b/vdsm/gluster/__init__.py @@ -22,7 +22,7 @@ import tempfile from functools import wraps
-MODULE_LIST = ('cli', 'hooks', 'services') +MODULE_LIST = ('cli', 'hooks', 'services', 'gfapi')
def makePublic(func): diff --git a/vdsm/gluster/api.py b/vdsm/gluster/api.py index 4bd8308..89546c1 100644 --- a/vdsm/gluster/api.py +++ b/vdsm/gluster/api.py @@ -287,6 +287,22 @@ status = self.svdsmProxy.glusterServicesGet(serviceNames) return {'services': status}
+ @exportAsVerb + def volumeSize(self, volumeName, options=None): + data = self.svdsmProxy.glusterVolumeStatvfs(volumeName) + # f_blocks = Total number of blocks + # f_bfree = Total number of blocks free + # f_bavail = Total number of blocks available for non root user + # total blocks available = f_blocks - (f_bfree - f_bavail) + total_blocks_available = data['f_blocks'] - \ + (data['f_bfree'] - data['f_bavail']) + return { + 'total': total_blocks_available * data.f_bsize / 1024, + 'free': data['f_bavail'] * data['f_bsize'] / 1024, + 'used': (total_blocks_available - data['f_bavail']) * \ + data['f_bsize'] / 1024 + } +
def getGlusterMethods(gluster): l = [] diff --git a/vdsm/gluster/gfapi.py b/vdsm/gluster/gfapi.py new file mode 100644 index 0000000..abfdabd --- /dev/null +++ b/vdsm/gluster/gfapi.py @@ -0,0 +1,65 @@ +# +# Copyright 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# +from ctypes import * + +# import exception as ge +from . import makePublic + +GLUSTER_VOL_PROTOCAL='tcp' +GLUSTER_VOL_HOST='localhost' +GLUSTER_VOL_PORT=24007 + +class Stat (Structure): + _fields_ = [ + ('f_bsize', c_ulong), + ('f_frsize', c_ulong), + ('f_blocks', c_ulong), + ('f_bfree', c_ulong), + ('f_bavail', c_ulong), + ('f_files', c_ulong), + ('f_ffree', c_ulong), + ('f_favail', c_ulong), + ('f_fsid', c_ulong), + ('f_flag', c_ulong), + ('f_namemax', c_ulong), + ('__f_spare', c_int * 6), + ] + + +api = CDLL("libgfapi.so",RTLD_GLOBAL) +api.glfs_statvfs.restype = c_int +api.glfs_statvfs.argtypes = [c_void_p, c_char_p, POINTER(Stat)] + +@makePublic +def volumeStatvfs(volumeId): + path = "/" + fs = api.glfs_new(volumeId) + api.glfs_set_volfile_server(fs, + GLUSTER_VOL_PROTOCAL, + GLUSTER_VOL_HOST, + GLUSTER_VOL_PORT) + api.glfs_init(fs) + + x = Stat() + rc = api.glfs_statvfs(fs, path, byref(x)) + statvfsData = {} + for k in x._fields_: + statvfsData[k[0]] = getattr(x, k[0]) + return statvfsData
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: [WIP]Get size information of gluster volume ......................................................................
Patch Set 1: Code-Review-1 Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3815/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3732/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2924/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 2: Code-Review-1
Build Unstable
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3856/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3773/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2967/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 3: Code-Review-1
Build Unstable
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3858/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3775/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2969/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 4: Code-Review-1
Build Unstable
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4048/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3153/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3969/ : UNSTABLE
Bala.FA has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 4: Code-Review-1
(8 comments)
.................................................... File client/vdsClientGluster.py Line 426: Line 427: def do_glusterVolumeSize(self, args): Line 428: params = self._eqSplit(args) Line 429: try: Line 430: volumeName = params.get('volumeName', '') This code doesn't throw any exception Line 431: except: Line 432: raise ValueError Line 433: Line 434: status = self.s.glusterVolumeSize(volumeName)
Line 428: params = self._eqSplit(args) Line 429: try: Line 430: volumeName = params.get('volumeName', '') Line 431: except: Line 432: raise ValueError Don't treat anything as ValueError Line 433: Line 434: status = self.s.glusterVolumeSize(volumeName) Line 435: pp.pprint(status) Line 436: return status['status']['code'], status['status']['message']
Line 718: )), Line 719: 'glusterVolumeSize': ( Line 720: serv.do_glusterVolumeSize, Line 721: ('volumeName=<volume name>', Line 722: 'Returns total, available and used ' you could say 'Returns total, free and used space of gluster volume' Line 723: 'space status of gluster volume' Line 724: )),
Line 719: 'glusterVolumeSize': ( Line 720: serv.do_glusterVolumeSize, Line 721: ('volumeName=<volume name>', Line 722: 'Returns total, available and used ' Line 723: 'space status of gluster volume' Do we need to specify the unit of 'space'? Line 724: )),
.................................................... File vdsm/gluster/api.py Line 287: status = self.svdsmProxy.glusterServicesGet(serviceNames) Line 288: return {'services': status} Line 289: Line 290: @exportAsVerb Line 291: def volumeSize(self, volumeName, options=None): May be volumeSizeGet()? Line 292: """ Line 293: f_blocks = Total number of blocks Line 294: f_bfree = Total number of blocks free Line 295: f_bavail = Total number of blocks available for non root user
Line 301: return { Line 302: 'total': total_blocks_available * data.f_bsize / 1024, Line 303: 'free': data['f_bavail'] * data['f_bsize'] / 1024, Line 304: 'used': (total_blocks_available - data['f_bavail']) * \ Line 305: data['f_bsize'] / 1024 What is the unit of these size? Line 306: } Line 307: Line 308: Line 309: def getGlusterMethods(gluster):
.................................................... File vdsm/gluster/gfapi.py Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: Line 33: class Stat (Structure): can we use os.statvfs_result class or somethng similar? Line 34: _fields_ = [ Line 35: ('f_bsize', c_ulong), Line 36: ('f_frsize', c_ulong), Line 37: ('f_blocks', c_ulong),
Line 52: @makePublic Line 53: def volumeStatvfs(volumeId): Line 54: api.glfs_statvfs.restype = c_int Line 55: api.glfs_statvfs.argtypes = [c_void_p, c_char_p, POINTER(Stat)] Line 56: fs = api.glfs_new(volumeId) libgfapi usage can be extended beyond management to Gluster Storage Domain. Lets add Deepak here. Line 57: api.glfs_set_volfile_server(fs, Line 58: GLUSTER_VOL_PROTOCAL, Line 59: GLUSTER_VOL_HOST, Line 60: GLUSTER_VOL_PORT)
Aravinda VK has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 4:
(8 comments)
.................................................... File client/vdsClientGluster.py Line 426: Line 427: def do_glusterVolumeSize(self, args): Line 428: params = self._eqSplit(args) Line 429: try: Line 430: volumeName = params.get('volumeName', '') Done Line 431: except: Line 432: raise ValueError Line 433: Line 434: status = self.s.glusterVolumeSize(volumeName)
Line 428: params = self._eqSplit(args) Line 429: try: Line 430: volumeName = params.get('volumeName', '') Line 431: except: Line 432: raise ValueError Done Line 433: Line 434: status = self.s.glusterVolumeSize(volumeName) Line 435: pp.pprint(status) Line 436: return status['status']['code'], status['status']['message']
Line 718: )), Line 719: 'glusterVolumeSize': ( Line 720: serv.do_glusterVolumeSize, Line 721: ('volumeName=<volume name>', Line 722: 'Returns total, available and used ' Done Line 723: 'space status of gluster volume' Line 724: )),
Line 719: 'glusterVolumeSize': ( Line 720: serv.do_glusterVolumeSize, Line 721: ('volumeName=<volume name>', Line 722: 'Returns total, available and used ' Line 723: 'space status of gluster volume' Done Line 724: )),
.................................................... File vdsm/gluster/api.py Line 287: status = self.svdsmProxy.glusterServicesGet(serviceNames) Line 288: return {'services': status} Line 289: Line 290: @exportAsVerb Line 291: def volumeSize(self, volumeName, options=None): Since we don't have Set, do we need to change to Get? Line 292: """ Line 293: f_blocks = Total number of blocks Line 294: f_bfree = Total number of blocks free Line 295: f_bavail = Total number of blocks available for non root user
Line 301: return { Line 302: 'total': total_blocks_available * data.f_bsize / 1024, Line 303: 'free': data['f_bavail'] * data['f_bsize'] / 1024, Line 304: 'used': (total_blocks_available - data['f_bavail']) * \ Line 305: data['f_bsize'] / 1024 bytes. Line 306: } Line 307: Line 308: Line 309: def getGlusterMethods(gluster):
.................................................... File vdsm/gluster/gfapi.py Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: Line 33: class Stat (Structure): Here Stat is derived class of Structure which should be same as C structure which libgfapi uses.
We can plan to use the os.statvfs_result format while returning statvfsData from the function volumeStatvfs Line 34: _fields_ = [ Line 35: ('f_bsize', c_ulong), Line 36: ('f_frsize', c_ulong), Line 37: ('f_blocks', c_ulong),
Line 52: @makePublic Line 53: def volumeStatvfs(volumeId): Line 54: api.glfs_statvfs.restype = c_int Line 55: api.glfs_statvfs.argtypes = [c_void_p, c_char_p, POINTER(Stat)] Line 56: fs = api.glfs_new(volumeId) Done Line 57: api.glfs_set_volfile_server(fs, Line 58: GLUSTER_VOL_PROTOCAL, Line 59: GLUSTER_VOL_HOST, Line 60: GLUSTER_VOL_PORT)
Bala.FA has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 4:
(2 comments)
.................................................... File vdsm/gluster/api.py Line 287: status = self.svdsmProxy.glusterServicesGet(serviceNames) Line 288: return {'services': status} Line 289: Line 290: @exportAsVerb Line 291: def volumeSize(self, volumeName, options=None): name 'volumeSize' looks like a noun than verb. You could make it as verb. May be volumeSizeInfoGet() or something like that Line 292: """ Line 293: f_blocks = Total number of blocks Line 294: f_bfree = Total number of blocks free Line 295: f_bavail = Total number of blocks available for non root user
.................................................... File vdsm/gluster/gfapi.py Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: Line 33: class Stat (Structure): I believe statvfs() of libgfapi should be compatible with posix statvfs(). Line 34: _fields_ = [ Line 35: ('f_bsize', c_ulong), Line 36: ('f_frsize', c_ulong), Line 37: ('f_blocks', c_ulong),
Aravinda VK has posted comments on this change.
Change subject: [WIP]gluster: Get size information of a gluster volume ......................................................................
Patch Set 4:
(2 comments)
.................................................... File vdsm/gluster/api.py Line 287: status = self.svdsmProxy.glusterServicesGet(serviceNames) Line 288: return {'services': status} Line 289: Line 290: @exportAsVerb Line 291: def volumeSize(self, volumeName, options=None): Done Line 292: """ Line 293: f_blocks = Total number of blocks Line 294: f_bfree = Total number of blocks free Line 295: f_bavail = Total number of blocks available for non root user
.................................................... File vdsm/gluster/gfapi.py Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: Line 33: class Stat (Structure): Yes. It is compatible. But here we need to pass information about C datatype which maps to a field in Python Structure. I am not sure how we can use os.statvfs_result with ctypes. Will check. Line 34: _fields_ = [ Line 35: ('f_bsize', c_ulong), Line 36: ('f_frsize', c_ulong), Line 37: ('f_blocks', c_ulong),
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4094/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3199/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4015/ : SUCCESS
Deepak C Shetty has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5: Code-Review-1
(9 comments)
.................................................... File client/vdsClientGluster.py Line 715: 'Returns status of all gluster services if serviceName is ' Line 716: 'not set' Line 717: '(swift, glusterd, smb, memcached)' Line 718: )), Line 719: 'glusterVolumeSizeInfoGet': ( SInce this ends up doing glfs_statvfs.. why do we name it as volumeinfoget ? Why not glusterVolumeStatsGet ? volumeinfoget is confusing as one things it is doing `gluster volume info` Line 720: serv.do_glusterVolumeSizeInfoGet, Line 721: ('volumeName=<volume name> [humanReadable=<yes|no>]', Line 722: 'Returns total, free and used space(bytes) of gluster volume' Line 723: )),
Line 719: 'glusterVolumeSizeInfoGet': ( Line 720: serv.do_glusterVolumeSizeInfoGet, Line 721: ('volumeName=<volume name> [humanReadable=<yes|no>]', Line 722: 'Returns total, free and used space(bytes) of gluster volume' Line 723: )), How abt adding addnl parameter for volFileServer. Without that you are always going to assume glusterd /server is running on local machine. In VDSM and in general mgmt. usecase.. the hyp host may or maynot be the same as gluster host.. so volFileServer should help provide the capability to query remote gluster host from hyp host when both are not co-located
.................................................... File vdsm.spec.in Line 1271: %dir %{_datadir}/%{vdsm_name}/gluster Line 1272: %doc COPYING Line 1273: %{_datadir}/%{vdsm_name}/gluster/api.py* Line 1274: %{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json Line 1275: %{_datadir}/%{vdsm_name}/gluster/gfapi.py* IIUC this provides the pythin binding for libgfapi. This should ideally be part of glusterfs-api RPM package and when -api gets installed.. the python binding should go to the /usr/lib64/python-x.x/site-packages/... dir such that it can be used not just by vdsm-gluster but even in vdsm in general or any appln on the host, agree ?
By doing this, u r limiting the usage of gfapi.py to vdsm-gluster only. Is that the plan ?
Having said that I see that gfapi.py only has support for statvfs.. what abt other gfapi methods ? Is there a plan to make gfapi.py provide full support for all libgfapi methods ? Line 1276: %{_datadir}/%{vdsm_name}/gluster/hooks.py* Line 1277: %{_datadir}/%{vdsm_name}/gluster/services.py* Line 1278: %endif Line 1279:
.................................................... File vdsm/gluster/api.py Line 289: return {'services': status} Line 290: Line 291: @exportAsVerb Line 292: def volumeSizeInfoGet(self, volumeName, human_readable=False, Line 293: options=None): Similar point.. why name it as sizeinfo why not volumeStatsInfoGet .. so that caller know he/she is asking for volume Stats. Also add volFileServer for ability to query a remote gluster host Line 294: """ Line 295: f_blocks = Total number of blocks Line 296: f_bfree = Total number of blocks free Line 297: f_bavail = Total number of blocks available for non root user
Line 293: options=None): Line 294: """ Line 295: f_blocks = Total number of blocks Line 296: f_bfree = Total number of blocks free Line 297: f_bavail = Total number of blocks available for non root user What is the significance of non root user here ? Can you put better comment.. Does that mean for root use this field will be intepreted diferently, if yes how ? Line 298: total blocks available = f_blocks - (f_bfree - f_bavail) Line 299: Line 300: @returns { Line 301: 'total': TOTALBYTES,
Line 312: total = formatVolumeSizeHumanReadable(total) Line 313: free = formatVolumeSizeHumanReadable(free) Line 314: used = formatVolumeSizeHumanReadable(used) Line 315: Line 316: return {'total': str(total), 'free': str(free), 'used': str(used)} Per @returns i thot you are returning number, here its string... pls indicate in @return that is a str. Line 317: Line 318: Line 319: def getGlusterMethods(gluster): Line 320: l = []
.................................................... File vdsm/gluster/gfapi.py Line 24: import exception as ge Line 25: from . import makePublic Line 26: Line 27: Line 28: GLUSTER_VOL_PROTOCAL = 'tcp' s/PROTOCAL/PROTOCOL What abt rdma and unix protocol ? If we don't support them, and volume was created with rdma transport type.. we should return appr. error somewhere from this .py ? Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: _api = None
Line 25: from . import makePublic Line 26: Line 27: Line 28: GLUSTER_VOL_PROTOCAL = 'tcp' Line 29: GLUSTER_VOL_HOST = 'localhost' This is a wrong assumption. This only works for the case where the vdsm-gluster is on the same host as the gluster peer. As mentioned prev. its possible that in VDSM case gluster peer is a diff host than hyp. host. Always aim for remote host usecase to be safer from mgmt. usecase perspective. Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: _api = None Line 33:
Line 61: return Line 62: Line 63: Line 64: def _volumeMount(volumeId): Line 65: fs = _api.glfs_new(volumeId) IIUC from the gfapi.py perspective, we are passing volumeName, so why confuse by putting the param as volumeID ? Even in glfs.h i see glfs_new taking arg as volumeName. Line 66: _api.glfs_set_volfile_server(fs, Line 67: GLUSTER_VOL_PROTOCAL, Line 68: GLUSTER_VOL_HOST, Line 69: GLUSTER_VOL_PORT)
Deepak C Shetty has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5:
A general Q: IF gfapi.py is used only to query the statvfs info... the same could be done by temp. mounting the volume, df -h, parsing it and return the total, free and used bytes, then unmounting the volume on the host. Are there plans to extend gfapi.py beyond supporting just 1 api ? In other words, is it worth to add so much stuff just to get volumeStats only ?
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5:
(9 comments)
To refresh Volume Size info in ovirt engine UI, engine may query VDSM verb number of times. Mounting GlusterFS volumes every time may be overhead when compared to libgfapi usage.
.................................................... File client/vdsClientGluster.py Line 715: 'Returns status of all gluster services if serviceName is ' Line 716: 'not set' Line 717: '(swift, glusterd, smb, memcached)' Line 718: )), Line 719: 'glusterVolumeSizeInfoGet': ( Done Line 720: serv.do_glusterVolumeSizeInfoGet, Line 721: ('volumeName=<volume name> [humanReadable=<yes|no>]', Line 722: 'Returns total, free and used space(bytes) of gluster volume' Line 723: )),
Line 719: 'glusterVolumeSizeInfoGet': ( Line 720: serv.do_glusterVolumeSizeInfoGet, Line 721: ('volumeName=<volume name> [humanReadable=<yes|no>]', Line 722: 'Returns total, free and used space(bytes) of gluster volume' Line 723: )), Done
.................................................... File vdsm.spec.in Line 1271: %dir %{_datadir}/%{vdsm_name}/gluster Line 1272: %doc COPYING Line 1273: %{_datadir}/%{vdsm_name}/gluster/api.py* Line 1274: %{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json Line 1275: %{_datadir}/%{vdsm_name}/gluster/gfapi.py* Full support for libgfapi is not planned from our team as of now. Current plan is to show volume stats in ovirt engine UI. Line 1276: %{_datadir}/%{vdsm_name}/gluster/hooks.py* Line 1277: %{_datadir}/%{vdsm_name}/gluster/services.py* Line 1278: %endif Line 1279:
.................................................... File vdsm/gluster/api.py Line 289: return {'services': status} Line 290: Line 291: @exportAsVerb Line 292: def volumeSizeInfoGet(self, volumeName, human_readable=False, Line 293: options=None): Done Line 294: """ Line 295: f_blocks = Total number of blocks Line 296: f_bfree = Total number of blocks free Line 297: f_bavail = Total number of blocks available for non root user
Line 293: options=None): Line 294: """ Line 295: f_blocks = Total number of blocks Line 296: f_bfree = Total number of blocks free Line 297: f_bavail = Total number of blocks available for non root user As per http://docs.python.org/2/library/statvfs.html
Will update the comment with more description. Line 298: total blocks available = f_blocks - (f_bfree - f_bavail) Line 299: Line 300: @returns { Line 301: 'total': TOTALBYTES,
Line 312: total = formatVolumeSizeHumanReadable(total) Line 313: free = formatVolumeSizeHumanReadable(free) Line 314: used = formatVolumeSizeHumanReadable(used) Line 315: Line 316: return {'total': str(total), 'free': str(free), 'used': str(used)} Will update the @return Line 317: Line 318: Line 319: def getGlusterMethods(gluster): Line 320: l = []
.................................................... File vdsm/gluster/gfapi.py Line 24: import exception as ge Line 25: from . import makePublic Line 26: Line 27: Line 28: GLUSTER_VOL_PROTOCAL = 'tcp' Done Line 29: GLUSTER_VOL_HOST = 'localhost' Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: _api = None
Line 25: from . import makePublic Line 26: Line 27: Line 28: GLUSTER_VOL_PROTOCAL = 'tcp' Line 29: GLUSTER_VOL_HOST = 'localhost' I will add protocal and host as optional parameter to vdsm verb. Line 30: GLUSTER_VOL_PORT = 24007 Line 31: GLUSTER_VOL_PATH = "/" Line 32: _api = None Line 33:
Line 61: return Line 62: Line 63: Line 64: def _volumeMount(volumeId): Line 65: fs = _api.glfs_new(volumeId) Done Line 66: _api.glfs_set_volfile_server(fs, Line 67: GLUSTER_VOL_PROTOCAL, Line 68: GLUSTER_VOL_HOST, Line 69: GLUSTER_VOL_PORT)
Deepak C Shetty has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5:
(1 comment)
Another option could be do a readonly mount in a hidden dir and do 'df -h' whenever u need the latest stats. thats possible too... I know its not perfect tho!
.................................................... File vdsm.spec.in Line 1271: %dir %{_datadir}/%{vdsm_name}/gluster Line 1272: %doc COPYING Line 1273: %{_datadir}/%{vdsm_name}/gluster/api.py* Line 1274: %{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json Line 1275: %{_datadir}/%{vdsm_name}/gluster/gfapi.py* I will suggest then not to use the name as gfapi.py, since thats misleading and wrong. Maybe say statvfs.py or have gluster/gfapi/stavfs.py .. that looks more logical considering that u don't plan to support everything via gfapi.
Any reason why u r putting this in vdsm-gluster pkg and not in -api pkg ? Since gfapi.py needs libgfapi.so.XX it should be part of -api pkg, in which case, the vdsm pkg itself can make use of it in future as needed. Line 1276: %{_datadir}/%{vdsm_name}/gluster/hooks.py* Line 1277: %{_datadir}/%{vdsm_name}/gluster/services.py* Line 1278: %endif Line 1279:
Bala.FA has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 5:
(2 comments)
Mounting a volume locally would be a pain to maintain ie
1. when mount happens? 2. when umount happens? 3. What if there is a stale mount? 4. What if the volume is been deleted?
.................................................... File client/vdsClientGluster.py Line 715: 'Returns status of all gluster services if serviceName is ' Line 716: 'not set' Line 717: '(swift, glusterd, smb, memcached)' Line 718: )), Line 719: 'glusterVolumeSizeInfoGet': ( I feel glusterVolumeStatsGet name is similar to glusterVolumeStatus. Stats and Status are quite similar. I would prefer different name Line 720: serv.do_glusterVolumeSizeInfoGet, Line 721: ('volumeName=<volume name> [humanReadable=<yes|no>]', Line 722: 'Returns total, free and used space(bytes) of gluster volume' Line 723: )),
.................................................... File vdsm.spec.in Line 1271: %dir %{_datadir}/%{vdsm_name}/gluster Line 1272: %doc COPYING Line 1273: %{_datadir}/%{vdsm_name}/gluster/api.py* Line 1274: %{_datadir}/%{vdsm_name}/gluster/vdsmapi-gluster-schema.json Line 1275: %{_datadir}/%{vdsm_name}/gluster/gfapi.py* +1
BTW what is the plan of using gfapi in storage domain? Does python bindings go into glusterfs-api package? Line 1276: %{_datadir}/%{vdsm_name}/gluster/hooks.py* Line 1277: %{_datadir}/%{vdsm_name}/gluster/services.py* Line 1278: %endif Line 1279:
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 6: Verified+1
Falling back to mounting glusterfs volume using mount command instead of libgfapi.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 6: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4797/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4873/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3988/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_install_rpm_sanity_gerrit/147/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 6:
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4799/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4875/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3990/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_install_rpm_sanity_gerrit/148/ : FAILURE
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7: Verified+1
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4931/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4045/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4855/ : SUCCESS
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7:
I didn't succeed with the libgfapi approach to get statvfs information of glusterfs volume. Falling back to `mount -t glusterfs` method to get statvfs info of glusterfs volume.
Saggi Mizrahi has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7:
(1 comment)
.................................................... File client/vdsClientGluster.py Line 444: def do_glusterVolumeStatsInfoGet(self, args): Line 445: params = self._eqSplit(args) Line 446: volumeName = params.get('volumeName', '') Line 447: if not volumeName: Line 448: raise ValueError Please raise a ValueError instance with some context perhaps though I see you don't do that all over so you guys might just like it this way. Line 449: Line 450: status = self.s.glusterVolumeStatsInfoGet(volumeName) Line 451: pp.pprint(status) Line 452: return status['status']['code'], status['status']['message']
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7: -Verified
(1 comment)
.................................................... File client/vdsClientGluster.py Line 444: def do_glusterVolumeStatsInfoGet(self, args): Line 445: params = self._eqSplit(args) Line 446: volumeName = params.get('volumeName', '') Line 447: if not volumeName: Line 448: raise ValueError Done Line 449: Line 450: status = self.s.glusterVolumeStatsInfoGet(volumeName) Line 451: pp.pprint(status) Line 452: return status['status']['code'], status['status']['message']
Saggi Mizrahi has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 7:
One of SaggiMizrahi's automated scripts discovered this patch might require his approval. Please wait until he had time to check it out.
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 8: Verified+1
Updated schema and updated client/vdsClientGluster.py as per Saggi's comment.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 8:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6564/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5671/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6477/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/206/ : SUCCESS
Timothy Asir has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 8:
(2 comments)
.................................................... File client/vdsClientGluster.py Line 457: params = self._eqSplit(args) Line 458: volumeName = params.get('volumeName', '') Line 459: if not volumeName: Line 460: raise ValueError('volumeName is required parameter') Line 461: This check is not required! Line 462: status = self.s.glusterVolumeStatsInfoGet(volumeName) Line 463: pp.pprint(status) Line 464: return status['status']['code'], status['status']['message'] Line 465:
.................................................... File vdsm/gluster/statvfs.py Line 43: log.debug("Mount point for volume %s: %s" % (volumeName, mountPoint)) Line 44: fs = "%s:/%s" % (volumeServer, volumeName) Line 45: glusterfsMount = storage.mount.Mount(fs, mountPoint) Line 46: try: Line 47: glusterfsMount.mount(vfstype="glusterfs") There will be some potential security risk when we mount the volume in /tmp. Please check it out and try to mount the volume in read only mode under privilaged user (path). Line 48: except storage.mount.MountError: Line 49: removeMountPoint(mountPoint) Line 50: raise ge.GlusterVolumeStatsInfoGetFailedException(vol=volumeName) Line 51:
Timothy Asir has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 8:
(1 comment)
.................................................... File client/vdsClientGluster.py Line 457: params = self._eqSplit(args) Line 458: volumeName = params.get('volumeName', '') Line 459: if not volumeName: Line 460: raise ValueError('volumeName is required parameter') Line 461: vdsmcli also treated as a functional testing tool. We need to test the state (of glusterVolumeStatsInfoGet) when engine calls this funciton without volumeName. So, this volumeName null check should be there inside the glusterVolumeStatsInfoGet function. Line 462: status = self.s.glusterVolumeStatsInfoGet(volumeName) Line 463: pp.pprint(status) Line 464: return status['status']['code'], status['status']['message'] Line 465:
Bala.FA has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 8: Code-Review-1
As per Tim's comment
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 9:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6702/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6615/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5809/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/241/ : SUCCESS
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 11: Verified+1
Bala, Tim,
1. Removed validation in vdsClient as suggested.
2. Modified mount option as read only.
3. Added additional exception which will be raised when volume is down
Timothy Asir has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 11: Code-Review+1
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 12: Verified+1
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 12:
No changes after Patchset 11, dependent patch got updated.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 12: Verified-1
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5938/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/269/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6831/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6726/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 12: -Verified
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5960/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/276/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6748/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6854/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 13:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5964/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/278/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6752/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6858/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 14:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/5976/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_master_install_rpm_sanity_gerrit/282/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/6764/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/6870/ : SUCCESS
Aravinda VK has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 14: Verified+1
Darshan N has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 14: Code-Review+1
Bala.FA has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 14: Code-Review-1
Please use below code. This code uses libgfapi and working fine. I tested through vdsClient->vdsm->supervdsm->glfspy.so. Only thing is that glfspy_statvfs return value needs to be changed according to statvfs structure.
#include <Python.h>
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <time.h> #include <sys/types.h> #include <sys/statvfs.h>
#include "api/glfs.h" #include "api/glfs-handles.h"
#define USAGE_ERROR -1 #define GLFS_NEW_FAILURE -2 #define GLFS_INIT_FAILURE -3 #define GLFS_STATVFS_FAILURE -4 #define GLFS_FINI_FAILURE -5 #define DEFAULT_TRANSPORT "tcp" #define DEFAULT_SERVER "127.0.0.1" #define DEFAULT_SERVER_PORT 24007
int get_volume_statvfs (const char *volume_name, const char *server_name, struct statvfs *buf) { glfs_t *fs = NULL; int ret = 0; struct statvfs statvfsinfo = {0, }; int rv = 0;
if (!(volume_name && buf)) { return USAGE_ERROR; }
fs = glfs_new (volume_name); if (!fs) { fprintf (stderr, "glfs_new: returned NULL\n"); return GLFS_NEW_FAILURE; }
if (server_name) { ret = glfs_set_volfile_server (fs, DEFAULT_TRANSPORT, server_name, DEFAULT_SERVER_PORT); } else { ret = glfs_set_volfile_server (fs, DEFAULT_TRANSPORT, DEFAULT_SERVER, DEFAULT_SERVER_PORT); }
ret = glfs_set_logging (fs, "/dev/null", 7);
ret = glfs_init (fs); if (ret != 0) { fprintf (stderr, "glfs_init() failed with code %d\n", ret); rv = GLFS_INIT_FAILURE; goto out; }
fprintf (stdout, "waiting for 3 seconds to initialize\n"); sleep (3);
ret = glfs_statvfs (fs, "/", &statvfsinfo); if (ret == 0) { *buf = statvfsinfo; } else { fprintf (stderr, "glfs_statvfs() failed with [%d:%s] for "/"\n", ret, strerror (errno)); rv = GLFS_STATVFS_FAILURE; }
out: ret = glfs_fini (fs); if (ret != 0) { fprintf (stderr, "glfs_fini() failed with code %d\n", ret); }
return rv; }
static PyObject *glfspy_statvfs (PyObject *self, PyObject *args) { char *volume_name = NULL; char *server_name = NULL; int port = 0; char *transport = NULL; struct statvfs buf = {0, }; int rv = 0;
if (!PyArg_ParseTuple (args, "s|ziz", &volume_name, &server_name, &port, &transport)) { return NULL; }
rv = get_volume_statvfs (volume_name, server_name, &buf);
return Py_BuildValue("i", rv); }
static PyMethodDef glfspy_methods[] = { { "statvfs", (PyCFunction)glfspy_statvfs, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } };
PyMODINIT_FUNC initglfspy () { Py_InitModule3 ("glfspy", glfspy_methods, "gluster gfapi top level extension module."); }
Itamar Heim has posted comments on this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Patch Set 14:
ping
Itamar Heim has abandoned this change.
Change subject: gluster: Get size information of a gluster volume ......................................................................
Abandoned
no activity. please restore if relevant.
vdsm-patches@lists.fedorahosted.org