Revision 03b9bec5
b/lib/config.py | ||
---|---|---|
281 | 281 |
nodegroup = self._UnlockedGetNodeGroup(node.group) |
282 | 282 |
return self._UnlockedGetGroupDiskParams(nodegroup) |
283 | 283 |
|
284 |
def _UnlockedGetInstanceDisks(self, instance): |
|
285 |
"""Return the disks' info for the given instance |
|
286 |
|
|
287 |
This function is for internal use, when the config lock is already held. |
|
288 |
|
|
289 |
""" |
|
290 |
return [self._UnlockedGetDiskInfo(disk) for disk in instance.disks] |
|
291 |
|
|
292 |
@locking.ssynchronized(_config_lock, shared=1) |
|
293 |
def GetInstanceDisks(self, instance): |
|
294 |
"""Return the disks' info for the given instance |
|
295 |
|
|
296 |
@type instance: L{objects.Instance} |
|
297 |
@param instance: The instance we want to know the disks for |
|
298 |
|
|
299 |
@rtype: List of L{objects.Disk} |
|
300 |
@return: A list with all the disks' info |
|
301 |
|
|
302 |
""" |
|
303 |
return self._UnlockedGetInstanceDisks(instance) |
|
304 |
|
|
305 |
def _UnlockedGetDiskInfo(self, disk_uuid): |
|
306 |
"""Returns information about an instance. |
|
307 |
|
|
308 |
This function is for internal use, when the config lock is already held. |
|
309 |
|
|
310 |
""" |
|
311 |
if disk_uuid not in self._config_data.disks: |
|
312 |
return None |
|
313 |
|
|
314 |
return self._config_data.disks[disk_uuid] |
|
315 |
|
|
316 |
@locking.ssynchronized(_config_lock, shared=1) |
|
317 |
def GetDiskInfo(self, disk_uuid): |
|
318 |
"""Returns information about a disk. |
|
319 |
|
|
320 |
It takes the information from the configuration file. |
|
321 |
|
|
322 |
@param disk_uuid: UUID of the disk |
|
323 |
|
|
324 |
@rtype: L{objects.Disk} |
|
325 |
@return: the disk object |
|
326 |
|
|
327 |
""" |
|
328 |
return self._UnlockedGetDiskInfo(disk_uuid) |
|
329 |
|
|
284 | 330 |
# pylint: disable=R0201 |
285 | 331 |
def _UnlockedGetInstanceNodes(self, instance, disks=None): |
286 | 332 |
"""Get all disk-releated nodes for an instance. |
b/src/Ganeti/Config.hs | ||
---|---|---|
38 | 38 |
, getOnlineNodes |
39 | 39 |
, getNode |
40 | 40 |
, getInstance |
41 |
, getDisk |
|
41 | 42 |
, getGroup |
42 | 43 |
, getGroupNdParams |
43 | 44 |
, getGroupIpolicy |
... | ... | |
48 | 49 |
, getInstPrimaryNode |
49 | 50 |
, getInstMinorsForNode |
50 | 51 |
, getInstAllNodes |
52 |
, getInstDisks |
|
53 |
, getInstDisksByName |
|
51 | 54 |
, getFilledInstHvParams |
52 | 55 |
, getFilledInstBeParams |
53 | 56 |
, getFilledInstOsParams |
... | ... | |
209 | 212 |
(instName . (M.!) instances) instances |
210 | 213 |
in getItem "Instance" name by_name |
211 | 214 |
|
215 |
-- | Looks up a disk by uuid. |
|
216 |
getDisk :: ConfigData -> String -> ErrorResult Disk |
|
217 |
getDisk cfg name = |
|
218 |
let disks = fromContainer (configDisks cfg) |
|
219 |
in getItem "Disk" name disks |
|
220 |
|
|
212 | 221 |
-- | Looks up a node group by name or uuid. |
213 | 222 |
getGroup :: ConfigData -> String -> ErrorResult NodeGroup |
214 | 223 |
getGroup cfg name = |
... | ... | |
327 | 336 |
pNode <- getInstPrimaryNode cfg name |
328 | 337 |
return . nub $ pNode:diskNodes |
329 | 338 |
|
339 |
-- | Get disks for a given instance object. |
|
340 |
getInstDisks :: ConfigData -> Instance -> ErrorResult [Disk] |
|
341 |
getInstDisks _cfg = |
|
342 |
-- mapM (getDisk cfg) . instDisks |
|
343 |
return . instDisks |
|
344 |
|
|
345 |
-- | Get disks for a given instance. |
|
346 |
-- The instance is specified by name or uuid. |
|
347 |
getInstDisksByName :: ConfigData -> String -> ErrorResult [Disk] |
|
348 |
getInstDisksByName cfg iname = |
|
349 |
getInstance cfg iname >>= getInstDisks cfg |
|
350 |
|
|
330 | 351 |
-- | Filters DRBD minors for a given node. |
331 | 352 |
getDrbdMinorsForNode :: String -> Disk -> [(Int, String)] |
332 | 353 |
getDrbdMinorsForNode node disk = |
Also available in: Unified diff