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
8387c974
Commit
8387c974
authored
13 years ago
by
Gaetan SIMO
Browse files
Options
Downloads
Patches
Plain Diff
[Rakefile] Adding a manual task to edit net-links.yaml faster
parent
405ee069
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
Rakefile
+41
-0
41 additions, 0 deletions
Rakefile
with
41 additions
and
0 deletions
Rakefile
+
41
−
0
View file @
8387c974
...
...
@@ -231,6 +231,47 @@ namespace :netlinks do
puts
"+-
#{
"-"
*
message_size
}
-+"
end
end
task
:net_links
=>
[
:environment
,
:hosts
]
do
host
,
site
=
@host
.
scan
(
/(\S+)\.(\S+)/
).
flatten
dirs
=
Dir
.
glob
(
"generators/input/
#{
site
}
/"
)
if
dirs
.
empty?
@logger
.
error
"Failed to find a directory containing the net-links yaml file for your site '
#{
site
}
'"
next
end
@equipments
=
dirs
.
map
do
|
dir
|
site
=
File
.
basename
(
dir
)
net_links_file
=
File
.
join
(
dir
,
"net-links.yaml"
)
net_links_dir
=
File
.
join
(
dir
,
"net-links"
)
net_links_orig
=
YAML
::
load_file
(
net_links_file
)
net_links
=
net_links_orig
.
select
do
|
uid
,
properties
|
uid
.
match
(
Regexp
.
new
(
host
.
gsub
(
/\*/
,
'\S+'
)))
!=
nil
end
if
net_links
.
empty?
@logger
.
warn
"Failed to find any host described within the file
#{
net_links_file
}
."
else
{
:net_links
=>
net_links
,
:net_links_orig
=>
net_links_orig
,
:net_links_file
=>
net_links_file
}
end
end
end
desc
"Manually modify net-links.yaml with custumized script."
task
:manual
=>
:net_links
do
# puts @net_links.inspect
# gw.grenoble
gw
=
@equipments
[
0
]
puts
gw
[
:net_links
]
linecards
=
gw
[
:net_links
][
"sbordeplage-2"
][
"linecards"
][
1
]
linecards
[
"ports"
]
=
{}
if
linecards
[
"ports"
].
nil?
ports
=
linecards
[
"ports"
]
11
.
upto
(
51
)
do
|
i
|
ports
[
i
-
10
]
=
"bordeplage-
#{
i
}
"
end
# When all net links in a site are formated, we write them in they file.
File
.
open
(
gw
[
:net_links_file
],
'w'
){
|
f
|
YAML
::
dump
(
gw
[
:net_links_orig
].
merge
(
gw
[
:net_links
]),
f
)}
puts
"updated
#{
gw
[
:net_links_file
]
}
"
end
desc
"Update net-links.yaml with the kavlan like config file."
task
:kavlan
=>
[
:environment
,
:hosts
]
do
config_file
=
ENV
[
'CONF'
]
...
...
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