Revision c324da14

b/src/Ganeti/HTools/Backend/IAlloc.hs
131 131
  let vm_capable' = fromMaybe True vm_capable
132 132
  gidx <- lookupGroup ktg n guuid
133 133
  node <- if offline || drained || not vm_capable'
134
            then return $ Node.create n 0 0 0 0 0 0 True 0 gidx
134
            then return $ Node.create n 0 0 0 0 0 0 True 0 gidx False
135 135
            else do
136 136
              mtotal <- extract "total_memory"
137 137
              mnode  <- extract "reserved_memory"
......
142 142
              ndparams <- extract "ndparams" >>= asJSObject
143 143
              spindles <- tryFromObj desc (fromJSObject ndparams)
144 144
                          "spindle_count"
145
              excl_stor <- tryFromObj desc (fromJSObject ndparams)
146
                           "exclusive_storage"
145 147
              return $ Node.create n mtotal mnode mfree
146
                     dtotal dfree ctotal False spindles gidx
148
                     dtotal dfree ctotal False spindles gidx excl_stor
147 149
  return (n, node)
148 150

  
149 151
-- | Parses a group as found in the cluster group list.
b/src/Ganeti/HTools/Backend/Luxi.hs
104 104
  L.Query (Qlang.ItemTypeOpCode Qlang.QRNode)
105 105
     ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree",
106 106
      "ctotal", "offline", "drained", "vm_capable",
107
      "ndp/spindle_count", "group.uuid", "tags"] Qlang.EmptyFilter
107
      "ndp/spindle_count", "group.uuid", "tags",
108
      "ndp/exclusive_storage"] Qlang.EmptyFilter
108 109

  
109 110
-- | The input data for instance query.
110 111
queryInstancesMsg :: L.LuxiOp
......
185 186
-- | Construct a node from a JSON object.
186 187
parseNode :: NameAssoc -> [(JSValue, JSValue)] -> Result (String, Node.Node)
187 188
parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree
188
              , ctotal, offline, drained, vm_capable, spindles, g_uuid 
189
              , tags ]
189
              , ctotal, offline, drained, vm_capable, spindles, g_uuid
190
              , tags, excl_stor ]
190 191
    = do
191 192
  xname <- annotateResult "Parsing new node" (fromJValWithStatus name)
192 193
  let convert a = genericConvert "Node" xname a
......
196 197
  xspindles <- convert "spindles" spindles
197 198
  xgdx   <- convert "group.uuid" g_uuid >>= lookupGroup ktg xname
198 199
  xtags <- convert "tags" tags
200
  xexcl_stor <- convert "exclusive_storage" excl_stor
199 201
  node <- if xoffline || xdrained || not xvm_capable
200
            then return $ Node.create xname 0 0 0 0 0 0 True xspindles xgdx
202
            then return $
203
              Node.create xname 0 0 0 0 0 0 True xspindles xgdx False
201 204
            else do
202 205
              xmtotal  <- convert "mtotal" mtotal
203 206
              xmnode   <- convert "mnode" mnode
......
207 210
              xctotal  <- convert "ctotal" ctotal
208 211
              return . flip Node.setNodeTags xtags $
209 212
                Node.create xname xmtotal xmnode xmfree xdtotal xdfree
210
                            xctotal False xspindles xgdx
213
                            xctotal False xspindles xgdx xexcl_stor
211 214
  return (xname, node)
212 215

  
213 216
parseNode _ v = fail ("Invalid node query result: " ++ show v)
b/src/Ganeti/HTools/Backend/Rapi.hs
155 155
  let vm_cap' = fromMaybe True vm_cap
156 156
  ndparams <- extract "ndparams" >>= asJSObject
157 157
  spindles <- tryFromObj desc (fromJSObject ndparams) "spindle_count"
158
  excl_stor <- tryFromObj desc (fromJSObject ndparams) "exclusive_storage"
158 159
  guuid   <- annotateResult desc $ maybeFromObj a "group.uuid"
159 160
  guuid' <-  lookupGroup ktg name (fromMaybe defaultGroupID guuid)
160 161
  node <- if offline || drained || not vm_cap'
161
            then return $ Node.create name 0 0 0 0 0 0 True 0 guuid'
162
            then return $ Node.create name 0 0 0 0 0 0 True 0 guuid' False
162 163
            else do
163 164
              mtotal  <- extract "mtotal"
164 165
              mnode   <- extract "mnode"
......
169 170
              tags    <- extract "tags"
170 171
              return . flip Node.setNodeTags tags $
171 172
                Node.create name mtotal mnode mfree dtotal dfree ctotal False
172
                            spindles guuid'
173
                            spindles guuid' excl_stor
173 174
  return (name, node)
174 175

  
175 176
-- | Construct a group from a JSON object.
b/src/Ganeti/HTools/Backend/Simu.hs
6 6

  
7 7
{-
8 8

  
9
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
9
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
10 10

  
11 11
This program is free software; you can redistribute it and/or modify
12 12
it under the terms of the GNU General Public License as published by
......
51 51

  
52 52
-- | Parse the string description into nodes.
53 53
parseDesc :: String -> [String]
54
          -> Result (AllocPolicy, Int, Int, Int, Int, Int)
55
parseDesc _ [a, n, d, m, c, s] = do
54
          -> Result (AllocPolicy, Int, Int, Int, Int, Int, Bool)
55
parseDesc _ [a, n, d, m, c, s, exstor] = do
56 56
  apol <- allocPolicyFromRaw a `mplus` apolAbbrev a
57 57
  ncount <- tryRead "node count" n
58 58
  disk <- annotateResult "disk size" (parseUnit d)
59 59
  mem <- annotateResult "memory size" (parseUnit m)
60 60
  cpu <- tryRead "cpu count" c
61 61
  spindles <- tryRead "spindles" s
62
  return (apol, ncount, disk, mem, cpu, spindles)
62
  excl_stor <- tryRead "exclusive storage" exstor
63
  return (apol, ncount, disk, mem, cpu, spindles, excl_stor)
63 64

  
64 65
parseDesc desc [a, n, d, m, c] = parseDesc desc [a, n, d, m, c, "1"]
65 66

  
67
parseDesc desc [a, n, d, m, c, s] = parseDesc desc [a, n, d, m, c, s, "False"]
68

  
66 69
parseDesc desc es =
67 70
  fail $ printf
68 71
         "Invalid cluster specification, expected 6 comma-separated\
......
75 78
            -> String -- ^ The group specification
76 79
            -> Result (Group.Group, [Node.Node])
77 80
createGroup grpIndex spec = do
78
  (apol, ncount, disk, mem, cpu, spindles) <- parseDesc spec $
79
                                              sepSplit ',' spec
81
  (apol, ncount, disk, mem, cpu, spindles, excl_stor) <- parseDesc spec $
82
                                                         sepSplit ',' spec
80 83
  let nodes = map (\idx ->
81 84
                    flip Node.setMaster (grpIndex == 1 && idx == 1) $
82 85
                    Node.create (printf "node-%02d-%03d" grpIndex idx)
83 86
                      (fromIntegral mem) 0 mem
84 87
                      (fromIntegral disk) disk
85
                      (fromIntegral cpu) False spindles grpIndex
88
                      (fromIntegral cpu) False spindles grpIndex excl_stor
86 89
                  ) [1..ncount]
87 90
      -- TODO: parse networks to which this group is connected
88 91
      grp = Group.create (printf "group-%02d" grpIndex)
b/src/Ganeti/HTools/Backend/Text.hs
84 84
              -> Node.Node  -- ^ The node to be serialised
85 85
              -> String
86 86
serializeNode gl node =
87
  printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s|%d|%s" (Node.name node)
87
  printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s|%d|%s|%s" (Node.name node)
88 88
           (Node.tMem node) (Node.nMem node) (Node.fMem node)
89 89
           (Node.tDsk node) (Node.fDsk node) (Node.tCpu node)
90 90
           (if Node.offline node then 'Y' else
......
92 92
           (Group.uuid grp)
93 93
           (Node.spindleCount node)
94 94
           (intercalate "," (Node.nTags node))
95
           (if Node.exclStorage node then "Y" else "N")
95 96
    where grp = Container.find (Node.group node) gl
96 97

  
97 98
-- | Generate node file data from node objects.
......
199 200
         -> [String]              -- ^ Input data as a list of fields
200 201
         -> m (String, Node.Node) -- ^ The result, a tuple o node name
201 202
                                  -- and node object
202
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags] = do
203
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
204
              excl_stor] = do
203 205
  gdx <- lookupGroup ktg name gu
