Revision d752eb39
b/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
51 | 51 |
parseBaseInstance n a = do |
52 | 52 |
disk <- fromObj "disk_space_total" a |
53 | 53 |
mem <- fromObj "memory" a |
54 |
vcpus <- fromObj "vcpus" a |
|
54 | 55 |
let running = "running" |
55 |
return $ (n, Instance.create n mem disk running 0 0) |
|
56 |
return $ (n, Instance.create n mem disk vcpus running 0 0)
|
|
56 | 57 |
|
57 | 58 |
-- | Parses an instance as found in the cluster instance list. |
58 | 59 |
parseInstance :: NameAssoc -- ^ The node name-to-index association list |
b/Ganeti/HTools/Instance.hs | ||
---|---|---|
37 | 37 |
data Instance = Instance { name :: String -- ^ The instance name |
38 | 38 |
, mem :: Int -- ^ Memory of the instance |
39 | 39 |
, dsk :: Int -- ^ Disk size of instance |
40 |
, vcpus :: Int -- ^ Number of VCPUs |
|
40 | 41 |
, running :: Bool -- ^ Whether the instance |
41 | 42 |
-- is running |
42 | 43 |
, run_st :: String -- ^ Original (text) run status |
... | ... | |
64 | 65 |
-- |
65 | 66 |
-- Some parameters are not initialized by function, and must be set |
66 | 67 |
-- later (via 'setIdx' for example). |
67 |
create :: String -> Int -> Int -> String -> T.Ndx -> T.Ndx -> Instance |
|
68 |
create name_init mem_init dsk_init run_init pn sn = |
|
68 |
create :: String -> Int -> Int -> Int -> String -> T.Ndx -> T.Ndx -> Instance
|
|
69 |
create name_init mem_init dsk_init vcpus_init run_init pn sn =
|
|
69 | 70 |
Instance { |
70 | 71 |
name = name_init, |
71 | 72 |
mem = mem_init, |
72 | 73 |
dsk = dsk_init, |
74 |
vcpus = vcpus_init, |
|
73 | 75 |
running = case run_init of |
74 | 76 |
"running" -> True |
75 | 77 |
"ERROR_up" -> True |
b/Ganeti/HTools/Rapi.hs | ||
---|---|---|
82 | 82 |
name <- fromObj "name" a |
83 | 83 |
disk <- fromObj "disk_usage" a |
84 | 84 |
mem <- fromObj "beparams" a >>= fromObj "memory" |
85 |
vcpus <- fromObj "beparams" a >>= fromObj "vcpus" |
|
85 | 86 |
pnode <- fromObj "pnode" a >>= lookupNode ktn name |
86 | 87 |
snodes <- fromObj "snodes" a |
87 | 88 |
snode <- (if null snodes then return Node.noSecondary |
88 | 89 |
else readEitherString (head snodes) >>= lookupNode ktn name) |
89 | 90 |
running <- fromObj "status" a |
90 |
let inst = Instance.create name mem disk running pnode snode |
|
91 |
let inst = Instance.create name mem disk vcpus running pnode snode
|
|
91 | 92 |
return (name, inst) |
92 | 93 |
|
93 | 94 |
-- | Construct a node from a JSON object. |
b/Ganeti/HTools/Text.hs | ||
---|---|---|
66 | 66 |
-- | Load an instance from a field list. |
67 | 67 |
loadInst :: (Monad m) => |
68 | 68 |
[(String, Ndx)] -> [String] -> m (String, Instance.Instance) |
69 |
loadInst ktn (name:mem:dsk:status:pnode:snode:[]) = do |
|
69 |
loadInst ktn (name:mem:dsk:vcpus:status:pnode:snode:[]) = do
|
|
70 | 70 |
pidx <- lookupNode ktn name pnode |
71 | 71 |
sidx <- (if null snode then return Node.noSecondary |
72 | 72 |
else lookupNode ktn name snode) |
73 | 73 |
vmem <- tryRead name mem |
74 | 74 |
vdsk <- tryRead name dsk |
75 |
vvcpus <- tryRead name vcpus |
|
75 | 76 |
when (sidx == pidx) $ fail $ "Instance " ++ name ++ |
76 | 77 |
" has same primary and secondary node - " ++ pnode |
77 |
let newinst = Instance.create name vmem vdsk status pidx sidx |
|
78 |
let newinst = Instance.create name vmem vdsk vvcpus status pidx sidx
|
|
78 | 79 |
return (name, newinst) |
79 | 80 |
loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ (show s) ++ "'" |
80 | 81 |
|
b/README | ||
---|---|---|
86 | 86 |
|
87 | 87 |
gnt-node list -oname,mtotal,mnode,mfree,dtotal,dfree,offline \ |
88 | 88 |
--separator '|' --no-headers > nodes |
89 |
gnt-instance list -oname,be/memory,sda_size,status,pnode,snodes \ |
|
89 |
gnt-instance list -oname,be/memory,sda_size,be/vcpus,status,pnode,snodes \
|
|
90 | 90 |
--separator '|' --no-head > instances |
91 | 91 |
|
92 | 92 |
These two files should be saved under the names of *nodes* and |
b/hspace.hs | ||
---|---|---|
56 | 56 |
, optOffline :: [String] -- ^ Names of offline nodes |
57 | 57 |
, optIMem :: Int -- ^ Instance memory |
58 | 58 |
, optIDsk :: Int -- ^ Instance disk |
59 |
, optIVCPUs :: Int -- ^ Instance VCPUs |
|
59 | 60 |
, optINodes :: Int -- ^ Nodes required for an instance |
60 | 61 |
, optShowVer :: Bool -- ^ Just show the program version |
61 | 62 |
, optShowHelp :: Bool -- ^ Just show the help |
... | ... | |
86 | 87 |
, optOffline = [] |
87 | 88 |
, optIMem = 4096 |
88 | 89 |
, optIDsk = 102400 |
90 |
, optIVCPUs = 1 |
|
89 | 91 |
, optINodes = 2 |
90 | 92 |
, optShowVer = False |
91 | 93 |
, optShowHelp = False |
... | ... | |
121 | 123 |
, Option [] ["disk"] |
122 | 124 |
(ReqArg (\ d opts -> opts { optIDsk = read d }) "DISK") |
123 | 125 |
"disk size for instances" |
126 |
, Option [] ["vcpus"] |
|
127 |
(ReqArg (\ p opts -> opts { optIVCPUs = read p }) "NUM") |
|
128 |
"number of virtual cpus for instances" |
|
124 | 129 |
, Option [] ["req-nodes"] |
125 | 130 |
(ReqArg (\ n opts -> opts { optINodes = read n }) "NODES") |
126 | 131 |
"number of nodes for the new instances (1=plain, 2=mirrored)" |
... | ... | |
236 | 241 |
|
237 | 242 |
let nmlen = Container.maxNameLen nl |
238 | 243 |
newinst = Instance.create "new" (optIMem opts) (optIDsk opts) |
239 |
"ADMIN_down" (-1) (-1) |
|
244 |
(optIVCPUs opts) "ADMIN_down" (-1) (-1)
|
|
240 | 245 |
|
241 | 246 |
let (fin_nl, ixes) = iterateDepth nl il newinst req_nodes [] |
242 | 247 |
allocs = length ixes |
Also available in: Unified diff