Revision 125df9a8

b/src/Ganeti/Query/Network.hs
73 73
  , (FieldDefinition "group_cnt" "GroupCount" QFTOther "Number of node groups",
74 74
     FieldConfig (\cfg -> rsNormal . length . getGroupConnections cfg
75 75
       . networkUuid), QffNormal)
76
  , (FieldDefinition "inst_list" "InstanceList" QFTOther "List of instances",
77
     FieldConfig (\cfg -> rsNormal . getInstances cfg . networkUuid),
78
     QffNormal)
79
  , (FieldDefinition "inst_cnt" "InstanceCount" QFTOther "Number of instances",
80
     FieldConfig (\cfg -> rsNormal . length . getInstances cfg
81
       . networkUuid), QffNormal)
76 82
  ] ++
77 83
  uuidFields "Network" ++
78 84
  serialFields "Network" ++
......
116 122
getNicLink :: PartialNicParams -> String
117 123
getNicLink nic_params = fromMaybe "-" (nicpLinkP nic_params)
118 124

  
125
-- | Retrieves the network's instances' names.
126
getInstances :: ConfigData -> String -> [String]
127
getInstances cfg network_uuid =
128
  map instName (filter (instIsConnected network_uuid)
129
    ((Map.elems . fromContainer . configInstances) cfg))
130

  
131
-- | Helper function that checks if an instance is linked to the given network.
132
instIsConnected :: String -> Instance -> Bool
133
instIsConnected network_uuid inst =
134
  network_uuid `elem` map networkUuid (mapMaybe nicNetwork (instNics inst))

Also available in: Unified diff