204 206
  new_node <-
205 207
      if "?" `elem` [tm,nm,fm,td,fd,tc] || fo == "Y" then
206
          return $ Node.create name 0 0 0 0 0 0 True 0 gdx
208
          return $ Node.create name 0 0 0 0 0 0 True 0 gdx False
207 209
      else do
208 210
        let vtags = commaSplit tags
209 211
        vtm <- tryRead name tm
......
213 215
        vfd <- tryRead name fd
214 216
        vtc <- tryRead name tc
215 217
        vspindles <- tryRead name spindles
218
        vexcl_stor <- case excl_stor of
219
                        "Y" -> return True
220
                        "N" -> return False
221
                        _ -> fail $
222
                             "Invalid exclusive_storage value for node '" ++
223
                             name ++ "': " ++ excl_stor
216 224
        return . flip Node.setMaster (fo == "M") . flip Node.setNodeTags vtags $
217 225
          Node.create name vtm vnm vfm vtd vfd vtc False vspindles gdx
226
          vexcl_stor
218 227
  return (name, new_node)
219 228

  
220 229
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] =
......
223 232
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles] =
224 233
  loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, ""]
225 234

  
235
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags] =
236
  loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags, "N"]
237

  
226 238
loadNode _ s = fail $ "Invalid/incomplete node data: '" ++ show s ++ "'"
227 239

  
228 240
-- | Load an instance from a field list.
b/src/Ganeti/HTools/Node.hs
141 141
  , pTags    :: TagMap    -- ^ Primary instance exclusion tags and their count
142 142
  , group    :: T.Gdx     -- ^ The node's group (index)
143 143
  , iPolicy  :: T.IPolicy -- ^ The instance policy (of the node's group)
144
  , exclStorage :: Bool   -- ^ Effective value of exclusive_storage
144 145
  } deriving (Show, Eq)
145 146

  
146 147
instance T.Element Node where
......
216 217
-- The index and the peers maps are empty, and will be need to be
217 218
-- update later via the 'setIdx' and 'buildPeers' functions.
218 219
create :: String -> Double -> Int -> Int -> Double
219
       -> Int -> Double -> Bool -> Int -> T.Gdx -> Node
220
       -> Int -> Double -> Bool -> Int -> T.Gdx -> Bool -> Node
220 221
create name_init mem_t_init mem_n_init mem_f_init
221 222
       dsk_t_init dsk_f_init cpu_t_init offline_init spindles_init
222
       group_init =
223
       group_init excl_stor =
223 224
  Node { name = name_init
224 225
       , alias = name_init
225 226
       , tMem = mem_t_init
......
255 256
       , pTags = Map.empty
256 257
       , group = group_init
257 258
       , iPolicy = T.defIPolicy
259
       , exclStorage = excl_stor
258 260
       }
259 261

  
260 262
-- | Conversion formula from mDsk\/tDsk to loDsk.
b/test/data/htools/hail-alloc-drbd.json
414 414
      "free_memory": 31389,
415 415
      "ndparams": {
416 416
        "spindle_count": 1,
417
        "oob_program": null
417
        "oob_program": null,
418
        "exclusive_storage": false
418 419
      },
419 420
      "reserved_memory": 1017,
420 421
      "master_capable": true,
......
437 438
      "free_memory": 31746,
438 439
      "ndparams": {
439 440
        "spindle_count": 1,
440
        "oob_program": null
441
        "oob_program": null,
442
        "exclusive_storage": false
441 443
      },
442 444
      "reserved_memory": 1017,
443 445
      "master_capable": true,
......
460 462
      "free_memory": 31234,
461 463
      "ndparams": {
462 464
        "spindle_count": 1,
463
        "oob_program": null
465
        "oob_program": null,
466
        "exclusive_storage": false
464 467
      },
465 468
      "reserved_memory": 1017,
466 469
      "master_capable": true,
......
483 486
      "free_memory": 22914,
484 487
      "ndparams": {
485 488
        "spindle_count": 1,
486
        "oob_program": null
489
        "oob_program": null,
490
        "exclusive_storage": false
487 491
      },
488 492
      "reserved_memory": 1017,
489 493
      "master_capable": true,
b/test/data/htools/hail-alloc-invalid-network.json
100 100
      "free_memory": 4096,
101 101
      "group": "uuid-group-1",
