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
3cbe03c1
Commit
3cbe03c1
authored
4 years ago
by
IMBERT Matthieu
Committed by
Baptiste Jonglez
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[kavlan6] generate dhcpd6 configs
parent
69e38a04
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/refrepo/gen/puppet/kavlang5k.rb
+12
-9
12 additions, 9 deletions
lib/refrepo/gen/puppet/kavlang5k.rb
lib/refrepo/gen/puppet/templates/kavlan-dhcp.conf.erb
+33
-0
33 additions, 0 deletions
lib/refrepo/gen/puppet/templates/kavlan-dhcp.conf.erb
with
45 additions
and
9 deletions
lib/refrepo/gen/puppet/kavlang5k.rb
+
12
−
9
View file @
3cbe03c1
...
@@ -58,18 +58,21 @@ def generate_puppet_kavlang5k(options)
...
@@ -58,18 +58,21 @@ def generate_puppet_kavlang5k(options)
File
.
write
(
output_file
,
output
)
File
.
write
(
output_file
,
output
)
(
1
..
9
).
each
do
|
kavlan_id
|
(
1
..
9
).
each
do
|
kavlan_id
|
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
[
"dhcpd"
,
"dhcpd6"
].
each
{
|
dhcpkind
|
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/dhcpd-
#{
kavlan_id
}
.conf"
)
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
output_file
.
dirname
.
mkpath
()
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/
#{
dhcpkind
}
-
#{
kavlan_id
}
.conf"
)
File
.
write
(
output_file
,
output
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
}
end
end
# 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
()
kavlan_id
=
refapi
[
'sites'
][
site_uid
][
'kavlans'
].
each_key
.
select
{
|
k
|
k
.
to_i
>
9
}.
pop
().
to_i
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
[
"dhcpd"
,
"dhcpd6"
].
each
{
|
dhcpkind
|
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/dhcpd-0.conf"
)
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kavlan-dhcp.conf.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
File
.
write
(
output_file
,
output
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kavlan/
#{
site_uid
}
/dhcp/
#{
dhcpkind
}
-0.conf"
)
File
.
write
(
output_file
,
output
)
}
}
}
end
end
This diff is collapsed.
Click to expand it.
lib/refrepo/gen/puppet/templates/kavlan-dhcp.conf.erb
+
33
−
0
View file @
3cbe03c1
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# Module : kavlang5k
# Module : kavlang5k
# GENERATED by kavlang5k.rb
# GENERATED by kavlang5k.rb
<%
if
dhcpkind
==
'dhcpd'
-%>
ddns-update-style none;
ddns-update-style none;
option space pxelinux;
option space pxelinux;
option pxelinux.magic code 208 = string;
option pxelinux.magic code 208 = string;
...
@@ -52,15 +53,34 @@ kavlan = refapi['sites'][site_uid]['kavlans'][kavlan_id.to_s] # TODO fix needed
...
@@ -52,15 +53,34 @@ kavlan = refapi['sites'][site_uid]['kavlans'][kavlan_id.to_s] # TODO fix needed
kavlan_ip
=
IPAddress
::
IPv4
::
new
(
kavlan
[
'network'
])
kavlan_ip
=
IPAddress
::
IPv4
::
new
(
kavlan
[
'network'
])
-%>
-%>
<%
end
-%>
<%
kavlan
=
refapi
[
'sites'
][
site_uid
][
'kavlans'
][
kavlan_id
.
to_s
]
# TODO fix needed conversion
if
dhcpkind
==
'dhcpd'
kavlan_ip
=
IPAddress
::
IPv4
::
new
(
kavlan
[
'network'
])
-%>
subnet
<%=
kavlan_ip
.
network
%>
netmask
<%=
kavlan_ip
.
netmask
%>
{
subnet
<%=
kavlan_ip
.
network
%>
netmask
<%=
kavlan_ip
.
netmask
%>
{
<%
elsif
dhcpkind
==
'dhcpd6'
case
kavlan_id
when
1
..
3
# local non routed vlan
kavlan6_net
=
kavlan_id
+
0x80
-
1
when
4
..
9
# local routed vlan
kavlan6_net
=
kavlan_id
+
0x90
-
4
else
# global vlan
kavlan6_net
=
kavlan_id
+
0xa0
-
10
end
refapi
[
'sites'
][
site_uid
]
kavlan6_ip
=
"
#{
refapi
[
'sites'
][
site_uid
][
'ipv6'
][
'prefix'
]
}#{
sprintf
(
'%02x'
,
kavlan6_net
)
}
::/64"
-%>
subnet6
<%=
kavlan6_ip
%>
{
<%
end
-%>
default-lease-time 86400;
default-lease-time 86400;
max-lease-time 604800;
max-lease-time 604800;
option domain-name-servers
<%=
kavlan_id
.
to_i
.
between?
(
1
,
3
)?
kavlan
[
'gateway'
]
:
"dns.
#{
site_uid
}
.grid5000.fr"
%>
;
option domain-name-servers
<%=
kavlan_id
.
to_i
.
between?
(
1
,
3
)?
kavlan
[
'gateway'
]
:
"dns.
#{
site_uid
}
.grid5000.fr"
%>
;
option ntp-servers
<%=
kavlan_id
.
to_i
.
between?
(
1
,
3
)?
kavlan
[
'gateway'
]
:
"ntp.
#{
site_uid
}
.grid5000.fr"
%>
;
option ntp-servers
<%=
kavlan_id
.
to_i
.
between?
(
1
,
3
)?
kavlan
[
'gateway'
]
:
"ntp.
#{
site_uid
}
.grid5000.fr"
%>
;
option routers
<%=
kavlan
[
'gateway'
]
%>
;
option routers
<%=
kavlan
[
'gateway'
]
%>
;
<%
if
dhcpkind
==
'dhcpd'
-%>
option subnet-mask
<%=
kavlan_ip
.
netmask
%>
;
option subnet-mask
<%=
kavlan_ip
.
netmask
%>
;
option broadcast-address
<%=
kavlan_ip
.
broadcast
%>
;
option broadcast-address
<%=
kavlan_ip
.
broadcast
%>
;
next-server
<%=
"kadeploy.
#{
site_uid
}
.grid5000.fr"
%>
;
next-server
<%=
"kadeploy.
#{
site_uid
}
.grid5000.fr"
%>
;
<%
end
-%>
}
}
<%
<%
...
@@ -79,6 +99,8 @@ refapi['sites'].sort.to_h.each_key do |site|
...
@@ -79,6 +99,8 @@ refapi['sites'].sort.to_h.each_key do |site|
"Missing mac (
#{
interface
[
'mac'
]
}
) or IP (
#{
node
[
'kavlan'
][
interface
[
'device'
]]
and
node
[
'kavlan'
][
interface
[
'device'
]][
"kavlan-
#{
kavlan_id
}
"
]
}
)"
"Missing mac (
#{
interface
[
'mac'
]
}
) or IP (
#{
node
[
'kavlan'
][
interface
[
'device'
]]
and
node
[
'kavlan'
][
interface
[
'device'
]][
"kavlan-
#{
kavlan_id
}
"
]
}
)"
next
next
end
end
if
dhcpkind
==
'dhcpd'
-%>
-%>
host
<%=
node_uid
%><%=
interface
[
'mounted'
]?
""
:
"-"
+
interface
[
'device'
]
%>
-kavlan-
<%=
kavlan_id
%>
.
<%=
site
%>
.grid5000.fr {
host
<%=
node_uid
%><%=
interface
[
'mounted'
]?
""
:
"-"
+
interface
[
'device'
]
%>
-kavlan-
<%=
kavlan_id
%>
.
<%=
site
%>
.grid5000.fr {
hardware ethernet
<%=
interface
[
'mac'
].
downcase
()
%>
;
hardware ethernet
<%=
interface
[
'mac'
].
downcase
()
%>
;
...
@@ -91,6 +113,17 @@ host <%= node_uid %><%= interface['mounted']? "" : "-"+interface['device'] %>-ka
...
@@ -91,6 +113,17 @@ host <%= node_uid %><%= interface['mounted']? "" : "-"+interface['device'] %>-ka
<%
end
-%>
<%
end
-%>
}
}
<%
<%
elsif
dhcpkind
==
'dhcpd6'
-%>
host
<%=
node_uid
%><%=
interface
[
'mounted'
]?
""
:
"-"
+
interface
[
'device'
]
%>
-kavlan-
<%=
kavlan_id
%>
-ipv6.
<%=
site
%>
.grid5000.fr {
hardware ethernet
<%=
interface
[
'mac'
].
downcase
()
%>
;
option host-name "
<%=
node_uid
%><%=
interface
[
'mounted'
]?
""
:
"-"
+
interface
[
'device'
]
%>
-kavlan-
<%=
kavlan_id
%>
-ipv6";
option domain-name "
<%=
site
%>
.grid5000.fr";
option domain-search "
<%=
site
%>
.grid5000.fr", "grid5000.fr";
fixed-address
<%=
node
[
'kavlan6'
][
interface
[
'device'
]][
"kavlan-
#{
kavlan_id
}
"
]
%>
;
}
<%
end
end
end
end
end
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