Commit d28bf7a8 authored by Klaus Aehlig's avatar Klaus Aehlig

htools: add CPU speed to the text backend

Extend the text format by an optional column for each node
containing the relative CPU speed, if provided.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent b3fc101f
......@@ -182,6 +182,8 @@ support all options. Some common options are:
- exclusive storage value (``Y`` if active, ``N`` otherwise)
- node free spindles
- virtual CPUs used by the node OS
- CPU speed relative to that of a ``standard node`` in the node
group the node belongs to
The third section contains instance data, with the fields:
......
......@@ -84,7 +84,7 @@ serializeNode :: Group.List -- ^ The list of groups (needed for group uuid)
-> Node.Node -- ^ The node to be serialised
-> String
serializeNode gl node =
printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s|%d|%s|%s|%d|%d" (Node.name node)
printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s|%d|%s|%s|%d|%d|%f" (Node.name node)
(Node.tMem node) (Node.nMem node) (Node.fMem node)
(Node.tDsk node) (Node.fDsk node) (Node.tCpu node)
(if Node.offline node then 'Y' else
......@@ -94,7 +94,7 @@ serializeNode gl node =
(intercalate "," (Node.nTags node))
(if Node.exclStorage node then "Y" else "N")
(Node.fSpindles node)
(Node.nCpu node)
(Node.nCpu node) (Node.tCpuSpeed node)
where grp = Container.find (Node.group node) gl
-- | Generate node file data from node objects.
......@@ -207,7 +207,7 @@ loadNode :: (Monad m) =>
-> m (String, Node.Node) -- ^ The result, a tuple o node name
-- and node object
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
excl_stor, free_spindles, nos_cpu] = do
excl_stor, free_spindles, nos_cpu, cpu_speed] = do
gdx <- lookupGroup ktg name gu
new_node <-
if "?" `elem` [tm,nm,fm,td,fd,tc] then
......@@ -222,6 +222,7 @@ loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
vtc <- tryRead name tc
vnc <- tryRead name nos_cpu
vspindles <- tryRead name spindles
vcpu_speed <- tryRead name cpu_speed
vfree_spindles <- tryRead name free_spindles
vexcl_stor <- case excl_stor of
"Y" -> return True
......@@ -229,9 +230,10 @@ loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
_ -> fail $
"Invalid exclusive_storage value for node '" ++
name ++ "': " ++ excl_stor
return . flip Node.setMaster (fo == "M") . flip Node.setNodeTags vtags $
Node.create name vtm vnm vfm vtd vfd vtc vnc (fo == "Y") vspindles
vfree_spindles gdx vexcl_stor
return . flip Node.setMaster (fo == "M") . flip Node.setNodeTags vtags
. flip Node.setCpuSpeed vcpu_speed
$ Node.create name vtm vnm vfm vtd vfd vtc vnc (fo == "Y") vspindles
vfree_spindles gdx vexcl_stor
return (name, new_node)
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] =
......@@ -253,6 +255,11 @@ loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
excl_stor, free_spindles, "1"]
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
excl_stor, free_spindles, nos_cpu] =
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles, tags,
excl_stor, free_spindles, nos_cpu, "1.0"]
loadNode _ s = fail $ "Invalid/incomplete node data: '" ++ show s ++ "'"
-- | Load an instance from a field list.
......
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