New method GetUserspaceAccessURI in storage class
[ganeti-local] / lib / storage / base.py
index 5f58b6e..ee8c0c6 100644 (file)
@@ -72,7 +72,7 @@ class BlockDev(object):
   after assembly we'll have our correct major/minor.
 
   """
-  def __init__(self, unique_id, children, size, params):
+  def __init__(self, unique_id, children, size, params, dyn_params):
     self._children = children
     self.dev_path = None
     self.unique_id = unique_id
@@ -81,6 +81,7 @@ class BlockDev(object):
     self.attached = False
     self.size = size
     self.params = params
+    self.dyn_params = dyn_params
 
   def Assemble(self):
     """Assemble the device from its components.
@@ -109,7 +110,8 @@ class BlockDev(object):
     raise NotImplementedError
 
   @classmethod
-  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
+  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
+             dyn_params):
     """Create the device.
 
     If the device cannot be created, it will return None
@@ -132,6 +134,9 @@ class BlockDev(object):
     @param params: device-specific options/parameters
     @type excl_stor: bool
     @param excl_stor: whether exclusive_storage is active
+    @type dyn_params: dict
+    @param dyn_params: dynamic parameters of the disk only valid for this node.
+        As set by L{objects.Disk.UpdateDynamicDiskParams}.
     @rtype: L{BlockDev}
     @return: the created device, or C{None} in case of an error
 
@@ -298,7 +303,7 @@ class BlockDev(object):
     for child in self._children:
       child.SetInfo(text)
 
-  def Grow(self, amount, dryrun, backingstore):
+  def Grow(self, amount, dryrun, backingstore, excl_stor):
     """Grow the block device.
 
     @type amount: integer
@@ -309,6 +314,8 @@ class BlockDev(object):
     @param backingstore: whether to execute the operation on backing storage
         only, or on "logical" storage only; e.g. DRBD is logical storage,
         whereas LVM, file, RBD are backing storage
+    @type excl_stor: boolean
+    @param excl_stor: Whether exclusive_storage is active
 
     """
     raise NotImplementedError
@@ -352,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,