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

def lib::cmdlib::LUReplaceDisks::_ExecRR1 (   self,
) [private]

Replace the disks of an instance.

Definition at line 3401 of file cmdlib.py.

03401                                  :
    """Replace the disks of an instance.

    instance = self.instance
    iv_names = {}
    # start of work
    if self.op.remote_node is None:
      remote_node = self.sec_node
      remote_node = self.op.remote_node
    cfg = self.cfg
    for dev in instance.disks:
      size = dev.size
      lv_names = [".%s_%s" % (dev.iv_name, suf) for suf in ["data", "meta"]]
      names = _GenerateUniqueNames(cfg, lv_names)
      new_drbd = _GenerateMDDRBDBranch(cfg, instance.primary_node,
                                       remote_node, size, names)
      iv_names[dev.iv_name] = (dev, dev.children[0], new_drbd)
      logger.Info("adding new mirror component on secondary for %s" %
      if not _CreateBlockDevOnSecondary(cfg, remote_node, instance,
                                        new_drbd, False,
        raise errors.OpExecError("Failed to create new component on secondary"
                                 " node %s. Full abort, cleanup manually!" %

      logger.Info("adding new mirror component on primary")
      if not _CreateBlockDevOnPrimary(cfg, instance.primary_node,
                                      instance, new_drbd,
        # remove secondary dev
        cfg.SetDiskID(new_drbd, remote_node)
        rpc.call_blockdev_remove(remote_node, new_drbd)
        raise errors.OpExecError("Failed to create volume on primary!"
                                 " Full abort, cleanup manually!!")

      # the device exists now
      # call the primary node to add the mirror to md
      logger.Info("adding new mirror component to md")
      if not rpc.call_blockdev_addchildren(instance.primary_node, dev,
        logger.Error("Can't add mirror compoment to md!")
        cfg.SetDiskID(new_drbd, remote_node)
        if not rpc.call_blockdev_remove(remote_node, new_drbd):
          logger.Error("Can't rollback on secondary")
        cfg.SetDiskID(new_drbd, instance.primary_node)
        if not rpc.call_blockdev_remove(instance.primary_node, new_drbd):
          logger.Error("Can't rollback on primary")
        raise errors.OpExecError("Full abort, cleanup manually!!")


    # this can fail as the old devices are degraded and _WaitForSync
    # does a combined result over all disks, so we don't check its
    # return value
    _WaitForSync(cfg, instance, self.proc, unlock=True)

    # so check manually all the devices
    for name in iv_names:
      dev, child, new_drbd = iv_names[name]
      cfg.SetDiskID(dev, instance.primary_node)
      is_degr = rpc.call_blockdev_find(instance.primary_node, dev)[5]
      if is_degr:
        raise errors.OpExecError("MD device %s is degraded!" % name)
      cfg.SetDiskID(new_drbd, instance.primary_node)
      is_degr = rpc.call_blockdev_find(instance.primary_node, new_drbd)[5]
      if is_degr:
        raise errors.OpExecError("New drbd device %s is degraded!" % name)

    for name in iv_names:
      dev, child, new_drbd = iv_names[name]
      logger.Info("remove mirror %s component" % name)
      cfg.SetDiskID(dev, instance.primary_node)
      if not rpc.call_blockdev_removechildren(instance.primary_node,
                                              dev, [child]):
        logger.Error("Can't remove child from mirror, aborting"
                     " *this device cleanup*.\nYou need to cleanup manually!!")

      for node in child.logical_id[:2]:
        logger.Info("remove child device on %s" % node)
        cfg.SetDiskID(child, node)
        if not rpc.call_blockdev_remove(node, child):
          logger.Error("Warning: failed to remove device from node %s,"
                       " continuing operation." % node)



  def _ExecD8DiskOnly(self, feedback_fn):

Generated by  Doxygen 1.6.0   Back to index