Revision 54c7dff7

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

  
36 37

  
......
82 83
dcCategory :: Maybe DCCategory
83 84
dcCategory = Just DCStorage
84 85

  
86
-- | The kind of this data collector.
87
dcKind :: DCKind
88
dcKind = DCKStatus
89

  
85 90
-- * Command line options
86 91

  
87 92
options :: IO [OptType]
......
130 135
        show (Prelude.take defaultCharNum $ unpack unparsedText) ++ "\n"
131 136
          ++ show contexts ++ "\n" ++ errorMessage
132 137
      A.Done _ drbdStatus -> return $ J.showJSON drbdStatus
133
  buildReport dcName dcVersion dcFormatVersion dcCategory jsonData
138
  buildReport dcName dcVersion dcFormatVersion dcCategory dcKind jsonData
134 139

  
135 140
-- | Main function.
136 141
main :: Options -> [String] -> IO ()
b/src/Ganeti/DataCollectors/Types.hs
28 28
module Ganeti.DataCollectors.Types
29 29
  ( DCReport(..)
30 30
  , DCCategory(..)
31
  , DCKind(..)
31 32
  , DCVersion(..)
32 33
  , buildReport
33 34
  ) where
......
48 49
  readJSON =
49 50
    error "JSON read instance not implemented for type DCCategory"
50 51

  
52
-- | The type representing the kind of the collector.
53
data DCKind = DCKPerf   -- ^ Performance reporting collector
54
            | DCKStatus -- ^ Status reporting collector
55
            deriving (Show, Eq)
56

  
57
-- | The JSON instance for CollectorKind.
58
instance JSON DCKind where
59
  showJSON DCKPerf   = showJSON (0 :: Int)
60
  showJSON DCKStatus = showJSON (1 :: Int)
61
  readJSON = error "JSON read instance not implemented for type DCKind"
62

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

  
......
65 77
  , simpleField "timestamp"      [t| Integer |]
66 78
  , optionalNullSerField $
67 79
      simpleField "category"     [t| DCCategory |]
80
  , simpleField "kind"           [t| DCKind |]
68 81
  , simpleField "data"           [t| JSValue |]
69 82
  ])
70 83

  
......
72 85
-- timestamp (rounded up to seconds).
73 86
-- If the version is not specified, it will be set to the value indicating
74 87
-- a builtin collector.
75
buildReport :: String -> DCVersion -> Int -> Maybe DCCategory -> JSValue
76
            -> IO DCReport
77
buildReport name version format_version category jsonData = do
88
buildReport :: String -> DCVersion -> Int -> Maybe DCCategory -> DCKind
89
            -> JSValue -> IO DCReport
90
buildReport name version format_version category kind jsonData = do
78 91
  now <- getCurrentTime
79 92
  let timestamp = now * 1000000000 :: Integer
80
  return $ DCReport name version format_version timestamp category jsonData
93
  return $
94
    DCReport name version format_version timestamp category kind
95
      jsonData

Also available in: Unified diff