Commit f2374060 authored by Iustin Pop's avatar Iustin Pop
Browse files

Enable tags query over the query socket



This patch adds the tags field to the objects which were missing it
(all except Cluster), implements handling the LuxiCall QueryTags, and
then enables the use of the query socket in cli.ListTags, used by all
commands, and in the RAPI client.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent cebd85d8
......@@ -57,6 +57,7 @@ import Test.QuickCheck.Monadic (assert, monadicIO, run, stop)
import Text.Printf (printf)
import Data.List (intercalate, nub, isPrefixOf)
import Data.Maybe
import qualified Data.Set as Set
import Control.Monad
import Control.Applicative
import qualified System.Console.GetOpt as GetOpt
......@@ -548,6 +549,7 @@ instance Arbitrary Objects.Node where
<*> arbitrary <*> arbitrary <*> arbitrary <*> getFQDN
<*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
<*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary
<*> (Set.fromList <$> genTags)
instance Arbitrary Rpc.RpcCallAllInstancesInfo where
arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary
......
......@@ -293,7 +293,8 @@ $(buildObject "Instance" "inst" $
]
++ timeStampFields
++ uuidFields
++ serialFields)
++ serialFields
++ tagsFields)
-- * IPolicy definitions
......@@ -374,7 +375,8 @@ $(buildObject "Node" "node" $
]
++ timeStampFields
++ uuidFields
++ serialFields)
++ serialFields
++ tagsFields)
-- * NodeGroup definitions
......@@ -402,7 +404,8 @@ $(buildObject "NodeGroup" "group" $
]
++ timeStampFields
++ uuidFields
++ serialFields)
++ serialFields
++ tagsFields)
-- | IP family type
$(declareIADT "IpFamily"
......
......@@ -29,6 +29,7 @@ module Ganeti.Queryd
where
import Control.Applicative
import Control.Concurrent
import Control.Exception
import Data.Bits (bitSize)
......@@ -41,7 +42,7 @@ import System.Info (arch)
import qualified Ganeti.Constants as C
import Ganeti.Objects
--import Ganeti.Config
import qualified Ganeti.Config as Config
import Ganeti.BasicTypes
import Ganeti.Logging
import Ganeti.Luxi
......@@ -118,6 +119,14 @@ handleCall cdata QueryClusterInfo =
in return . Ok . J.makeObj $ obj
handleCall cfg (QueryTags kind name) =
let tags = case kind of
TagCluster -> Ok . clusterTags $ configCluster cfg
TagGroup -> groupTags <$> Config.getGroup cfg name
TagNode -> nodeTags <$> Config.getNode cfg name
TagInstance -> instTags <$> Config.getInstance cfg name
in return (J.showJSON <$> tags)
handleCall _ op =
return . Bad $ "Luxi call '" ++ strOfOp op ++ "' not implemented"
......
......@@ -464,7 +464,7 @@ def ListTags(opts, args):
"""
kind, name = _ExtractTagsObject(opts, args)
cl = GetClient()
cl = GetClient(query=True)
result = cl.QueryTags(kind, name)
result = list(result)
result.sort()
......
......@@ -1339,7 +1339,7 @@ class _R_Tags(baserlib.OpcodeResource):
if not self.name:
raise http.HttpBadRequest("Missing name on tag request")
cl = self.GetClient()
cl = self.GetClient(query=True)
tags = list(cl.QueryTags(kind, self.name))
elif kind == constants.TAG_CLUSTER:
......
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