Commit 04be800a authored by Iustin Pop's avatar Iustin Pop
Browse files

Add node memory field to Node objects

This patch adds a new n_mem field to the node objects, and implements
read/save/show support for it. The field is not currently used (except
in the node list) but will be used for checking data consistency and
instance up/down status.
parent 47a8bade
......@@ -642,8 +642,8 @@ printNodes ktn nl =
snl' = map (\ n -> ((fromJust $ lookup (Node.idx n) ktn), n)) snl
m_name = maximum . (map length) . fst . unzip $ snl'
helper = Node.list m_name
header = printf "%2s %-*s %5s %5s %5s %5s %5s %3s %3s %7s %7s"
" F" m_name "Name" "t_mem" "f_mem" "r_mem"
header = printf "%2s %-*s %5s %5s %5s %5s %5s %5s %3s %3s %7s %7s"
" F" m_name "Name" "t_mem" "n_mem" "f_mem" "r_mem"
"t_dsk" "f_dsk"
"pri" "sec" "p_fmem" "p_fdsk"
in unlines $ (header:map (uncurry helper) snl')
......@@ -750,11 +750,12 @@ loadData :: String -- ^ Node data in text format
String, NameList, NameList)
loadData ndata idata =
let
{- node file: name t_mem f_mem t_disk f_disk -}
{- node file: name t_mem n_mem f_mem t_disk f_disk -}
(ktn, nl) = loadTabular ndata
(\ (name:tm:fm:td:fd:[]) ->
(\ (name:tm:nm:fm:td:fd:[]) ->
(name,
Node.create (read tm) (read fm) (read td) (read fd)))
Node.create (read tm) (read nm)
(read fm) (read td) (read fd)))
Node.setIdx
{- instance file: name mem disk pnode snode -}
(kti, il) = loadTabular idata
......
......@@ -6,7 +6,8 @@
module Ganeti.HTools.Node
(
Node(failN1, idx, t_mem, f_mem, t_dsk, f_dsk, p_mem, p_dsk, p_rem,
Node(failN1, idx, t_mem, n_mem, f_mem, t_dsk, f_dsk,
p_mem, p_dsk, p_rem,
plist, slist, offline)
-- * Constructor
, create
......@@ -34,7 +35,8 @@ import qualified Ganeti.HTools.PeerMap as PeerMap
import Ganeti.HTools.Utils
data Node = Node { t_mem :: Double -- ^ total memory (Mib)
data Node = Node { t_mem :: Double -- ^ total memory (MiB)
, n_mem :: Int -- ^ node memory (MiB)
, f_mem :: Int -- ^ free memory (MiB)
, t_dsk :: Double -- ^ total disk space (MiB)
, f_dsk :: Int -- ^ free disk space (MiB)
......@@ -59,11 +61,12 @@ The index and the peers maps are empty, and will be need to be update
later via the 'setIdx' and 'buildPeers' functions.
-}
create :: Double -> Int -> Double -> Int -> Node
create mem_t_init mem_f_init dsk_t_init dsk_f_init =
create :: Double -> Int -> Int -> Double -> Int -> Node
create mem_t_init mem_n_init mem_f_init dsk_t_init dsk_f_init =
Node
{
t_mem = mem_t_init,
n_mem = mem_n_init,
f_mem = mem_f_init,
t_dsk = dsk_t_init,
f_dsk = dsk_f_init,
......@@ -217,9 +220,9 @@ list mname n t =
off = offline t
fn = failN1 t
in
printf " %c %-*s %5.0f %5d %5d %5.0f %5d %3d %3d %.5f %.5f"
printf " %c %-*s %5.0f %5d %5d %5d %5.0f %5d %3d %3d %.5f %.5f"
(if off then '-' else if fn then '*' else ' ')
mname n (t_mem t) (f_mem t) (r_mem t)
mname n (t_mem t) (n_mem t) (f_mem t) (r_mem t)
((t_dsk t) / 1024) ((f_dsk t) `div` 1024)
(length pl) (length sl)
mp dp
......@@ -161,10 +161,12 @@ parseNode :: JSObject JSValue -> Either String String
parseNode a =
let name = getStringElement "name" a
mtotal = getIntElement "mtotal" a
mnode = getIntElement "mnode" a
mfree = getIntElement "mfree" a
dtotal = getIntElement "dtotal" a
dfree = getIntElement "dfree" a
in concatElems name $
concatElems (show `apply1` mtotal) $
concatElems (show `apply1` mnode) $
concatElems (show `apply1` mfree) $
concatElems (show `apply1` dtotal) (show `apply1` dfree)
......@@ -240,7 +240,7 @@ The programs can either get their input from text files, or directly
from a cluster via RAPI. For text files, the following two commands
should be run::
gnt-node list -oname,mtotal,mfree,dtotal,dfree \
gnt-node list -oname,mtotal,mnode,mfree,dtotal,dfree \
--separator '|' --no-headers > nodes
gnt-instance list -oname,admin_ram,sda_size,pnode,snodes \
--separator '|' --no-head > instances
......
......@@ -111,6 +111,7 @@ The node list will contain these informations:
node
- the node name
- the total node memory
- the memory used by the node itself
- the free node memory
- the reserved node memory, which is the amount of free memory
needed for N+1 compliance
......
......@@ -97,6 +97,7 @@ The node list will contain these informations:
node
- the node name
- the total node memory
- the memory used by the node itself
- the free node memory
- the reserved node memory, which is the amount of free memory
needed for N+1 compliance
......
......@@ -85,8 +85,8 @@ serializeNodes nl csf ktn =
t_mem = (truncate $ Node.t_mem node)::Int
t_dsk = (truncate $ Node.t_dsk node)::Int
in
printf "%s|%d|%d|%d|%d" name
t_mem (Node.f_mem node)
printf "%s|%d|%d|%d|%d|%d" name
t_mem (Node.n_mem node) (Node.f_mem node)
t_dsk (Node.f_dsk node))
nodes
in unlines nlines
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment