Revision 9b648ee7

b/lib/storage.py
50 50
    """
51 51
    raise NotImplementedError()
52 52

  
53
  def Modify(self, name, changes):
54
    """Modifies an entity within the storage unit.
55

  
56
    @type name: string
57
    @param name: Entity name
58
    @type changes: dict
59
    @param changes: New field values
60

  
61
    """
62
    # Don't raise an error if no changes are requested
63
    if changes:
64
      raise errors.ProgrammerError("Unable to modify the following"
65
                                   "fields: %r" % (changes.keys(), ))
66

  
53 67

  
54 68
class FileStorage(_Base):
55 69
  """File storage unit.
......
298 312
    (constants.SF_ALLOCATABLE, "pv_attr", _GetAllocatable),
299 313
    ]
300 314

  
315
  def _SetAllocatable(self, name, allocatable):
316
    """Sets the "allocatable" flag on a physical volume.
317

  
318
    @type name: string
319
    @param name: Physical volume name
320
    @type allocatable: bool
321
    @param allocatable: Whether to set the "allocatable" flag
322

  
323
    """
324
    args = ["pvchange", "--allocatable"]
325

  
326
    if allocatable:
327
      args.append("y")
328
    else:
329
      args.append("n")
330

  
331
    args.append(name)
332

  
333
    result = utils.RunCmd(args)
334
    if result.failed:
335
      raise errors.StorageError("Failed to modify physical volume,"
336
                                " pvchange output: %s" %
337
                                result.output)
338

  
339
  def Modify(self, name, changes):
340
    """Modifies flags on a physical volume.
341

  
342
    See L{_Base.Modify}.
343

  
344
    """
345
    if constants.SF_ALLOCATABLE in changes:
346
      self._SetAllocatable(name, changes[constants.SF_ALLOCATABLE])
347
      del changes[constants.SF_ALLOCATABLE]
348

  
349
    # Other changes will be handled (and maybe refused) by the base class.
350
    return _LvmBase.Modify(self, name, changes)
351

  
301 352

  
302 353
class LvmVgStorage(_LvmBase):
303 354
  """LVM Volume Group storage unit.

Also available in: Unified diff