Commit 8bcdde0c authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a new node/instance field

This new field ('alias') will hold the shortened/beautified display
name. When resetting the name, the alias is reset too, and there's a new
function to update only the alias.
parent 49f9627a
......@@ -33,6 +33,7 @@ module Ganeti.HTools.Instance
, create
, setIdx
, setName
, setAlias
, setPri
, setSec
, setBoth
......@@ -49,6 +50,7 @@ import qualified Ganeti.HTools.Container as Container
-- | The instance type
data Instance = Instance { name :: String -- ^ The instance name
, alias :: String -- ^ The shortened name
, mem :: Int -- ^ Memory of the instance
, dsk :: Int -- ^ Disk size of instance
, vcpus :: Int -- ^ Number of VCPUs
......@@ -88,6 +90,7 @@ create :: String -> Int -> Int -> Int -> String
-> [String] -> T.Ndx -> T.Ndx -> Instance
create name_init mem_init dsk_init vcpus_init run_init tags_init pn sn =
Instance { name = name_init
, alias = name_init
, mem = mem_init
, dsk = dsk_init
, vcpus = vcpus_init
......@@ -115,7 +118,15 @@ setIdx t i = t { idx = i }
setName :: Instance -- ^ The original instance
-> String -- ^ New name
-> Instance -- ^ The modified instance
setName t s = t { name = s }
setName t s = t { name = s, alias = s }
-- | Changes the alias.
--
-- This is used only during the building of the data structures.
setAlias :: Instance -- ^ The original instance
-> String -- ^ New alias
-> Instance -- ^ The modified instance
setAlias t s = t { alias = s }
-- * Update functions
......
......@@ -34,6 +34,7 @@ module Ganeti.HTools.Node
, buildPeers
, setIdx
, setName
, setAlias
, setOffline
, setXmem
, setFmem
......@@ -85,6 +86,7 @@ type TagMap = Map.Map String Int
-- | The node type.
data Node = Node
{ name :: String -- ^ The node name
, alias :: String -- ^ The shortened name (for display purposes)
, tMem :: Double -- ^ Total memory (MiB)
, nMem :: Int -- ^ Node memory (MiB)
, fMem :: Int -- ^ Free memory (MiB)
......@@ -181,7 +183,8 @@ create :: String -> Double -> Int -> Int -> Double
-> Int -> Double -> Bool -> Node
create name_init mem_t_init mem_n_init mem_f_init
dsk_t_init dsk_f_init cpu_t_init offline_init =
Node { name = name_init
Node { name = name_init
, alias = name_init
, tMem = mem_t_init
, nMem = mem_n_init
, fMem = mem_f_init
......@@ -228,7 +231,13 @@ setIdx t i = t {idx = i}
--
-- This is used only during the building of the data structures.
setName :: Node -> String -> Node
setName t s = t {name = s}
setName t s = t { name = s, alias = s }
-- | Changes the alias.
--
-- This is used only during the building of the data structures.
setAlias :: Node -> String -> Node
setAlias t s = t { alias = s }
-- | Sets the offline attribute.
setOffline :: Node -> Bool -> Node
......
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