summaryrefslogtreecommitdiffstats
path: root/gluster/gfapi/gfapi.py
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2018-01-11 17:53:08 +0530
committerPrashanth Pai <ppai@redhat.com>2018-01-11 17:53:27 +0530
commitb5073b090535744608164e266badba919298f894 (patch)
tree2a3803cb22c74acabebc2462458cd84bcc49b7d1 /gluster/gfapi/gfapi.py
parentb125ff3e83283f231295873118ed7a170f4284d1 (diff)
Add get_volume_id() API
Change-Id: Ia4c378c5b1657bb4ec23c7057c7cbc49c1b31484 Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'gluster/gfapi/gfapi.py')
-rw-r--r--gluster/gfapi/gfapi.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/gluster/gfapi/gfapi.py b/gluster/gfapi/gfapi.py
index d48aa06..c01d534 100644
--- a/gluster/gfapi/gfapi.py
+++ b/gluster/gfapi/gfapi.py
@@ -14,6 +14,7 @@ import math
import time
import stat
import errno
+import uuid
from collections import Iterator
from gluster.gfapi import api
@@ -666,6 +667,7 @@ class Volume(object):
self.host = host
self.volname = volname
+ self.volid = None
self.protocol = proto
self.port = port
@@ -770,6 +772,23 @@ class Volume(object):
self.log_level = log_level
@validate_mount
+ def get_volume_id(self):
+ """
+ Returns the volume ID (of type uuid.UUID) for the currently mounted
+ volume.
+ """
+ if self.volid != None:
+ return self.volid
+ size = 16
+ buf = ctypes.create_string_buffer(size)
+ ret = api.glfs_get_volumeid(self.fs, buf, size)
+ if ret < 0:
+ err = ctypes.get_errno()
+ raise OSError(err, os.strerror(err))
+ self.volid = uuid.UUID(bytes=buf.raw)
+ return self.volid
+
+ @validate_mount
def access(self, path, mode):
"""
Use the real uid/gid to test for access to path.