Skip to content
Snippets Groups Projects
Commit 125df9a8 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Add fields 'inst_cnt' and 'inst_list' to network queries


This adds the fields 'inst_cnt' and 'inst_list' to the
Haskell implementation of the network queries.

Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 2d3d843d
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,12 @@ networkFields =
, (FieldDefinition "group_cnt" "GroupCount" QFTOther "Number of node groups",
FieldConfig (\cfg -> rsNormal . length . getGroupConnections cfg
. networkUuid), QffNormal)
, (FieldDefinition "inst_list" "InstanceList" QFTOther "List of instances",
FieldConfig (\cfg -> rsNormal . getInstances cfg . networkUuid),
QffNormal)
, (FieldDefinition "inst_cnt" "InstanceCount" QFTOther "Number of instances",
FieldConfig (\cfg -> rsNormal . length . getInstances cfg
. networkUuid), QffNormal)
] ++
uuidFields "Network" ++
serialFields "Network" ++
......@@ -116,3 +122,13 @@ getNicMode nic_params =
getNicLink :: PartialNicParams -> String
getNicLink nic_params = fromMaybe "-" (nicpLinkP nic_params)
-- | Retrieves the network's instances' names.
getInstances :: ConfigData -> String -> [String]
getInstances cfg network_uuid =
map instName (filter (instIsConnected network_uuid)
((Map.elems . fromContainer . configInstances) cfg))
-- | Helper function that checks if an instance is linked to the given network.
instIsConnected :: String -> Instance -> Bool
instIsConnected network_uuid inst =
network_uuid `elem` map networkUuid (mapMaybe nicNetwork (instNics inst))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment