Logo Search packages:      
Sourcecode: ganeti version File versions  Download package

def lib::bdev::MDRaid1::RemoveChildren (   self,
  devices 
)

Remove member(s) from the md raid1.

Definition at line 776 of file bdev.py.

00776                                    :
    """Remove member(s) from the md raid1.

    """
    if self.minor is None and not self.Attach():
      raise errors.BlockDeviceError("Can't attach to device")
    new_len = len(self._children) - len(devices)
    if new_len < 1:
      raise errors.BlockDeviceError("Can't reduce to less than one child")
    args = ["mdadm", "-f", self.dev_path]
    orig_devs = []
    for dev in devices:
      args.append(dev)
      for c in self._children:
        if c.dev_path == dev:
          orig_devs.append(c)
          break
      else:
        raise errors.BlockDeviceError("Can't find device '%s' for removal" %
                                      dev)
    result = utils.RunCmd(args)
    if result.failed:
      raise errors.BlockDeviceError("Failed to mark device(s) as failed: %s" %
                                    result.output)

    # it seems here we need a short delay for MD to update its
    # superblocks
    time.sleep(0.5)
    args[1] = "-r"
    result = utils.RunCmd(args)
    if result.failed:
      raise errors.BlockDeviceError("Failed to remove device(s) from array:"
                                    " %s" % result.output)
    result = utils.RunCmd(["mdadm", "--grow", "--force", self.dev_path,
                           "-n", new_len])
    if result.failed:
      raise errors.BlockDeviceError("Can't shrink md array: %s" %
                                    result.output)
    for dev in orig_devs:
      self._children.remove(dev)

  def GetStatus(self):


Generated by  Doxygen 1.6.0   Back to index