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