On Wed, Oct 2, 2013 at 11:02 AM, Raffa Santi <[email protected]> wrote:

> Returns a hypervisor specific URI for RBD template when userspace
> access is requested.
>
> Signed-off-by: Raffa Santi <[email protected]>
> ---
>  lib/storage/base.py |   13 +++++++++++++
>  lib/storage/bdev.py |   14 ++++++++++++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/lib/storage/base.py b/lib/storage/base.py
> index 3f244e5..7c1981b 100644
> --- a/lib/storage/base.py
> +++ b/lib/storage/base.py
> @@ -359,6 +359,19 @@ 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,
> diff --git a/lib/storage/bdev.py b/lib/storage/bdev.py
> index e3ffae8..365452c 100644
> --- a/lib/storage/bdev.py
> +++ b/lib/storage/bdev.py
> @@ -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,19 @@ 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:
> +      raise errors.BlockDeviceError("Hypervisor %s doesn't support"
> +                                    " RBD userspace access" % hypervisor)
>

Use base.ThrowError().

Rest LGTM, no need to resend, I'll fix before pushing.


> +
>
>  class ExtStorageDevice(base.BlockDev):
>    """A block device provided by an ExtStorage Provider.
> --
> 1.7.10.4
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to