Commit f83057ad authored by Raffa Santi's avatar Raffa Santi Committed by Thomas Thrainer
Browse files

New method GetUserspaceAccessURI in storage class



Returns a hypervisor specific URI for RBD template when userspace
access is requested.
Signed-off-by: default avatarSanti Raffa <rsanti@google.com>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 9b9e088c
......@@ -359,6 +359,18 @@ class BlockDev(object):
"""
return (self.GetActualSize(), self.GetActualSpindles())
def GetUserspaceAccessUri(self, hypervisor):
"""Return URIs hypervisors can use to access disks in userspace mode.
@rtype: string
@return: userspace device URI
@raise errors.BlockDeviceError if userspace access is not supported
"""
ThrowError("Userspace access with %s block device and %s hypervisor is not "
"supported." % (self.__class__.__name__,
hypervisor))
def __repr__(self):
return ("<%s: unique_id: %s, children: %s, %s:%s, %s>" %
(self.__class__, self.unique_id, self._children,
......
......@@ -1006,6 +1006,7 @@ class RADOSBlockDevice(base.BlockDev):
raise ValueError("Invalid configuration data %s" % str(unique_id))
self.driver, self.rbd_name = unique_id
self.rbd_pool = params[constants.LDP_POOL]
self.major = self.minor = None
self.Attach()
......@@ -1343,6 +1344,18 @@ class RADOSBlockDevice(base.BlockDev):
base.ThrowError("rbd resize failed (%s): %s",
result.fail_reason, result.output)
def GetUserspaceAccessUri(self, hypervisor):
"""Generate KVM userspace URIs to be used as `-drive file` settings.
@see: L{BlockDev.GetUserspaceAccessUri}
"""
if hypervisor == constants.HT_KVM:
return "rbd:" + self.rbd_pool + "/" + self.rbd_name
else:
base.ThrowError("Hypervisor %s doesn't support RBD userspace access" %
hypervisor)
class ExtStorageDevice(base.BlockDev):
"""A block device provided by an ExtStorage Provider.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment