Revision fffe93e7 lib/cmdlib.py

b/lib/cmdlib.py
6713 6713
      self._GoReconnect(False)
6714 6714
      self._WaitUntilSync()
6715 6715

  
6716
    # If the instance's disk template is `rbd' and there was a successfull
6717
    # migration, unmap the device from the source node.
6718
    if self.instance.disk_template == constants.DT_RBD:
6719
      disks = _ExpandCheckDisks(instance, instance.disks)
6720
      self.feedback_fn("* unmapping instance's disks from %s" % source_node)
6721
      for disk in disks:
6722
        result = self.rpc.call_blockdev_shutdown(source_node, disk)
6723
        msg = result.fail_msg
6724
        if msg:
6725
          self.LogWarning("Migration was successfull, but couldn't unmap the"
6726
                          "block device %s on source node %s: %s",
6727
                          disk.iv_name, source_node, msg)
6728
          self.LogWarning("Try to unmap the device %s manually on %s",
6729
                          disk.iv_name, source_node)
6730

  
6716 6731
    self.feedback_fn("* done")
6717 6732

  
6718 6733
  def Exec(self, feedback_fn):
......
6944 6959
                              iv_name="disk/%d" % disk_index,
6945 6960
                              mode=disk["mode"])
6946 6961
      disks.append(disk_dev)
6962
  elif template_name == constants.DT_RBD:
6963
    if len(secondary_nodes) != 0:
6964
      raise errors.ProgrammerError("Wrong template configuration")
6965

  
6966
    names = _GenerateUniqueNames(lu, [".rbd.disk%d" % (base_index + i)
6967
                                      for i in range(disk_count)])
6968

  
6969
    for idx, disk in enumerate(disk_info):
6970
      disk_index = idx + base_index
6971
      disk_dev = objects.Disk(dev_type=constants.LD_RBD, size=disk["size"],
6972
                              logical_id=(constants.RBD_POOL, names[idx]),
6973
                              iv_name="disk/%d" % disk_index,
6974
                              mode=disk["mode"])
6975
      disks.append(disk_dev)
6947 6976

  
6948 6977
  else:
6949 6978
    raise errors.ProgrammerError("Invalid disk template '%s'" % template_name)
......
7182 7211
    constants.DT_FILE: None,
7183 7212
    constants.DT_SHARED_FILE: 0,
7184 7213
    constants.DT_BLOCK: 0,
7214
    constants.DT_RBD: 0,
7185 7215
  }
7186 7216

  
7187 7217
  if disk_template not in req_size_dict:
......
7978 8008
    nodenames = [pnode.name] + self.secondaries
7979 8009

  
7980 8010
    if not self.adopt_disks:
7981
      # Check lv size requirements, if not adopting
7982
      req_sizes = _ComputeDiskSizePerVG(self.op.disk_template, self.disks)
7983
      _CheckNodesFreeDiskPerVG(self, nodenames, req_sizes)
8011
      if self.op.disk_template == constants.DT_RBD:
8012
        # Check if there is enough space on the RADOS cluster
8013
        _CheckRADOSFreeSpace(self.op.instance_name, self.disks)
8014
      else:
8015
        # Check lv size requirements, if not adopting
8016
        req_sizes = _ComputeDiskSizePerVG(self.op.disk_template, self.disks)
8017
        _CheckNodesFreeDiskPerVG(self, nodenames, req_sizes)
7984 8018

  
7985 8019
    elif self.op.disk_template == constants.DT_PLAIN: # Check the adoption data
7986 8020
      all_lvs = set([i["vg"] + "/" + i["adopt"] for i in self.disks])
......
8295 8329
    return list(iobj.all_nodes)
8296 8330

  
8297 8331

  
8332
def _CheckRADOSFreeSpace(name, disks):
8333
  """Compute disk size requirements inside the RADOS cluster
8334

  
8335
  """
8336
  # For the RADOS cluster we assume there is always enough space
8337
  enough_space = True
8338
  if not enough_space:
8339
    raise errors.OpPrereqError("Not enough disk space inside the RADOS"
8340
                               "cluster to allocate disks for instance: %s" %
8341
                               (name), errors.ECODE_NORES)
8342

  
8343

  
8298 8344
class LUInstanceConsole(NoHooksLU):
8299 8345
  """Connect to an instance's console.
8300 8346

  
......
9294 9340
    self.disk = instance.FindDisk(self.op.disk)
9295 9341

  
9296 9342
    if instance.disk_template not in (constants.DT_FILE,
9297
                                      constants.DT_SHARED_FILE):
9343
                                      constants.DT_SHARED_FILE,
9344
                                      constants.DT_RBD):
9298 9345
      # TODO: check the free disk space for file, when that feature will be
9299 9346
      # supported
9300 9347
      _CheckNodesFreeDiskPerVG(self, nodenames,

Also available in: Unified diff