102 102
      "ndparams": {
103
        "spindle_count": 1
103
        "spindle_count": 1,
104
        "exclusive_storage": false
104 105
      },
105 106
      "offline": false,
106 107
      "reserved_memory": 1017,
......
114 115
      "free_memory": 4096,
115 116
      "group": "uuid-group-2",
116 117
      "ndparams": {
117
        "spindle_count": 1
118
        "spindle_count": 1,
119
        "exclusive_storage": false
118 120
      },
119 121
      "offline": false,
120 122
      "reserved_memory": 1017,
b/test/data/htools/hail-alloc-invalid-twodisks.json
59 59
      "free_memory": 31389,
60 60
      "group": "uuid-group-1",
61 61
      "ndparams": {
62
        "spindle_count": 1
62
        "spindle_count": 1,
63
        "exclusive_storage": false
63 64
      },
64 65
      "offline": false,
65 66
      "reserved_memory": 1017,
b/test/data/htools/hail-alloc-restricted-network.json
191 191
      "free_memory": 3840,
192 192
      "group": "uuid-group-1",
193 193
      "ndparams": {
194
        "spindle_count": 1
194
        "spindle_count": 1,
195
        "exclusive_storage": false
195 196
      },
196 197
      "offline": false,
197 198
      "reserved_memory": 1017,
......
205 206
      "free_memory": 3968,
206 207
      "group": "uuid-group-1",
207 208
      "ndparams": {
208
        "spindle_count": 1
209
        "spindle_count": 1,
210
        "exclusive_storage": false
209 211
      },
210 212
      "offline": false,
211 213
      "reserved_memory": 1017,
......
219 221
      "free_memory": 4096,
220 222
      "group": "uuid-group-2",
221 223
      "ndparams": {
222
        "spindle_count": 1
224
        "spindle_count": 1,
225
        "exclusive_storage": false
223 226
      },
224 227
      "offline": false,
225 228
      "reserved_memory": 1017,
......
233 236
      "free_memory": 4096,
234 237
      "group": "uuid-group-2",
235 238
      "ndparams": {
236
        "spindle_count": 1
239
        "spindle_count": 1,
240
        "exclusive_storage": false
237 241
      },
238 242
      "offline": false,
239 243
      "reserved_memory": 1017,
b/test/data/htools/hail-alloc-twodisks.json
59 59
      "free_memory": 31389,
60 60
      "group": "uuid-group-1",
61 61
      "ndparams": {
62
        "spindle_count": 1
62
        "spindle_count": 1,
63
        "exclusive_storage": false
63 64
      },
64 65
      "offline": false,
65 66
      "reserved_memory": 1017,
b/test/data/htools/hail-change-group.json
461 461
      "free_memory": 31389,
462 462
      "ndparams": {
463 463
        "spindle_count": 1,
464
        "oob_program": null
464
        "oob_program": null,
465
        "exclusive_storage": false
465 466
      },
466 467
      "reserved_memory": 1017,
467 468
      "master_capable": true,
......
484 485
      "free_memory": 31234,
485 486
      "ndparams": {
486 487
        "spindle_count": 1,
487
        "oob_program": null
488
        "oob_program": null,
489
        "exclusive_storage": false
488 490
      },
489 491
      "reserved_memory": 1017,
490 492
      "master_capable": true,
......
507 509
      "free_memory": 22914,
508 510
      "ndparams": {
509 511
        "spindle_count": 1,
510
        "oob_program": null
512
        "oob_program": null,
513
        "exclusive_storage": false
511 514
      },
512 515
      "reserved_memory": 1017,
513 516
      "master_capable": true,
......
530 533
      "free_memory": 31746,
531 534
      "ndparams": {
532 535
        "spindle_count": 1,
533
        "oob_program": null
536
        "oob_program": null,
537
        "exclusive_storage": false
534 538
      },
535 539
      "reserved_memory": 1017,
536 540
      "master_capable": true,
......
553 557
      "free_memory": 31746,
554 558
      "ndparams": {
555 559
        "spindle_count": 1,
556
        "oob_program": null
560
        "oob_program": null,
561
        "exclusive_storage": false
557 562
      },
558 563
      "reserved_memory": 1017,
559 564
      "master_capable": true,
b/test/data/htools/hail-node-evac.json
410 410
      "free_memory": 31389,
411 411
      "ndparams": {
412 412
        "spindle_count": 1,
413
        "oob_program": null
413
        "oob_program": null,
414
        "exclusive_storage": false
414 415
      },
415 416
      "reserved_memory": 1017,
416 417
      "master_capable": true,
......
433 434
      "free_memory": 31746,
434 435
      "ndparams": {
435 436
        "spindle_count": 1,
436
        "oob_program": null
437
        "oob_program": null,
438
        "exclusive_storage": false
437 439
      },
438 440
      "reserved_memory": 1017,
439 441
      "master_capable": true,
......
456 458
      "free_memory": 31234,
457 459
      "ndparams": {
458 460
        "spindle_count": 1,
459
        "oob_program": null
461
        "oob_program": null,
462
        "exclusive_storage": false
460 463
      },
461 464
      "reserved_memory": 1017,
462 465
      "master_capable": true,
......
479 482
      "free_memory": 22914,
480 483
      "ndparams": {
481 484
        "spindle_count": 1,
482
        "oob_program": null
485
        "oob_program": null,
486
        "exclusive_storage": false
483 487
      },
484 488
      "reserved_memory": 1017,
485 489
      "master_capable": true,
b/test/data/htools/hail-reloc-drbd.json
414 414
      "free_memory": 31389,
415 415
      "ndparams": {
416 416
        "spindle_count": 1,
417
        "oob_program": null
417
        "oob_program": null,
418
        "exclusive_storage": false
418 419
      },
419 420
      "reserved_memory": 1017,
420 421
      "master_capable": true,
......
437 438
      "free_memory": 31746,
438 439
      "ndparams": {
439 440
        "spindle_count": 1,
440
        "oob_program": null
441
        "oob_program": null,
442
        "exclusive_storage": false
441 443
      },
442 444
      "reserved_memory": 1017,
443 445
      "master_capable": true,
......
460 462
      "free_memory": 31234,
461 463
      "ndparams": {
462 464
        "spindle_count": 1,
463
        "oob_program": null
465
        "oob_program": null,
466
        "exclusive_storage": false
464 467
      },
465 468
      "reserved_memory": 1017,
466 469
      "master_capable": true,
......
483 486
      "free_memory": 22914,
484 487
      "ndparams": {
485 488
        "spindle_count": 1,
486
        "oob_program": null
489
        "oob_program": null,
490
        "exclusive_storage": false
487 491
      },
488 492
      "reserved_memory": 1017,
489 493
      "master_capable": true,
b/test/data/htools/rapi/nodes.json
29 29
    "vm_capable": true,
30 30
    "ndparams": {
31 31
      "spindle_count": 1,
32
      "oob_program": null
32
      "oob_program": null,
33
      "exclusive_storage": false
33 34
    }
34 35
  },
35 36
  {
......
62 63
    "vm_capable": true,
63 64
    "ndparams": {
64 65
      "spindle_count": 1,
65
      "oob_program": null
66
      "oob_program": null,
67
      "exclusive_storage": false
66 68
    }
67 69
  },
68 70
  {
......
103 105
    ],
104 106
    "ndparams": {
105 107
      "spindle_count": 1,
106
      "oob_program": null
108
      "oob_program": null,
109
      "exclusive_storage": false
107 110
    }
108 111
  },
109 112
  {
......
150 153
    ],
151 154
    "ndparams": {
152 155
      "spindle_count": 1,
153
      "oob_program": null
156
      "oob_program": null,
157
      "exclusive_storage": false
154 158
    }
155 159
  }
156 160
]
b/test/hs/Test/Ganeti/HTools/Node.hs
7 7

  
8 8
{-
9 9

  
10
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
10
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
11 11

  
12 12
This program is free software; you can redistribute it and/or modify
13 13
it under the terms of the GNU General Public License as published by
......
90 90
  cpu_t <- choose (base_cpu, top_cpu)
91 91
  offl  <- arbitrary
92 92
  let n = Node.create name (fromIntegral mem_t) mem_n mem_f
93
          (fromIntegral dsk_t) dsk_f (fromIntegral cpu_t) offl 1 0
93
          (fromIntegral dsk_t) dsk_f (fromIntegral cpu_t) offl 1 0 False
94 94
      n' = Node.setPolicy nullIPolicy n
95 95
  return $ Node.buildPeers n' Container.empty
96 96

  

Also available in: Unified diff