Revision 7abe5725

b/lib/config.py
312 312
    """
313 313
    return self._UnlockedGetInstanceSecondaryNodes(instance)
314 314

  
315
  # pylint: disable=R0201
316
  def _UnlockedGetInstanceLVsByNode(self, instance, lvmap=None):
317
    """Provide a mapping of node to LVs a given instance owns.
318

  
319
    This is a simple wrapper over _UnlockedGetInstanceNodes.
320

  
321
    """
322
    def _MapLVsByNode(lvmap, devs, node_uuid):
323
      """Recursively helper function."""
324
      if not node_uuid in lvmap:
325
        lvmap[node_uuid] = []
326

  
327
      for dev in devs:
328
        if dev.dev_type == constants.DT_PLAIN:
329
          lvmap[node_uuid].append(dev.logical_id[0] + "/" + dev.logical_id[1])
330

  
331
        elif dev.dev_type in constants.DTS_DRBD:
332
          if dev.children:
333
            _MapLVsByNode(lvmap, dev.children, dev.logical_id[0])
334
            _MapLVsByNode(lvmap, dev.children, dev.logical_id[1])
335

  
336
        elif dev.children:
337
          _MapLVsByNode(lvmap, devs.children, node_uuid)
338

  
339
    if lvmap is None:
340
      lvmap = {}
341
      ret = lvmap
342
    else:
343
      ret = None
344

  
345
    node_uuid = instance.primary_node
346
    devs = instance.disks
347
    _MapLVsByNode(lvmap, devs, node_uuid)
348
    return ret
349

  
350
  @locking.ssynchronized(_config_lock, shared=1)
351
  def GetInstanceLVsByNode(self, instance, lvmap=None):
352
    """Provide a mapping of node to LVs a given instance owns.
353

  
354
    This function figures out what logical volums should belong on
355
    which nodes, recursing through a device tree.
356

  
357
    @type instance: L{objects.Instance}
358
    @param instance: The instance we want to compute the LVsByNode for
359
    @type lvmap: dict
360
    @param lvmap: optional dictionary to receive the
361
        'node' : ['lv', ...] data.
362
    @return: None if lvmap arg is given, otherwise, a dictionary of
363
        the form { 'node_uuid' : ['volume1', 'volume2', ...], ... };
364
        volumeN is of the form "vg_name/lv_name", compatible with
365
        GetVolumeList()
366

  
367
    """
368
    return self._UnlockedGetInstanceLVsByNode(instance, lvmap=lvmap)
369

  
315 370
  @locking.ssynchronized(_config_lock, shared=1)
316 371
  def GetGroupDiskParams(self, group):
317 372
    """Get the disk params populated with inherit chain.

Also available in: Unified diff