Commit 9d0b521e authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Hrvoje Ribicic

Fix gnt-network list-tags

Define network tags in haskell part.

This fixes issue 641.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 6ce56f8f
......@@ -311,6 +311,7 @@ $(declareSADT "TagType"
, ("TagTypeNode", 'C.tagNode)
, ("TagTypeGroup", 'C.tagNodegroup)
, ("TagTypeCluster", 'C.tagCluster)
, ("TagTypeNetwork", 'C.tagNetwork)
])
$(makeJSONInstance ''TagType)
......@@ -318,6 +319,7 @@ $(makeJSONInstance ''TagType)
data TagObject = TagInstance String
| TagNode String
| TagGroup String
| TagNetwork String
| TagCluster
deriving (Show, Eq)
......@@ -327,12 +329,14 @@ tagTypeOf (TagInstance {}) = TagTypeInstance
tagTypeOf (TagNode {}) = TagTypeNode
tagTypeOf (TagGroup {}) = TagTypeGroup
tagTypeOf (TagCluster {}) = TagTypeCluster
tagTypeOf (TagNetwork {}) = TagTypeNetwork
-- | Gets the potential tag object name.
tagNameOf :: TagObject -> Maybe String
tagNameOf (TagInstance s) = Just s
tagNameOf (TagNode s) = Just s
tagNameOf (TagGroup s) = Just s
tagNameOf (TagNetwork s) = Just s
tagNameOf TagCluster = Nothing
-- | Builds a 'TagObject' from a tag type and name.
......@@ -341,6 +345,8 @@ tagObjectFrom TagTypeInstance (JSString s) =
return . TagInstance $ fromJSString s
tagObjectFrom TagTypeNode (JSString s) = return . TagNode $ fromJSString s
tagObjectFrom TagTypeGroup (JSString s) = return . TagGroup $ fromJSString s
tagObjectFrom TagTypeNetwork (JSString s) =
return . TagNetwork $ fromJSString s
tagObjectFrom TagTypeCluster JSNull = return TagCluster
tagObjectFrom t v =
fail $ "Invalid tag type/name combination: " ++ show t ++ "/" ++
......
......@@ -150,6 +150,7 @@ handleCall cfg (QueryTags kind) =
TagGroup name -> groupTags <$> Config.getGroup cfg name
TagNode name -> nodeTags <$> Config.getNode cfg name
TagInstance name -> instTags <$> Config.getInstance cfg name
TagNetwork name -> networkTags <$> Config.getNetwork cfg name
in return (J.showJSON <$> tags)
handleCall cfg (Query qkind qfields qfilter) = do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment