Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reference-repository
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
grid5000
reference-repository
Commits
26f13113
Commit
26f13113
authored
7 years ago
by
Florent Didier
Browse files
Options
Downloads
Patches
Plain Diff
[dev] check-network-description: sort .dot file content to be able to make diffs
parent
cf49aee1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generators/input-validators/check-network-description.rb
+23
-18
23 additions, 18 deletions
generators/input-validators/check-network-description.rb
with
23 additions
and
18 deletions
generators/input-validators/check-network-description.rb
+
23
−
18
View file @
26f13113
#!/usr/bin/ruby
# coding: utf-8
# This script checks the network description for inconsistencies
...
...
@@ -266,30 +267,31 @@ def generate_dot(netnodes, links, site)
# factor
nodeslinks
.
map!
{
|
e
|
e
[
1
]
=
`echo
#{
e
[
1
].
uniq
.
join
(
' '
)
}
|nodeset -f`
.
chomp
;
e
}
fd
=
File
::
new
(
"network_
#{
site
}
.dot"
,
'w'
)
fd
.
puts
"graph graphname {"
header
=
[]
content
=
[]
trailer
=
[]
header
<<
"graph graphname {"
router
=
mynetnodes
.
select
{
|
n
|
n
[
'kind'
]
==
'router'
}.
first
[
'nickname'
]
fd
.
puts
<<-
EOF
root="
#{
router
}
";
layout=twopi;
overlap=scale;
splines=true;
ranksep=2.0;
EOF
header
<<
"root=
\"
#{
router
}
\"
;"
header
<<
"layout=twopi;"
header
<<
"overlap=scale;"
header
<<
"splines=true;"
header
<<
"ranksep=2.0;"
# output graph nodes, equipment first
(
eqlinks
.
map
{
|
e
|
e
[
'switch'
]
}
+
eqlinks
.
map
{
|
e
|
e
[
'target'
]
}).
each
do
|
eq
|
fd
.
puts
"
\"
#{
eq
}
\"
[shape=box];"
content
<<
"
\"
#{
eq
}
\"
[shape=box];"
end
# then nodes groups
nodeslinks
.
each
do
|
e
|
fd
.
puts
"
\"
#{
e
[
1
]
}
\"
;"
content
<<
"
\"
#{
e
[
1
]
}
\"
;"
end
# finally output links
# between network equipments
eqlinks
.
each
do
|
l
|
r
=
"
#{
l
[
'rate'
]
/
10
**
9
}
G"
fd
.
puts
"
\"
#{
l
[
'switch'
]
}
\"
--
\"
#{
l
[
'target'
]
}
\"
[label=
\"
#{
r
}
\"
];"
content
<<
"
\"
#{
l
[
'switch'
]
}
\"
--
\"
#{
l
[
'target'
]
}
\"
[label=
\"
#{
r
}
\"
];"
end
# between network equipments and nodes
nodeslinks
.
each
do
|
l
|
...
...
@@ -299,20 +301,23 @@ def generate_dot(netnodes, links, site)
iface
,
target
=
e
iface
=
iface
.
gsub
(
'eth'
,
''
)
r
=
"
#{
target
[
'rate'
]
/
10
**
9
}
G"
fd
.
puts
"
\"
#{
target
[
'switch'
]
}
\"
--
\"
#{
l
[
1
]
}
\"
[label=
\"
#{
r
}
\"
,headlabel=
\"
#{
iface
}
\"
];"
content
<<
"
\"
#{
target
[
'switch'
]
}
\"
--
\"
#{
l
[
1
]
}
\"
[label=
\"
#{
r
}
\"
,headlabel=
\"
#{
iface
}
\"
];"
end
else
# only one interface
l
[
0
][
1
].
each_pair
do
|
iface
,
target
|
r
=
"
#{
target
[
'rate'
]
/
10
**
9
}
G"
fd
.
puts
"
\"
#{
target
[
'switch'
]
}
\"
--
\"
#{
l
[
1
]
}
\"
[label=
\"
#{
r
}
\"
,len=2.0];"
content
<<
"
\"
#{
target
[
'switch'
]
}
\"
--
\"
#{
l
[
1
]
}
\"
[label=
\"
#{
r
}
\"
,len=2.0];"
end
end
end
fd
.
puts
"}"
fd
.
close
system
(
"dot -Tpdf network_
#{
site
}
.dot -onetwork_
#{
site
}
.pdf"
)
system
(
"dot -Tpng network_
#{
site
}
.dot -onetwork_
#{
site
}
.png"
)
trailer
<<
"}"
name
=
"
#{
site
.
capitalize
}
Network"
data
=
[
header
,
content
.
sort
,
trailer
].
flatten
.
join
(
"
\n
"
)
IO
.
write
(
"
#{
name
}
.dot"
,
data
)
system
(
"dot -Tpdf
#{
name
}
.dot -o
#{
name
}
.pdf"
)
system
(
"dot -Tpng
#{
name
}
.dot -o
#{
name
}
.png"
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment