Revision af5dd836

b/lib/config.py
260 260
    nodegroup = self._UnlockedGetNodeGroup(node.group)
261 261
    return self._UnlockedGetGroupDiskParams(nodegroup)
262 262

  
263
  def _UnlockedGetInstanceDisks(self, instance):
264
    """Return the disks' info for the given instance
265

  
266
    This function is for internal use, when the config lock is already held.
267

  
268
    """
269
    return [self._UnlockedGetDiskInfo(disk) for disk in instance.disks]
270

  
271
  @locking.ssynchronized(_config_lock, shared=1)
272
  def GetInstanceDisks(self, instance):
273
    """Return the disks' info for the given instance
274

  
275
    @type instance: L{objects.Instance}
276
    @param instance: The instance we want to know the disks for
277

  
278
    @rtype: List of L{objects.Disk}
279
    @return: A list with all the disks' info
280

  
281
    """
282
    return self._UnlockedGetInstanceDisks(instance)
283

  
284
  def _UnlockedGetDiskInfo(self, disk_uuid):
285
    """Returns information about an instance.
286

  
287
    This function is for internal use, when the config lock is already held.
288

  
289
    """
290
    if disk_uuid not in self._config_data.disks:
291
      return None
292

  
293
    return self._config_data.disks[disk_uuid]
294

  
295
  @locking.ssynchronized(_config_lock, shared=1)
296
  def GetDiskInfo(self, disk_uuid):
297
    """Returns information about a disk.
298

  
299
    It takes the information from the configuration file.
300

  
301
    @param disk_uuid: UUID of the disk
302

  
303
    @rtype: L{objects.Disk}
304
    @return: the disk object
305

  
306
    """
307
    return self._UnlockedGetDiskInfo(disk_uuid)
308

  
263 309
  # pylint: disable=R0201
264 310
  def _UnlockedGetInstanceNodes(self, instance, disks=None):
265 311
    """Get all disk-releated nodes for an instance.
b/src/Ganeti/Config.hs
36 36
    , getMasterCandidates
37 37
    , getNode
38 38
    , getInstance
39
    , getDisk
39 40
    , getGroup
40 41
    , getGroupNdParams
41 42
    , getGroupIpolicy
......
132 133

  
133 134
-- | Get the list of master candidates.
134 135
getMasterCandidates :: ConfigData -> [Node]
135
getMasterCandidates cfg = 
136
getMasterCandidates cfg =
136 137
  filter ((==) NRCandidate . getNodeRole cfg)
137 138
    (map snd . M.toList . fromContainer . configNodes $ cfg)
138 139

  
......
194 195
                              (instName . (M.!) instances) instances
195 196
                in getItem "Instance" name by_name
196 197

  
198
-- | Looks up a disk by uuid.
199
getDisk :: ConfigData -> String -> ErrorResult Disk
200
getDisk cfg name =
201
  let disks = fromContainer (configDisks cfg)
202
  in getItem "Disk" name disks
203

  
197 204
-- | Looks up a node group by name or uuid.
198 205
getGroup :: ConfigData -> String -> ErrorResult NodeGroup
199 206
getGroup cfg name =
......
312 319
  pNode <- getInstPrimaryNode cfg name
313 320
  return . nub $ pNode:diskNodes
314 321

  
322
-- | Get disks for a given instance.
323
-- The instance is specified by name or uuid.
324
--getInstDisks :: ConfigData -> String -> ErrorResult [Disk]
325
--getInstDisks cfg iname = do
326
--  let inst = getInstance cfg iname
327
--  mapM (getDisk cfg) $ instDisks inst
328

  
315 329
-- | Filters DRBD minors for a given node.
316 330
getDrbdMinorsForNode :: String -> Disk -> [(Int, String)]
317 331
getDrbdMinorsForNode node disk =

Also available in: Unified diff