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
c92576fe
Commit
c92576fe
authored
9 months ago
by
JACQUOT Pierre
Browse files
Options
Downloads
Patches
Plain Diff
[kavlan] Put routed kavlan prefixes into a hash
parent
2a4a4f7a
Branches
autokavlan
No related tags found
No related merge requests found
Pipeline
#999478
passed
9 months ago
Stage: lint
Stage: validate
Stage: generate
Stage: deploy
Stage: checks
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/refrepo/gen/puppet/kavlang5k.rb
+24
-2
24 additions, 2 deletions
lib/refrepo/gen/puppet/kavlang5k.rb
with
24 additions
and
2 deletions
lib/refrepo/gen/puppet/kavlang5k.rb
+
24
−
2
View file @
c92576fe
...
@@ -39,7 +39,10 @@ def generate_puppet_kavlang5k(options)
...
@@ -39,7 +39,10 @@ def generate_puppet_kavlang5k(options)
puts
"For site(s):
#{
options
[
:sites
].
join
(
', '
)
}
"
puts
"For site(s):
#{
options
[
:sites
].
join
(
', '
)
}
"
refapi
=
load_data_hierarchy
refapi
=
load_data_hierarchy
eth_1_to_4_prefixes
=
{}
eth_5_to_6_prefixes
=
{}
eth_7_prefix
=
{}
refapi
[
'sites'
].
each
{
|
site_uid
,
site_refapi
|
refapi
[
'sites'
].
each
{
|
site_uid
,
site_refapi
|
next
unless
options
[
:sites
].
include?
(
site_uid
)
next
unless
options
[
:sites
].
include?
(
site_uid
)
...
@@ -68,13 +71,32 @@ def generate_puppet_kavlang5k(options)
...
@@ -68,13 +71,32 @@ def generate_puppet_kavlang5k(options)
}
}
end
end
kavlans
=
refapi
[
'sites'
][
site_uid
][
'kavlans'
]
# Look for site's global kavlan
# Look for site's global kavlan
# TODO fix dirty convertion to_i below
# TODO fix dirty convertion to_i below
kavlan_id
=
refapi
[
'sites'
][
site_uid
][
'
kavlans
'
]
.
each_key
.
select
{
|
k
|
k
.
to_i
>
9
}.
pop
().
to_i
kavlan_id
=
kavlans
.
each_key
.
select
{
|
k
|
k
.
to_i
>
9
}.
pop
().
to_i
[
"dhcpd"
,
"dhcpd6"
].
each
{
|
dhcpkind
|
[
"dhcpd"
,
"dhcpd6"
].
each
{
|
dhcpkind
|
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
trim_mode:
'-'
).
result
(
binding
)
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
trim_mode:
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/
#{
dhcpkind
}
-0.conf"
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/
#{
dhcpkind
}
-0.conf"
)
File
.
write
(
output_file
,
output
)
File
.
write
(
output_file
,
output
)
eth_7_prefix
[
site_uid
]
=
get_network_prefix
(
kavlans
[
"
#{
kavlan_id
}
"
][
'network'
])
}
}
eth_1_to_4_prefixes
[
site_uid
]
=
get_network_prefix
(
kavlans
[
'4'
][
'network'
])
eth_5_to_6_prefixes
[
site_uid
]
=
get_network_prefix
(
kavlans
[
'7'
][
'network'
])
}
}
# FIXME: remove theses ugly print and output the hashes into a yaml file into the cdgp
print
(
eth_1_to_4_prefixes
)
print
(
"
\n
"
)
print
(
eth_5_to_6_prefixes
)
print
(
"
\n
"
)
print
(
eth_7_prefix
)
print
(
"
\n
"
)
end
def
get_network_prefix
(
network
)
address
=
network
.
split
(
'/'
).
first
bytes
=
address
.
split
(
'.'
)
prefix
=
bytes
[
0
]
+
'.'
+
bytes
[
1
]
return
prefix
end
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