Revision 0c3d9c7c lib/storage/bdev.py

b/lib/storage/bdev.py
67 67
  _INVALID_NAMES = compat.UniqueFrozenset([".", "..", "snapshot", "pvmove"])
68 68
  _INVALID_SUBSTRINGS = compat.UniqueFrozenset(["_mlog", "_mimage"])
69 69

  
70
  def __init__(self, unique_id, children, size, params):
70
  def __init__(self, unique_id, children, size, params, dyn_params):
71 71
    """Attaches to a LV device.
72 72

  
73 73
    The unique_id is a tuple (vg_name, lv_name)
74 74

  
75 75
    """
76
    super(LogicalVolume, self).__init__(unique_id, children, size, params)
76
    super(LogicalVolume, self).__init__(unique_id, children, size, params,
77
                                        dyn_params)
77 78
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
78 79
      raise ValueError("Invalid configuration data %s" % str(unique_id))
79 80
    self._vg_name, self._lv_name = unique_id
......
123 124
    return map((lambda pv: pv.name), empty_pvs)
124 125

  
125 126
  @classmethod
126
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
127
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
128
             dyn_params):
127 129
    """Create a new logical volume.
128 130

  
129 131
    """
......
205 207
    if result.failed:
206 208
      base.ThrowError("LV create failed (%s): %s",
207 209
                      result.fail_reason, result.output)
208
    return LogicalVolume(unique_id, children, size, params)
210
    return LogicalVolume(unique_id, children, size, params, dyn_params)
209 211

  
210 212
  @staticmethod
211 213
  def _GetVolumeInfo(lvm_cmd, fields):
......
597 599
    snap_name = self._lv_name + ".snap"
598 600

  
599 601
    # remove existing snapshot if found
600
    snap = LogicalVolume((self._vg_name, snap_name), None, size, self.params)
602
    snap = LogicalVolume((self._vg_name, snap_name), None, size, self.params,
603
                         self.dyn_params)
601 604
    base.IgnoreError(snap.Remove)
602 605

  
603 606
    vg_info = self.GetVGInfo([self._vg_name], False)
......
717 720
  The unique_id for the file device is a (file_driver, file_path) tuple.
718 721

  
719 722
  """
720
  def __init__(self, unique_id, children, size, params):
723
  def __init__(self, unique_id, children, size, params, dyn_params):
721 724
    """Initalizes a file device backend.
722 725

  
723 726
    """
724 727
    if children:
725 728
      raise errors.BlockDeviceError("Invalid setup for file device")
726
    super(FileStorage, self).__init__(unique_id, children, size, params)
729
    super(FileStorage, self).__init__(unique_id, children, size, params,
730
                                      dyn_params)
727 731
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
728 732
      raise ValueError("Invalid configuration data %s" % str(unique_id))
729 733
    self.driver = unique_id[0]
......
836 840
      base.ThrowError("Can't stat %s: %s", self.dev_path, err)
837 841

  
838 842
  @classmethod
839
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
843
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
844
             dyn_params):
840 845
    """Create a new file.
841 846

  
842 847
    @param size: the size of file in MiB
......
865 870
        base.ThrowError("File already existing: %s", dev_path)
866 871
      base.ThrowError("Error in file creation: %", str(err))
867 872

  
868
    return FileStorage(unique_id, children, size, params)
873
    return FileStorage(unique_id, children, size, params, dyn_params)
869 874

  
870 875

  
871 876
class PersistentBlockDevice(base.BlockDev):
......
878 883
  For the time being, pathnames are required to lie under /dev.
879 884

  
880 885
  """
881
  def __init__(self, unique_id, children, size, params):
886
  def __init__(self, unique_id, children, size, params, dyn_params):
882 887
    """Attaches to a static block device.
883 888

  
884 889
    The unique_id is a path under /dev.
885 890

  
886 891
    """
887 892
    super(PersistentBlockDevice, self).__init__(unique_id, children, size,
888
                                                params)
893
                                                params, dyn_params)
889 894
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
890 895
      raise ValueError("Invalid configuration data %s" % str(unique_id))
891 896
    self.dev_path = unique_id[1]
......
904 909
    self.Attach()
905 910

  
906 911
  @classmethod
907
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
912
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
913
             dyn_params):
908 914
    """Create a new device
909 915

  
910 916
    This is a noop, we only return a PersistentBlockDevice instance
......
913 919
    if excl_stor:
