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
8da4db97
Commit
8da4db97
authored
Jun 19, 2019
by
DELABROYE Dimitri
Browse files
[lib/refrepo/gen/puppet/bind] make bindg5k use data instead if input
parent
5864c5c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/refrepo/data_loader.rb
View file @
8da4db97
...
...
@@ -22,7 +22,7 @@ def load_data_hierarchy
path_hierarchy
=
File
.
dirname
(
filename
).
split
(
'/'
)
# Split the file path (path relative to input/)
path_hierarchy
=
[]
if
path_hierarchy
==
[
'.'
]
if
[
'nodes'
,
'network_equipments'
].
include?
(
path_hierarchy
.
last
)
if
[
'nodes'
,
'network_equipments'
,
'servers'
,
'pdus'
].
include?
(
path_hierarchy
.
last
)
# it's a node or a network_equipment, add the uid
path_hierarchy
<<
file_hash
[
'uid'
]
end
...
...
lib/refrepo/gen/puppet/bindg5k.rb
View file @
8da4db97
...
...
@@ -145,7 +145,7 @@ def get_networks_records(site, key)
next
end
eth_net_uid
=
node
[
'network_adapters'
].
select
{
|
u
,
h
|
h
[
'mounted'
]
&&
/^eth[0-9]$/
.
match
(
u
)
}
# eth* interfaces
eth_net_uid
=
node
[
'network_adapters'
].
select
{
|
u
,
h
|
h
[
'mounted'
]
&&
/^eth[0-9]$/
.
match
(
u
)
}
# eth* interfaces
node
[
'network_adapters'
].
each
{
|
net_uid
,
net_hash
|
if
!
eth_net_uid
.
include?
(
net_uid
)
&&
node
[
'network_adapters'
].
size
>
1
hostsuffix
=
"-
#{
net_uid
}
"
...
...
@@ -164,7 +164,7 @@ end
def
get_node_records
(
cluster_uid
,
node_uid
,
network_adapters
)
records
=
[]
network_adapters
.
each
{
|
net_uid
,
net_hash
|
next
unless
net_hash
[
'ip'
]
...
...
@@ -415,7 +415,7 @@ def generate_puppet_bindg5k(options)
$written_files
=
[]
refapi
=
load_
yaml_file
_hierarchy
refapi
=
load_
data
_hierarchy
# Loop over Grid'5000 sites
refapi
[
"sites"
].
each
{
|
site_uid
,
site
|
...
...
@@ -445,7 +445,7 @@ def generate_puppet_bindg5k(options)
site_records
[
'pdus'
]
=
get_pdus_records
(
site
)
unless
site
[
'pdus'
].
nil?
# Networks and laptops (same input format)
site_records
[
'networks'
]
=
get_networks_records
(
site
,
'networks'
)
unless
site
[
'networks'
].
nil?
site_records
[
'networks'
]
=
get_networks_records
(
site
,
'network
_equipment
s'
)
unless
site
[
'network
_equipment
s'
].
nil?
site_records
[
'laptops'
]
=
get_networks_records
(
site
,
'laptops'
)
unless
site
[
'laptops'
].
nil?
site
.
fetch
(
"clusters"
,
[]).
sort
.
each
{
|
cluster_uid
,
cluster
|
...
...
@@ -457,8 +457,8 @@ def generate_puppet_bindg5k(options)
network_adapters
=
{}
# Nodes
node
.
fetch
(
'network_adapters'
).
each
{
|
net
_uid
,
net_hash
|
network_adapters
[
net
_uid
]
=
{
"ip"
=>
net
_hash
[
"ip"
],
"mounted"
=>
net
_hash
[
"mounted"
],
"
alias
"
=>
net
_hash
[
"
alias
"
]}
node
.
fetch
(
'network_adapters'
).
each
{
|
net
|
network_adapters
[
net
[
'device'
]
]
=
{
"ip"
=>
net
[
"ip"
],
"mounted"
=>
net
[
"mounted"
],
'
alias
'
=>
net
[
'
alias
'
]}
}
# Mic
...
...
@@ -474,9 +474,15 @@ def generate_puppet_bindg5k(options)
kavlan_adapters
=
{}
node
.
fetch
(
'kavlan'
).
each
{
|
net_uid
,
net_hash
|
net_hash
.
each
{
|
kavlan_net_uid
,
ip
|
kavlan_adapters
[
"
#{
net_uid
}
-
#{
kavlan_net_uid
}
"
]
=
{
"ip"
=>
ip
,
"mounted"
=>
node
[
'network_adapters'
][
net_uid
][
'mounted'
]}
kavlan_adapters
[
"
#{
net_uid
}
-
#{
kavlan_net_uid
}
"
]
=
{
'ip'
=>
ip
,
'mounted'
=>
node
[
'network_adapters'
].
select
{
|
n
|
n
[
'device'
]
==
net_uid
}[
0
][
'mounted'
]
}
}
}
site_records
[
"
#{
cluster_uid
}
-kavlan"
]
||=
[]
site_records
[
"
#{
cluster_uid
}
-kavlan"
]
+=
get_node_kavlan_records
(
cluster_uid
,
node_uid
,
network_adapters
,
kavlan_adapters
)
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