Revision eb62691c src/Ganeti/Block/Drbd/Types.hs

b/src/Ganeti/Block/Drbd/Types.hs
38 38
  , Time(..)
39 39
  , TimeUnit(..)
40 40
  , AdditionalInfo(..)
41
  , DrbdInstMinor(..)
41 42
  ) where
42 43

  
44
import Control.Monad
43 45
import Text.JSON
44 46
import Text.Printf
45 47

  
......
93 95
  UnconfiguredDevice Int -- ^ An DRBD minor marked as unconfigured
94 96
  | -- | A configured DRBD minor
95 97
    DeviceInfo
96
      { minorNumber :: Int -- ^ The minor index of the device
97
      , connectionState :: ConnState -- ^ State of the connection
98
      , resourceRoles :: LocalRemote Role -- ^ Roles of the resources
98
      { minorNumber :: Int                  -- ^ The minor index of the device
99
      , connectionState :: ConnState        -- ^ State of the connection
100
      , resourceRoles :: LocalRemote Role   -- ^ Roles of the resources
99 101
      , diskStates :: LocalRemote DiskState -- ^ Status of the disks
100
      , replicationProtocol :: Char -- ^ The replication protocol being used
101
      , ioFlags :: String -- ^ The input/output flags
102
      , perfIndicators
103
          :: PerfIndicators -- ^ Performance indicators
104
      , syncStatus :: Maybe SyncStatus -- ^ The status of the syncronization of
105
                                       -- the disk (only if it is happening)
106
      , resync :: Maybe AdditionalInfo -- ^ Additional info by DRBD 8.0
107
      , actLog :: Maybe AdditionalInfo -- ^ Additional info by DRBD 8.0
102
      , replicationProtocol :: Char         -- ^ The replication protocol
103
                                            -- being used
104
      , ioFlags :: String                   -- ^ The input/output flags
105
      , perfIndicators :: PerfIndicators    -- ^ Performance indicators
106
      , syncStatus :: Maybe SyncStatus      -- ^ The status of the
107
                                            -- syncronization of the disk
108
                                            -- (only if it is happening)
109
      , resync :: Maybe AdditionalInfo      -- ^ Additional info by DRBD 8.0
110
      , actLog :: Maybe AdditionalInfo      -- ^ Additional info by DRBD 8.0
111
      , instName :: Maybe String            -- ^ The name of the associated
112
                                            -- instance
108 113
      } deriving (Eq, Show)
109 114

  
110 115
-- | The DeviceInfo instance of JSON.
......
115 120
    ]
116 121
  showJSON (DeviceInfo minorNumberF connectionStateF (LocalRemote
117 122
    localRole remoteRole) (LocalRemote localState remoteState)
118
    replicProtocolF ioFlagsF perfIndicatorsF syncStatusF _ _) =
123
    replicProtocolF ioFlagsF perfIndicatorsF syncStatusF _ _ instNameF) =
119 124
    optFieldsToObj
120 125
    [ Just ("minor", showJSON minorNumberF)
121 126
    , Just ("connectionState", showJSON connectionStateF)
......
127 132
    , Just ("ioFlags", showJSON ioFlagsF)
128 133
    , Just ("perfIndicators", showJSON perfIndicatorsF)
129 134
    , optionalJSField "syncStatus" syncStatusF
135
    , Just ("instance", maybe JSNull showJSON instNameF)
130 136
    ]
131 137

  
132 138
  readJSON = error "JSON read instance not implemented for type DeviceInfo"
......
321 327
  , dirty       :: Int
322 328
  , changed     :: Int
323 329
  } deriving (Eq, Show)
330

  
331
-- | Data type representing the pairing of a DRBD minor with an instance.
332
data DrbdInstMinor = DrbdInstMinor
333
  { dimNode :: String
334
  , dimMinor :: Int
335
  , dimInstName :: String
336
  , dimDiskIdx :: String
337
  , dimRole :: String
338
  , dimPeer :: String
339
  } deriving (Show)
340

  
341
-- | The DrbdInstMinor instance of JSON.
342
instance JSON DrbdInstMinor where
343
  showJSON (DrbdInstMinor a b c d e f) =
344
    JSArray
345
      [ showJSON a
346
      , showJSON b
347
      , showJSON c
348
      , showJSON d
349
      , showJSON e
350
      , showJSON f
351
      ]
352
  readJSON (JSArray [a, b, c, d, e, f]) =
353
    DrbdInstMinor
354
      `fmap` readJSON a
355
      `ap` readJSON b
356
      `ap` readJSON c
357
      `ap` readJSON d
358
      `ap` readJSON e
359
      `ap` readJSON f
360
  readJSON _ = fail "Unable to read a DrbdInstMinor"

Also available in: Unified diff