914 920
      raise errors.ProgrammerError("Persistent block device requested with"
915 921
                                   " exclusive_storage")
916
    return PersistentBlockDevice(unique_id, children, 0, params)
922
    return PersistentBlockDevice(unique_id, children, 0, params, dyn_params)
917 923

  
918 924
  def Remove(self):
919 925
    """Remove a device
......
990 996
  this to be functional.
991 997

  
992 998
  """
993
  def __init__(self, unique_id, children, size, params):
999
  def __init__(self, unique_id, children, size, params, dyn_params):
994 1000
    """Attaches to an rbd device.
995 1001

  
996 1002
    """
997
    super(RADOSBlockDevice, self).__init__(unique_id, children, size, params)
1003
    super(RADOSBlockDevice, self).__init__(unique_id, children, size, params,
1004
                                           dyn_params)
998 1005
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
999 1006
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1000 1007

  
......
1004 1011
    self.Attach()
1005 1012

  
1006 1013
  @classmethod
1007
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
1014
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
1015
             dyn_params):
1008 1016
    """Create a new rbd device.
1009 1017

  
1010 1018
    Provision a new rbd volume inside a RADOS pool.
......
1027 1035
      base.ThrowError("rbd creation failed (%s): %s",
1028 1036
                      result.fail_reason, result.output)
1029 1037

  
1030
    return RADOSBlockDevice(unique_id, children, size, params)
1038
    return RADOSBlockDevice(unique_id, children, size, params, dyn_params)
1031 1039

  
1032 1040
  def Remove(self):
1033 1041
    """Remove the rbd device.
......
1343 1351
  handling of the externally provided block devices.
1344 1352

  
1345 1353
  """
1346
  def __init__(self, unique_id, children, size, params):
1354
  def __init__(self, unique_id, children, size, params, dyn_params):
1347 1355
    """Attaches to an extstorage block device.
1348 1356

  
1349 1357
    """
1350
    super(ExtStorageDevice, self).__init__(unique_id, children, size, params)
1358
    super(ExtStorageDevice, self).__init__(unique_id, children, size, params,
1359
                                           dyn_params)
1351 1360
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1352 1361
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1353 1362

  
......
1358 1367
    self.Attach()
1359 1368

  
1360 1369
  @classmethod
1361
  def Create(cls, unique_id, children, size, spindles, params, excl_stor):
1370
  def Create(cls, unique_id, children, size, spindles, params, excl_stor,
1371
             dyn_params):
1362 1372
    """Create a new extstorage device.
1363 1373

  
1364 1374
    Provision a new volume using an extstorage provider, which will
......
1377 1387
    _ExtStorageAction(constants.ES_ACTION_CREATE, unique_id,
1378 1388
                      params, str(size))
1379 1389

  
1380
    return ExtStorageDevice(unique_id, children, size, params)
1390
    return ExtStorageDevice(unique_id, children, size, params, dyn_params)
1381 1391

  
1382 1392
  def Remove(self):
1383 1393
    """Remove the extstorage device.
......
1757 1767

  
1758 1768
  """
1759 1769
  _VerifyDiskType(disk.dev_type)
1760
  device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
1761
                                  disk.params)
1770
  device = DEV_MAP[disk.dev_type](disk.logical_id, children, disk.size,
1771
                                  disk.params, disk.dynamic_params)
1762 1772
  if not device.attached:
1763 1773
    return None
1764 1774
  return device
......
1779 1789
  """
1780 1790
  _VerifyDiskType(disk.dev_type)
1781 1791
  _VerifyDiskParams(disk)
1782
  device = DEV_MAP[disk.dev_type](disk.physical_id, children, disk.size,
1783
                                  disk.params)
1792
  device = DEV_MAP[disk.dev_type](disk.logical_id, children, disk.size,
1793
                                  disk.params, disk.dynamic_params)
1784 1794
  device.Assemble()
1785 1795
  return device
1786 1796

  
......
1801 1811
  """
1802 1812
  _VerifyDiskType(disk.dev_type)
1803 1813
  _VerifyDiskParams(disk)
1804
  device = DEV_MAP[disk.dev_type].Create(disk.physical_id, children, disk.size,
1805
                                         disk.spindles, disk.params, excl_stor)
1814
  device = DEV_MAP[disk.dev_type].Create(disk.logical_id, children, disk.size,
1815
                                         disk.spindles, disk.params, excl_stor,
1816
                                         disk.dynamic_params)
1806 1817
  return device

Also available in: Unified diff