Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
ffdd4dcf
Commit
ffdd4dcf
authored
Dec 04, 2018
by
Pierre Neyron
🚴
Browse files
Add option unit to get_size: IEC or metric
e.g.: IEC for disks metric for RAM
parent
0026e36e
Pipeline
#52851
passed with stages
in 1 minute and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/refrepo/gen/wiki/generators/hardware.rb
View file @
ffdd4dcf
...
...
@@ -274,19 +274,19 @@ class G5KHardwareGenerator < WikiGenerator
sd
=
node_hash
[
'storage_devices'
]
reservable_disks
=
sd
.
to_a
.
select
{
|
v
|
v
[
1
][
'reservation'
]
==
true
}.
count
>
0
maindisk
=
sd
.
to_a
.
select
{
|
v
|
v
[
0
]
==
'sda'
}.
first
[
1
]
maindisk_t
=
maindisk
[
'storage'
]
+
' '
+
G5K
.
get_size
(
maindisk
[
'size'
])
maindisk_t
=
maindisk
[
'storage'
]
+
' '
+
G5K
.
get_size
(
maindisk
[
'size'
]
,
'metric'
)
other
=
sd
.
to_a
.
select
{
|
d
|
d
[
0
]
!=
'sda'
}
hdds
=
other
.
select
{
|
d
|
d
[
1
][
'storage'
]
==
'HDD'
}
if
hdds
.
count
==
0
hdd_t
=
"0"
else
hdd_t
=
hdds
.
count
.
to_s
+
" ("
+
hdds
.
map
{
|
d
|
G5K
.
get_size
(
d
[
1
][
'size'
])
}.
join
(
', '
)
+
")"
hdd_t
=
hdds
.
count
.
to_s
+
" ("
+
hdds
.
map
{
|
d
|
G5K
.
get_size
(
d
[
1
][
'size'
]
,
'metric'
)
}.
join
(
', '
)
+
")"
end
ssds
=
other
.
select
{
|
d
|
d
[
1
][
'storage'
]
==
'SSD'
}
if
ssds
.
count
==
0
ssd_t
=
"0"
else
ssd_t
=
ssds
.
count
.
to_s
+
" ("
+
ssds
.
map
{
|
d
|
G5K
.
get_size
(
d
[
1
][
'size'
])
}.
join
(
', '
)
+
")"
ssd_t
=
ssds
.
count
.
to_s
+
" ("
+
ssds
.
map
{
|
d
|
G5K
.
get_size
(
d
[
1
][
'size'
]
,
'metric'
)
}.
join
(
', '
)
+
")"
end
queues
=
cluster_hash
[
'queues'
]
-
[
'admin'
,
'default'
]
queue_t
=
(
queues
.
nil?
||
(
queues
.
empty?
?
''
:
"_.28"
+
queues
[
0
].
gsub
(
' '
,
'_'
)
+
' queue.29'
))
...
...
lib/refrepo/gen/wiki/generators/site_hardware.rb
View file @
ffdd4dcf
...
...
@@ -201,10 +201,10 @@ def get_hardware(sites)
hard
[
'processor_description'
]
=
"
#{
hard
[
'processor_model'
]
}
(
#{
hard
[
'microarchitecture'
]
}#{
hard
[
'processor_freq'
]
?
', '
+
hard
[
'processor_freq'
]
:
''
}
,
#{
hard
[
'cpus_per_node_str'
]
}
,
#{
hard
[
'cores_per_cpu_str'
]
}
)"
hard
[
'ram_size'
]
=
G5K
.
get_size
(
node_hash
[
'main_memory'
][
'ram_size'
])
storage
=
node_hash
[
'storage_devices'
].
map
{
|
k
,
v
|
{
'size'
=>
v
[
'size'
],
'tech'
=>
v
[
'storage'
]}
}
hard
[
'storage'
]
=
storage
.
each_with_object
(
Hash
.
new
(
0
))
{
|
data
,
counts
|
counts
[
data
]
+=
1
}.
to_a
.
sort_by
{
|
e
|
e
[
0
][
'size'
].
to_f
}.
map
{
|
e
|
(
e
[
1
]
==
1
?
''
:
e
[
1
].
to_s
+
' x '
)
+
G5K
.
get_size
(
e
[
0
][
'size'
])
+
' '
+
e
[
0
][
'tech'
]
}.
join
(
' + '
)
hard
[
'storage'
]
=
storage
.
each_with_object
(
Hash
.
new
(
0
))
{
|
data
,
counts
|
counts
[
data
]
+=
1
}.
to_a
.
sort_by
{
|
e
|
e
[
0
][
'size'
].
to_f
}.
map
{
|
e
|
(
e
[
1
]
==
1
?
''
:
e
[
1
].
to_s
+
' x '
)
+
G5K
.
get_size
(
e
[
0
][
'size'
]
,
'metric'
)
+
' '
+
e
[
0
][
'tech'
]
}.
join
(
' + '
)
hard
[
'storage_size'
]
=
storage
.
inject
(
0
){
|
sum
,
v
|
sum
+
(
v
[
'size'
].
to_f
/
2
**
30
).
floor
}.
to_s
# round to GB to avoid small differences within a cluster
storage_description
=
node_hash
[
'storage_devices'
].
map
{
|
k
,
v
|
{
'device'
=>
v
[
'device'
],
'size'
=>
v
[
'size'
],
'tech'
=>
v
[
'storage'
],
'interface'
=>
v
[
'interface'
],
'model'
=>
v
[
'model'
],
'driver'
=>
v
[
'driver'
],
'path'
=>
v
[
'by_path'
]
||
v
[
'by_id'
],
'count'
=>
node_hash
[
'storage_devices'
].
count
}
}
hard
[
'storage_description'
]
=
storage_description
.
map
{
|
e
|
[
e
[
'count'
]
>
1
?
"
\n
*"
:
''
,
G5K
.
get_size
(
e
[
'size'
]),
e
[
'tech'
],
e
[
'interface'
],
e
[
'model'
],
' (driver: '
+
(
e
[
'driver'
]
||
'MISSING'
)
+
', path: '
+
(
e
[
'path'
]
||
'MISSING'
)
+
')'
].
join
(
' '
)
}.
join
(
'<br />'
)
hard
[
'storage_description'
]
=
storage_description
.
map
{
|
e
|
[
e
[
'count'
]
>
1
?
"
\n
*"
:
''
,
G5K
.
get_size
(
e
[
'size'
]
,
'metric'
),
e
[
'tech'
],
e
[
'interface'
],
e
[
'model'
],
' (driver: '
+
(
e
[
'driver'
]
||
'MISSING'
)
+
', path: '
+
(
e
[
'path'
]
||
'MISSING'
)
+
')'
].
join
(
' '
)
}.
join
(
'<br />'
)
network
=
node_hash
[
'network_adapters'
].
select
{
|
k
,
v
|
v
[
'management'
]
==
false
&&
...
...
lib/refrepo/gen/wiki/mw_utils.rb
View file @
ffdd4dcf
...
...
@@ -77,12 +77,21 @@ module G5K
s
+=
']'
end
def
self
.
get_size
(
x
)
gbytes
=
(
x
.
to_f
/
2
**
30
).
floor
if
gbytes
<
2
**
10
gbytes
.
to_s
+
' GB'
def
self
.
get_size
(
x
,
unit
=
'IEC'
)
if
unit
==
'metric'
giga
=
(
x
.
to_f
/
1000
**
3
).
floor
if
giga
<
1000
giga
.
to_s
+
' GB'
else
(
x
.
to_f
/
1000
**
4
).
round
(
2
).
to_s
+
' TB'
end
else
(
x
.
to_f
/
2
**
40
).
round
(
3
).
to_s
+
' TB'
giga
=
(
x
.
to_f
/
2
**
30
).
floor
if
giga
<
2
**
10
giga
.
to_s
+
' GiB'
else
(
x
.
to_f
/
2
**
40
).
round
(
2
).
to_s
+
' TiB'
end
end
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment