Revision 497beee2

b/htest/Test/Ganeti/Objects.hs
85 85

  
86 86
$(genArbitrary ''AdminState)
87 87

  
88
$(genArbitrary ''NICMode)
89

  
90 88
$(genArbitrary ''PartialNicParams)
91 89

  
92 90
$(genArbitrary ''PartialNic)
b/htest/Test/Ganeti/Types.hs
103 103

  
104 104
$(genArbitrary ''IAllocatorMode)
105 105

  
106
$(genArbitrary ''NICMode)
107

  
106 108
-- * Properties
107 109

  
108 110
prop_AllocPolicy_serialisation :: AllocPolicy -> Property
......
231 233
      all_hs_codes = sort $ map Types.iAllocatorModeToRaw [minBound..maxBound]
232 234
  assertEqual "for IAllocatorMode equivalence" all_py_codes all_hs_codes
233 235

  
236
-- | Test 'NICMode' serialisation.
237
prop_NICMode_serialisation :: NICMode -> Property
238
prop_NICMode_serialisation = testSerialisation
239

  
240
-- | Tests equivalence with Python, based on Constants.hs code.
241
case_NICMode_pyequiv :: Assertion
242
case_NICMode_pyequiv = do
243
  let all_py_codes = sort C.nicValidModes
244
      all_hs_codes = sort $ map Types.nICModeToRaw [minBound..maxBound]
245
  assertEqual "for NICMode equivalence" all_py_codes all_hs_codes
246

  
234 247
testSuite "Types"
235 248
  [ 'prop_AllocPolicy_serialisation
236 249
  , 'prop_DiskTemplate_serialisation
......
258 271
  , 'prop_IAllocatorTestDir_serialisation
259 272
  , 'prop_IAllocatorMode_serialisation
260 273
  , 'case_IAllocatorMode_pyequiv
274
  , 'prop_NICMode_serialisation
275
  , 'case_NICMode_pyequiv
261 276
  ]
b/htools/Ganeti/Objects.hs
33 33
  , vTypeFromRaw
34 34
  , HvParams
35 35
  , OsParams
36
  , NICMode(..)
37 36
  , PartialNicParams(..)
38 37
  , FilledNicParams(..)
39 38
  , fillNicParams
......
168 167

  
169 168
-- * NIC definitions
170 169

  
171
$(declareSADT "NICMode"
172
  [ ("NMBridged", 'C.nicModeBridged)
173
  , ("NMRouted",  'C.nicModeRouted)
174
  ])
175
$(makeJSONInstance ''NICMode)
176

  
177 170
$(buildParam "Nic" "nicp"
178 171
  [ simpleField "mode" [t| NICMode |]
179 172
  , simpleField "link" [t| String  |]
b/htools/Ganeti/Types.hs
67 67
  , IAllocatorTestDir(..)
68 68
  , IAllocatorMode(..)
69 69
  , iAllocatorModeToRaw
70
  , NICMode(..)
71
  , nICModeToRaw
70 72
  ) where
71 73

  
72 74
import qualified Text.JSON as JSON
......
314 316
  , ("IAllocatorChangeGroup", 'C.iallocatorModeChgGroup)
315 317
  ])
316 318
$(THH.makeJSONInstance ''IAllocatorMode)
319

  
320
-- | Netork mode.
321
$(THH.declareSADT "NICMode"
322
  [ ("NMBridged", 'C.nicModeBridged)
323
  , ("NMRouted",  'C.nicModeRouted)
324
  ])
325
$(THH.makeJSONInstance ''NICMode)

Also available in: Unified diff