Revision 843094ad lib/objects.py

b/lib/objects.py
1108 1108
  all_nodes = property(_ComputeAllNodes, None, None,
1109 1109
                       "List of names of all the nodes of the instance")
1110 1110

  
1111
  def MapLVsByNode(self, lvmap=None, devs=None, node=None):
1111
  def MapLVsByNode(self, lvmap=None, devs=None, node_uuid=None):
1112 1112
    """Provide a mapping of nodes to LVs this instance owns.
1113 1113

  
1114 1114
    This function figures out what logical volumes should belong on
1115 1115
    which nodes, recursing through a device tree.
1116 1116

  
1117
    @type lvmap: dict
1117 1118
    @param lvmap: optional dictionary to receive the
1118 1119
        'node' : ['lv', ...] data.
1119

  
1120
    @type devs: list of L{Disk}
1121
    @param devs: disks to get the LV name for. If None, all disk of this
1122
        instance are used.
1123
    @type node_uuid: string
1124
    @param node_uuid: UUID of the node to get the LV names for. If None, the
1125
        primary node of this instance is used.
1120 1126
    @return: None if lvmap arg is given, otherwise, a dictionary of
1121 1127
        the form { 'node_uuid' : ['volume1', 'volume2', ...], ... };
1122 1128
        volumeN is of the form "vg_name/lv_name", compatible with
1123 1129
        GetVolumeList()
1124 1130

  
1125 1131
    """
1126
    if node is None:
1127
      node = self.primary_node
1132
    if node_uuid is None:
1133
      node_uuid = self.primary_node
1128 1134

  
1129 1135
    if lvmap is None:
1130 1136
      lvmap = {
1131
        node: [],
1137
        node_uuid: [],
1132 1138
        }
1133 1139
      ret = lvmap
1134 1140
    else:
1135
      if not node in lvmap:
1136
        lvmap[node] = []
1141
      if not node_uuid in lvmap:
1142
        lvmap[node_uuid] = []
1137 1143
      ret = None
1138 1144

  
1139 1145
    if not devs:
......
1141 1147

  
1142 1148
    for dev in devs:
1143 1149
      if dev.dev_type == constants.LD_LV:
1144
        lvmap[node].append(dev.logical_id[0] + "/" + dev.logical_id[1])
1150
        lvmap[node_uuid].append(dev.logical_id[0] + "/" + dev.logical_id[1])
1145 1151

  
1146 1152
      elif dev.dev_type in constants.LDS_DRBD:
1147 1153
        if dev.children:
......
1149 1155
          self.MapLVsByNode(lvmap, dev.children, dev.logical_id[1])
1150 1156

  
1151 1157
      elif dev.children:
1152
        self.MapLVsByNode(lvmap, dev.children, node)
1158
        self.MapLVsByNode(lvmap, dev.children, node_uuid)
1153 1159

  
1154 1160
    return ret
1155 1161

  

Also available in: Unified diff