Revision f0e4b2a4

b/src/Ganeti/DataCollectors/Drbd.hs
30 30
  , dcName
31 31
  , dcVersion
32 32
  , dcFormatVersion
33
  , dcCategory
33 34
  ) where
34 35

  
35 36

  
......
77 78
dcFormatVersion :: Int
78 79
dcFormatVersion = 1
79 80

  
81
-- | The category of this data collector.
82
dcCategory :: Maybe DCCategory
83
dcCategory = Just DCStorage
84

  
80 85
-- * Command line options
81 86

  
82 87
options :: IO [OptType]
......
125 130
        show (Prelude.take defaultCharNum $ unpack unparsedText) ++ "\n"
126 131
          ++ show contexts ++ "\n" ++ errorMessage
127 132
      A.Done _ drbdStatus -> return $ J.showJSON drbdStatus
128
  buildReport dcName dcVersion dcFormatVersion jsonData
133
  buildReport dcName dcVersion dcFormatVersion dcCategory jsonData
129 134

  
130 135
-- | Main function.
131 136
main :: Options -> [String] -> IO ()
b/src/Ganeti/DataCollectors/Types.hs
27 27

  
28 28
module Ganeti.DataCollectors.Types
29 29
  ( DCReport(..)
30
  , DCCategory(..)
30 31
  , DCVersion(..)
31 32
  , buildReport
32 33
  ) where
......
37 38
import Ganeti.THH
38 39
import Ganeti.Utils (getCurrentTime)
39 40

  
41
-- | The possible classes a data collector can belong to.
42
data DCCategory = DCInstance | DCStorage | DCDaemon | DCHypervisor
43
  deriving (Show, Eq)
44

  
45
-- | The JSON instance for DCCategory.
46
instance JSON DCCategory where
47
  showJSON = showJSON . show
48
  readJSON =
49
    error "JSON read instance not implemented for type DCCategory"
50

  
40 51
-- | Type representing the version number of a data collector.
41 52
data DCVersion = DCVerBuiltin | DCVersion String deriving (Show, Eq)
42 53

  
......
52 63
  , simpleField "version"        [t| DCVersion |]
53 64
  , simpleField "format_version" [t| Int |]
54 65
  , simpleField "timestamp"      [t| Integer |]
66
  , optionalNullSerField $
67
      simpleField "category"     [t| DCCategory |]
55 68
  , simpleField "data"           [t| JSValue |]
56 69
  ])
57 70

  
......
59 72
-- timestamp (rounded up to seconds).
60 73
-- If the version is not specified, it will be set to the value indicating
61 74
-- a builtin collector.
62
buildReport :: String -> DCVersion -> Int -> JSValue -> IO DCReport
63
buildReport name version format_version jsonData = do
75
buildReport :: String -> DCVersion -> Int -> Maybe DCCategory -> JSValue
76
            -> IO DCReport
77
buildReport name version format_version category jsonData = do
64 78
  now <- getCurrentTime
65 79
  let timestamp = now * 1000000000 :: Integer
66
  return $ DCReport name version format_version timestamp jsonData
80
  return $ DCReport name version format_version timestamp category jsonData

Also available in: Unified diff