Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
822e3eef
Commit
822e3eef
authored
Sep 20, 2017
by
Lucas Nussbaum
Browse files
[dev] Better network graphs
parent
332bad78
Changes
1
Hide whitespace changes
Inline
Side-by-side
generators/input-validators/check-network-description.rb
View file @
822e3eef
...
...
@@ -189,15 +189,13 @@ def check_network_description(options)
# FIXME check rates
if
options
[
:dot
]
generate_dot
(
netnodes
,
links
,
"network_
#{
site
}
.dot"
)
generate_dot
(
netnodes
,
links
,
site
)
end
end
return
ok
end
def
generate_dot
(
netnodes
,
links
,
ofile
)
fd
=
File
::
new
(
ofile
,
'w'
)
fd
.
puts
"graph graphname {"
def
generate_dot
(
netnodes
,
links
,
site
)
mynetnodes
=
[]
netnodes
.
each
do
|
n
|
next
if
n
[
'interface'
]
==
'InfiniBand'
or
n
[
'interface'
]
==
'Myrinet'
or
HPC_SWITCHES
.
include?
(
n
[
'nickname'
])
...
...
@@ -239,17 +237,31 @@ def generate_dot(netnodes, links, ofile)
# remove duplicate reverse links between switches. We keep only the one where the target is the second node.
links
.
delete_if
{
|
l
|
[
'router'
,
'switch'
].
include?
(
l
[
'target_kind'
])
and
l
[
'target'
]
==
l
[
'nicknames'
].
first
}
fd
=
File
::
new
(
"network_
#{
site
}
.dot"
,
'w'
)
fd
.
puts
"graph graphname {"
router
=
mynetnodes
.
select
{
|
n
|
n
[
'kind'
]
==
'router'
}.
first
[
'nickname'
]
fd
.
puts
<<-
EOF
root="
#{
router
}
";
overlap=false;
splines=true;
ranksep=0.6;
EOF
# output remaining netnodes
mynetnodes
.
each
do
|
n
|
fd
.
puts
"
\"
#{
n
[
'nickname'
]
}
\"
;"
if
n
[
'kind'
]
==
'node'
fd
.
puts
"
\"
#{
n
[
'nickname'
]
}
\"
;"
else
fd
.
puts
"
\"
#{
n
[
'nickname'
]
}
\"
[shape=box];"
end
end
# finally output links
links
.
uniq
.
each
do
|
l
|
links
.
each
do
|
l
|
if
l
[
'rate'
]
==
1
*
10
**
9
r
=
'1G'
elsif
l
[
'rate'
]
==
10
*
10
**
9
r
=
'10G'
elsif
l
[
'rate'
]
==
40
*
10
**
9
r
=
'40G'
else
raise
"Invalid rate:
#{
l
[
'rate'
]
}
"
end
...
...
@@ -257,6 +269,8 @@ def generate_dot(netnodes, links, ofile)
end
fd
.
puts
"}"
fd
.
close
system
(
"twopi -Tpdf network_
#{
site
}
.dot -onetwork_
#{
site
}
.pdf"
)
system
(
"twopi -Tpng network_
#{
site
}
.dot -onetwork_
#{
site
}
.png"
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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