Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Storage / Drbd / Types.hs @ a1f35d0a

History | View | Annotate | Download (13.4 kB)

1 3c1915df Michele Tartara
{-| DRBD Data Types
2 3c1915df Michele Tartara
3 3c1915df Michele Tartara
This module holds the definition of the data types describing the status of
4 3c1915df Michele Tartara
DRBD.
5 3c1915df Michele Tartara
6 3c1915df Michele Tartara
-}
7 3c1915df Michele Tartara
{-
8 3c1915df Michele Tartara
9 3c1915df Michele Tartara
Copyright (C) 2012 Google Inc.
10 3c1915df Michele Tartara
11 3c1915df Michele Tartara
This program is free software; you can redistribute it and/or modify
12 3c1915df Michele Tartara
it under the terms of the GNU General Public License as published by
13 3c1915df Michele Tartara
the Free Software Foundation; either version 2 of the License, or
14 3c1915df Michele Tartara
(at your option) any later version.
15 3c1915df Michele Tartara
16 3c1915df Michele Tartara
This program is distributed in the hope that it will be useful, but
17 3c1915df Michele Tartara
WITHOUT ANY WARRANTY; without even the implied warranty of
18 3c1915df Michele Tartara
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 3c1915df Michele Tartara
General Public License for more details.
20 3c1915df Michele Tartara
21 3c1915df Michele Tartara
You should have received a copy of the GNU General Public License
22 3c1915df Michele Tartara
along with this program; if not, write to the Free Software
23 3c1915df Michele Tartara
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 3c1915df Michele Tartara
02110-1301, USA.
25 3c1915df Michele Tartara
26 3c1915df Michele Tartara
-}
27 c5f6cba2 Helga Velroyen
module Ganeti.Storage.Drbd.Types
28 3c1915df Michele Tartara
  ( DRBDStatus(..)
29 3c1915df Michele Tartara
  , VersionInfo(..)
30 3c1915df Michele Tartara
  , DeviceInfo(..)
31 2188740e Michele Tartara
  , ConnState(..)
32 3c1915df Michele Tartara
  , LocalRemote(..)
33 3c1915df Michele Tartara
  , Role(..)
34 3c1915df Michele Tartara
  , DiskState(..)
35 2188740e Michele Tartara
  , PerfIndicators(..)
36 3c1915df Michele Tartara
  , SyncStatus(..)
37 3c1915df Michele Tartara
  , SizeUnit(..)
38 3c1915df Michele Tartara
  , Time(..)
39 3c1915df Michele Tartara
  , TimeUnit(..)
40 3c1915df Michele Tartara
  , AdditionalInfo(..)
41 eb62691c Michele Tartara
  , DrbdInstMinor(..)
42 3c1915df Michele Tartara
  ) where
43 3c1915df Michele Tartara
44 eb62691c Michele Tartara
import Control.Monad
45 2188740e Michele Tartara
import Text.JSON
46 2188740e Michele Tartara
import Text.Printf
47 2188740e Michele Tartara
48 2188740e Michele Tartara
import Ganeti.JSON
49 2188740e Michele Tartara
50 3c1915df Michele Tartara
--TODO: consider turning deviceInfos into an IntMap
51 3c1915df Michele Tartara
-- | Data type contaning all the data about the status of DRBD.
52 3c1915df Michele Tartara
data DRBDStatus =
53 3c1915df Michele Tartara
  DRBDStatus
54 3c1915df Michele Tartara
  { versionInfo :: VersionInfo  -- ^ Version information about DRBD
55 3c1915df Michele Tartara
  , deviceInfos :: [DeviceInfo] -- ^ Per-minor information
56 3c1915df Michele Tartara
  } deriving (Eq, Show)
57 3c1915df Michele Tartara
58 2188740e Michele Tartara
-- | The DRBDStatus instance of JSON.
59 2188740e Michele Tartara
instance JSON DRBDStatus where
60 2188740e Michele Tartara
  showJSON d = makeObj
61 2188740e Michele Tartara
    [ ("versionInfo", showJSON $ versionInfo d)
62 2188740e Michele Tartara
    , ("deviceInfos", showJSONs $ deviceInfos d)
63 2188740e Michele Tartara
    ]
64 2188740e Michele Tartara
65 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type DRBDStatus"
66 2188740e Michele Tartara
67 3c1915df Michele Tartara
-- | Data type describing the DRBD version.
68 3c1915df Michele Tartara
data VersionInfo =
69 3c1915df Michele Tartara
  VersionInfo
70 3c1915df Michele Tartara
  { version    :: Maybe String -- ^ DRBD driver version
71 3c1915df Michele Tartara
  , api        :: Maybe String -- ^ The api version
72 3c1915df Michele Tartara
  , proto      :: Maybe String -- ^ The protocol version
73 3c1915df Michele Tartara
  , srcversion :: Maybe String -- ^ The version of the source files
74 3c1915df Michele Tartara
  , gitHash    :: Maybe String -- ^ Git hash of the source files
75 3c1915df Michele Tartara
  , buildBy    :: Maybe String -- ^ Who built the binary (and,
76 3c1915df Michele Tartara
                               -- optionally, when)
77 3c1915df Michele Tartara
  } deriving (Eq, Show)
78 3c1915df Michele Tartara
79 2188740e Michele Tartara
-- | The VersionInfo instance of JSON.
80 2188740e Michele Tartara
instance JSON VersionInfo where
81 2188740e Michele Tartara
  showJSON (VersionInfo versionF apiF protoF srcversionF gitHashF buildByF) =
82 2188740e Michele Tartara
    optFieldsToObj
83 2188740e Michele Tartara
      [ optionalJSField "version" versionF
84 2188740e Michele Tartara
      , optionalJSField "api" apiF
85 2188740e Michele Tartara
      , optionalJSField "proto" protoF
86 2188740e Michele Tartara
      , optionalJSField "srcversion" srcversionF
87 2188740e Michele Tartara
      , optionalJSField "gitHash" gitHashF
88 2188740e Michele Tartara
      , optionalJSField "buildBy" buildByF
89 2188740e Michele Tartara
      ]
90 2188740e Michele Tartara
91 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type VersionInfo"
92 2188740e Michele Tartara
93 3c1915df Michele Tartara
-- | Data type describing a device.
94 3c1915df Michele Tartara
data DeviceInfo =
95 3c1915df Michele Tartara
  UnconfiguredDevice Int -- ^ An DRBD minor marked as unconfigured
96 3c1915df Michele Tartara
  | -- | A configured DRBD minor
97 3c1915df Michele Tartara
    DeviceInfo
98 eb62691c Michele Tartara
      { minorNumber :: Int                  -- ^ The minor index of the device
99 eb62691c Michele Tartara
      , connectionState :: ConnState        -- ^ State of the connection
100 eb62691c Michele Tartara
      , resourceRoles :: LocalRemote Role   -- ^ Roles of the resources
101 3c1915df Michele Tartara
      , diskStates :: LocalRemote DiskState -- ^ Status of the disks
102 eb62691c Michele Tartara
      , replicationProtocol :: Char         -- ^ The replication protocol
103 eb62691c Michele Tartara
                                            -- being used
104 eb62691c Michele Tartara
      , ioFlags :: String                   -- ^ The input/output flags
105 eb62691c Michele Tartara
      , perfIndicators :: PerfIndicators    -- ^ Performance indicators
106 eb62691c Michele Tartara
      , syncStatus :: Maybe SyncStatus      -- ^ The status of the
107 eb62691c Michele Tartara
                                            -- syncronization of the disk
108 eb62691c Michele Tartara
                                            -- (only if it is happening)
109 eb62691c Michele Tartara
      , resync :: Maybe AdditionalInfo      -- ^ Additional info by DRBD 8.0
110 eb62691c Michele Tartara
      , actLog :: Maybe AdditionalInfo      -- ^ Additional info by DRBD 8.0
111 eb62691c Michele Tartara
      , instName :: Maybe String            -- ^ The name of the associated
112 eb62691c Michele Tartara
                                            -- instance
113 3c1915df Michele Tartara
      } deriving (Eq, Show)
114 3c1915df Michele Tartara
115 2188740e Michele Tartara
-- | The DeviceInfo instance of JSON.
116 2188740e Michele Tartara
instance JSON DeviceInfo where
117 2188740e Michele Tartara
  showJSON (UnconfiguredDevice num) = makeObj
118 2188740e Michele Tartara
    [ ("minor", showJSON num)
119 2188740e Michele Tartara
    , ("connectionState", showJSON Unconfigured)
120 2188740e Michele Tartara
    ]
121 2188740e Michele Tartara
  showJSON (DeviceInfo minorNumberF connectionStateF (LocalRemote
122 2188740e Michele Tartara
    localRole remoteRole) (LocalRemote localState remoteState)
123 eb62691c Michele Tartara
    replicProtocolF ioFlagsF perfIndicatorsF syncStatusF _ _ instNameF) =
124 2188740e Michele Tartara
    optFieldsToObj
125 2188740e Michele Tartara
    [ Just ("minor", showJSON minorNumberF)
126 2188740e Michele Tartara
    , Just ("connectionState", showJSON connectionStateF)
127 2188740e Michele Tartara
    , Just ("localRole", showJSON localRole)
128 2188740e Michele Tartara
    , Just ("remoteRole", showJSON remoteRole)
129 2188740e Michele Tartara
    , Just ("localState", showJSON localState)
130 2188740e Michele Tartara
    , Just ("remoteState", showJSON remoteState)
131 2188740e Michele Tartara
    , Just ("replicationProtocol", showJSON replicProtocolF)
132 2188740e Michele Tartara
    , Just ("ioFlags", showJSON ioFlagsF)
133 2188740e Michele Tartara
    , Just ("perfIndicators", showJSON perfIndicatorsF)
134 2188740e Michele Tartara
    , optionalJSField "syncStatus" syncStatusF
135 eb62691c Michele Tartara
    , Just ("instance", maybe JSNull showJSON instNameF)
136 2188740e Michele Tartara
    ]
137 2188740e Michele Tartara
138 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type DeviceInfo"
139 2188740e Michele Tartara
140 3c1915df Michele Tartara
-- | Data type describing the state of the connection.
141 2188740e Michele Tartara
data ConnState
142 3c1915df Michele Tartara
  = StandAlone     -- ^  No network configuration available
143 3c1915df Michele Tartara
  | Disconnecting  -- ^ Temporary state during disconnection
144 3c1915df Michele Tartara
  | Unconnected    -- ^ Prior to a connection attempt
145 3c1915df Michele Tartara
  | Timeout        -- ^ Following a timeout in the communication
146 3c1915df Michele Tartara
  | BrokenPipe     -- ^ After the connection to the peer was lost
147 9572482e Michele Tartara
  | NetworkFailure -- ^ After the connection to the partner was lost
148 9572482e Michele Tartara
  | ProtocolError  -- ^ After the connection to the partner was lost
149 3c1915df Michele Tartara
  | TearDown       -- ^ The peer is closing the connection
150 3c1915df Michele Tartara
  | WFConnection   -- ^ Waiting for the peer to become visible
151 3c1915df Michele Tartara
  | WFReportParams -- ^ Waiting for first packet from peer
152 3c1915df Michele Tartara
  | Connected      -- ^ Connected, data mirroring active
153 3c1915df Michele Tartara
  | StartingSyncS  -- ^ Source of a full sync started by admin
154 3c1915df Michele Tartara
  | StartingSyncT  -- ^ Target of a full sync started by admin
155 3c1915df Michele Tartara
  | WFBitMapS      -- ^ Source of a just starting partial sync
156 3c1915df Michele Tartara
  | WFBitMapT      -- ^ Target of a just starting partial sync
157 3c1915df Michele Tartara
  | WFSyncUUID     -- ^ Synchronization is about to begin
158 3c1915df Michele Tartara
  | SyncSource     -- ^ Source of a running synchronization
159 3c1915df Michele Tartara
  | SyncTarget     -- ^ Target of a running synchronization
160 3c1915df Michele Tartara
  | PausedSyncS    -- ^ Source of a paused synchronization
161 3c1915df Michele Tartara
  | PausedSyncT    -- ^ Target of a paused synchronization
162 9572482e Michele Tartara
  | VerifyS        -- ^ Source of a running verification
163 9572482e Michele Tartara
  | VerifyT        -- ^ Target of a running verification
164 3c1915df Michele Tartara
  | Unconfigured   -- ^ The device is not configured
165 3c1915df Michele Tartara
    deriving (Show, Eq)
166 3c1915df Michele Tartara
167 2188740e Michele Tartara
-- | The ConnState instance of JSON.
168 2188740e Michele Tartara
instance JSON ConnState where
169 2188740e Michele Tartara
  showJSON = showJSON . show
170 2188740e Michele Tartara
171 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type ConnState"
172 2188740e Michele Tartara
173 3c1915df Michele Tartara
-- | Algebraic data type describing something that has a local and a remote
174 3c1915df Michele Tartara
-- value.
175 3c1915df Michele Tartara
data LocalRemote a =
176 3c1915df Michele Tartara
  LocalRemote
177 3c1915df Michele Tartara
  { local  :: a -- ^ The local value
178 3c1915df Michele Tartara
  , remote :: a -- ^ The remote value
179 3c1915df Michele Tartara
  } deriving (Eq, Show)
180 3c1915df Michele Tartara
181 3c1915df Michele Tartara
-- | Data type describing.
182 3c1915df Michele Tartara
data Role = Primary   -- ^ The device role is primary
183 3c1915df Michele Tartara
          | Secondary -- ^ The device role is secondary
184 3c1915df Michele Tartara
          | Unknown   -- ^ The device role is unknown
185 3c1915df Michele Tartara
            deriving (Eq, Show)
186 3c1915df Michele Tartara
187 2188740e Michele Tartara
-- | The Role instance of JSON.
188 2188740e Michele Tartara
instance JSON Role where
189 2188740e Michele Tartara
  showJSON = showJSON . show
190 2188740e Michele Tartara
191 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type Role"
192 2188740e Michele Tartara
193 3c1915df Michele Tartara
-- | Data type describing disk states.
194 3c1915df Michele Tartara
data DiskState
195 3c1915df Michele Tartara
  = Diskless     -- ^ No local block device assigned to the DRBD driver
196 3c1915df Michele Tartara
  | Attaching    -- ^ Reading meta data
197 3c1915df Michele Tartara
  | Failed       -- ^ I/O failure
198 3c1915df Michele Tartara
  | Negotiating  -- ^ "Attach" on an already-connected device
199 3c1915df Michele Tartara
  | Inconsistent -- ^ The data is inconsistent between nodes.
200 3c1915df Michele Tartara
  | Outdated     -- ^ Data consistent but outdated
201 3c1915df Michele Tartara
  | DUnknown     -- ^ No network connection available
202 3c1915df Michele Tartara
  | Consistent   -- ^ Consistent data, but without network connection
203 3c1915df Michele Tartara
  | UpToDate     -- ^ Consistent, up-to-date. This is the normal state
204 3c1915df Michele Tartara
    deriving (Eq, Show)
205 3c1915df Michele Tartara
206 2188740e Michele Tartara
-- | The DiskState instance of JSON.
207 2188740e Michele Tartara
instance JSON DiskState where
208 2188740e Michele Tartara
  showJSON = showJSON . show
209 2188740e Michele Tartara
210 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type DiskState"
211 2188740e Michele Tartara
212 3c1915df Michele Tartara
-- | Data type containing data about performance indicators.
213 2188740e Michele Tartara
data PerfIndicators = PerfIndicators
214 3c1915df Michele Tartara
  { networkSend :: Int -- ^ KiB of data sent on the network
215 3c1915df Michele Tartara
  , networkReceive :: Int -- ^ KiB of data received from the network
216 3c1915df Michele Tartara
  , diskWrite :: Int -- ^ KiB of data written on local disk
217 3c1915df Michele Tartara
  , diskRead :: Int -- ^ KiB of data read from local disk
218 3c1915df Michele Tartara
  , activityLog :: Int -- ^ Number of updates of the activity log
219 3c1915df Michele Tartara
  , bitMap :: Int -- ^ Number of updates to the bitmap area of the metadata
220 c816a371 Michele Tartara
  , localCount :: Int -- ^ Number of open requests to the local I/O subsystem
221 3c1915df Michele Tartara
  , pending :: Int -- ^ Num of requests sent to the partner but not yet answered
222 3c1915df Michele Tartara
  , unacknowledged :: Int -- ^ Num of requests received by the partner but still
223 3c1915df Michele Tartara
                        -- to be answered
224 3c1915df Michele Tartara
  , applicationPending :: Int -- ^ Num of block I/O requests forwarded
225 3c1915df Michele Tartara
                              -- to DRBD but that have not yet been
226 3c1915df Michele Tartara
                              -- answered
227 3c1915df Michele Tartara
  , epochs :: Maybe Int -- ^ Number of epoch objects
228 3c1915df Michele Tartara
  , writeOrder :: Maybe Char -- ^ Currently used write ordering method
229 3c1915df Michele Tartara
  , outOfSync :: Maybe Int -- ^ KiB of storage currently out of sync
230 3c1915df Michele Tartara
  } deriving (Eq, Show)
231 3c1915df Michele Tartara
232 2188740e Michele Tartara
-- | The PerfIndicators instance of JSON.
233 2188740e Michele Tartara
instance JSON PerfIndicators where
234 2188740e Michele Tartara
  showJSON p = optFieldsToObj
235 2188740e Michele Tartara
    [ Just ("networkSend", showJSON $ networkSend p)
236 2188740e Michele Tartara
    , Just ("networkReceive", showJSON $ networkReceive p)
237 2188740e Michele Tartara
    , Just ("diskWrite", showJSON $ diskWrite p)
238 2188740e Michele Tartara
    , Just ("diskRead", showJSON $ diskRead p)
239 2188740e Michele Tartara
    , Just ("activityLog", showJSON $ activityLog p)
240 2188740e Michele Tartara
    , Just ("bitMap", showJSON $ bitMap p)
241 2188740e Michele Tartara
    , Just ("localCount", showJSON $ localCount p)
242 2188740e Michele Tartara
    , Just ("pending", showJSON $ pending p)
243 2188740e Michele Tartara
    , Just ("unacknowledged", showJSON $ unacknowledged p)
244 2188740e Michele Tartara
    , Just ("applicationPending", showJSON $ applicationPending p)
245 2188740e Michele Tartara
    , optionalJSField "epochs" $ epochs p
246 2188740e Michele Tartara
    , optionalJSField "writeOrder" $ writeOrder p
247 2188740e Michele Tartara
    , optionalJSField "outOfSync" $ outOfSync p
248 2188740e Michele Tartara
    ]
249 2188740e Michele Tartara
250 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type PerfIndicators"
251 2188740e Michele Tartara
252 3c1915df Michele Tartara
-- | Data type containing data about the synchronization status of a device.
253 3c1915df Michele Tartara
data SyncStatus =
254 3c1915df Michele Tartara
  SyncStatus
255 3c1915df Michele Tartara
  { percentage      :: Double    -- ^ Percentage of syncronized data
256 9de303af Michele Tartara
  , partialSyncSize :: Int       -- ^ Numerator of the fraction of synced data
257 9de303af Michele Tartara
  , totalSyncSize   :: Int       -- ^ Denominator of the fraction of
258 3c1915df Michele Tartara
                                 -- synced data
259 3c1915df Michele Tartara
  , syncUnit        :: SizeUnit  -- ^ Measurement unit of the previous
260 3c1915df Michele Tartara
                                 -- fraction
261 3c1915df Michele Tartara
  , timeToFinish    :: Time      -- ^ Expected time before finishing
262 3c1915df Michele Tartara
                                 -- the syncronization
263 3c1915df Michele Tartara
  , speed           :: Int       -- ^ Speed of the syncronization
264 3c1915df Michele Tartara
  , want            :: Maybe Int -- ^ Want of the syncronization
265 3c1915df Michele Tartara
  , speedSizeUnit   :: SizeUnit  -- ^ Size unit of the speed
266 3c1915df Michele Tartara
  , speedTimeUnit   :: TimeUnit  -- ^ Time unit of the speed
267 3c1915df Michele Tartara
  } deriving (Eq, Show)
268 3c1915df Michele Tartara
269 2188740e Michele Tartara
-- | The SyncStatus instance of JSON.
270 2188740e Michele Tartara
instance JSON SyncStatus where
271 2188740e Michele Tartara
  showJSON s = optFieldsToObj
272 2188740e Michele Tartara
    [ Just ("percentage", showJSON $ percentage s)
273 2188740e Michele Tartara
    , Just ("progress", showJSON $ show (partialSyncSize s) ++ "/" ++
274 2188740e Michele Tartara
        show (totalSyncSize s))
275 2188740e Michele Tartara
    , Just ("progressUnit", showJSON $ syncUnit s)
276 2188740e Michele Tartara
    , Just ("timeToFinish", showJSON $ timeToFinish s)
277 2188740e Michele Tartara
    , Just ("speed", showJSON $ speed s)
278 2188740e Michele Tartara
    , optionalJSField "want" $ want s
279 2188740e Michele Tartara
    , Just ("speedUnit", showJSON $ show (speedSizeUnit s) ++ "/" ++
280 2188740e Michele Tartara
        show (speedTimeUnit s))
281 2188740e Michele Tartara
    ]
282 2188740e Michele Tartara
283 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type SyncStatus"
284 2188740e Michele Tartara
285 3c1915df Michele Tartara
-- | Data type describing a size unit for memory.
286 3c1915df Michele Tartara
data SizeUnit = KiloByte | MegaByte deriving (Eq, Show)
287 3c1915df Michele Tartara
288 2188740e Michele Tartara
-- | The SizeUnit instance of JSON.
289 2188740e Michele Tartara
instance JSON SizeUnit where
290 2188740e Michele Tartara
  showJSON = showJSON . show
291 2188740e Michele Tartara
292 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type SizeUnit"
293 2188740e Michele Tartara
294 3c1915df Michele Tartara
-- | Data type describing a time (hh:mm:ss).
295 3c1915df Michele Tartara
data Time = Time
296 2188740e Michele Tartara
  { hour :: Int
297 2188740e Michele Tartara
  , min  :: Int
298 2188740e Michele Tartara
  , sec  :: Int
299 3c1915df Michele Tartara
  } deriving (Eq, Show)
300 3c1915df Michele Tartara
301 2188740e Michele Tartara
-- | The Time instance of JSON.
302 2188740e Michele Tartara
instance JSON Time where
303 2188740e Michele Tartara
  showJSON (Time h m s) = showJSON (printf "%02d:%02d:%02d" h m s :: String)
304 2188740e Michele Tartara
305 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type Time"
306 2188740e Michele Tartara
307 3c1915df Michele Tartara
-- | Data type describing a time unit.
308 3c1915df Michele Tartara
data TimeUnit = Second deriving (Eq, Show)
309 3c1915df Michele Tartara
310 2188740e Michele Tartara
-- | The TimeUnit instance of JSON.
311 2188740e Michele Tartara
instance JSON TimeUnit where
312 2188740e Michele Tartara
  showJSON Second = showJSON "Second"
313 2188740e Michele Tartara
314 2188740e Michele Tartara
  readJSON = error "JSON read instance not implemented for type TimeUnit"
315 2188740e Michele Tartara
316 3c1915df Michele Tartara
-- | Additional device-specific cache-like information produced by
317 3c1915df Michele Tartara
-- drbd <= 8.0.
318 3c1915df Michele Tartara
--
319 3c1915df Michele Tartara
-- Internal debug information exported by old DRBD versions.
320 3c1915df Michele Tartara
-- Undocumented both in DRBD and here.
321 3c1915df Michele Tartara
data AdditionalInfo = AdditionalInfo
322 3c1915df Michele Tartara
  { partialUsed :: Int
323 3c1915df Michele Tartara
  , totalUsed   :: Int
324 3c1915df Michele Tartara
  , hits        :: Int
325 3c1915df Michele Tartara
  , misses      :: Int
326 3c1915df Michele Tartara
  , starving    :: Int
327 3c1915df Michele Tartara
  , dirty       :: Int
328 3c1915df Michele Tartara
  , changed     :: Int
329 3c1915df Michele Tartara
  } deriving (Eq, Show)
330 eb62691c Michele Tartara
331 eb62691c Michele Tartara
-- | Data type representing the pairing of a DRBD minor with an instance.
332 eb62691c Michele Tartara
data DrbdInstMinor = DrbdInstMinor
333 eb62691c Michele Tartara
  { dimNode :: String
334 eb62691c Michele Tartara
  , dimMinor :: Int
335 eb62691c Michele Tartara
  , dimInstName :: String
336 eb62691c Michele Tartara
  , dimDiskIdx :: String
337 eb62691c Michele Tartara
  , dimRole :: String
338 eb62691c Michele Tartara
  , dimPeer :: String
339 eb62691c Michele Tartara
  } deriving (Show)
340 eb62691c Michele Tartara
341 eb62691c Michele Tartara
-- | The DrbdInstMinor instance of JSON.
342 eb62691c Michele Tartara
instance JSON DrbdInstMinor where
343 eb62691c Michele Tartara
  showJSON (DrbdInstMinor a b c d e f) =
344 eb62691c Michele Tartara
    JSArray
345 eb62691c Michele Tartara
      [ showJSON a
346 eb62691c Michele Tartara
      , showJSON b
347 eb62691c Michele Tartara
      , showJSON c
348 eb62691c Michele Tartara
      , showJSON d
349 eb62691c Michele Tartara
      , showJSON e
350 eb62691c Michele Tartara
      , showJSON f
351 eb62691c Michele Tartara
      ]
352 eb62691c Michele Tartara
  readJSON (JSArray [a, b, c, d, e, f]) =
353 eb62691c Michele Tartara
    DrbdInstMinor
354 eb62691c Michele Tartara
      `fmap` readJSON a
355 eb62691c Michele Tartara
      `ap` readJSON b
356 eb62691c Michele Tartara
      `ap` readJSON c
357 eb62691c Michele Tartara
      `ap` readJSON d
358 eb62691c Michele Tartara
      `ap` readJSON e
359 eb62691c Michele Tartara
      `ap` readJSON f
360 eb62691c Michele Tartara
  readJSON _ = fail "Unable to read a DrbdInstMinor"