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
06b0bf54
Commit
06b0bf54
authored
Mar 11, 2020
by
Simon Delamare
Browse files
[lib] Add generator for kwollect
parent
2d75bf26
Changes
8
Hide whitespace changes
Inline
Side-by-side
Rakefile
View file @
06b0bf54
...
...
@@ -203,7 +203,7 @@ namespace :gen do
namespace
:puppet
do
all_puppet_tasks
=
[
:bindg5k
,
:conmang5k
,
:dhcpg5k
,
:kadeployg5k
,
:lanpowerg5k
,
:kavlang5k
,
:network_monitoring
,
:'refapi-subset'
]
all_puppet_tasks
=
[
:bindg5k
,
:conmang5k
,
:dhcpg5k
,
:kadeployg5k
,
:lanpowerg5k
,
:kavlang5k
,
:kwollectg5k
,
:network_monitoring
,
:'refapi-subset'
]
all_puppet_tasks
.
each
{
|
t
|
generated_desc
=
(
t
==
:'refapi-subset'
)
?
'description'
:
'configuration'
...
...
lib/refrepo/gen/puppet/kwollectg5k.rb
0 → 100644
View file @
06b0bf54
require
'refrepo/hash/hash'
def
generate_puppet_kwollectg5k
(
options
)
puts
"Writing kwollect configuration files to:
#{
options
[
:output_dir
]
}
"
puts
"Using configuration directory:
#{
options
[
:conf_dir
]
}
"
puts
"For site(s):
#{
options
[
:sites
].
join
(
', '
)
}
"
if
not
options
[
:conf_dir
]
options
[
:conf_dir
]
=
"
#{
options
[
:output_dir
]
}
/platforms/production/generators/ipmitools/"
end
if
not
Pathname
(
"
#{
options
[
:conf_dir
]
}
/console-password.yaml"
).
exist?
puts
"Warning: No
#{
options
[
:conf_dir
]
}
/console-password.yaml file found"
credentials
=
{}
else
credentials
=
YAML
::
load_file
(
"
#{
options
[
:conf_dir
]
}
/console-password.yaml"
)
end
refapi
=
load_data_hierarchy
refapi
[
'sites'
].
each
{
|
site_uid
,
site
|
next
unless
options
[
:sites
].
include?
(
site_uid
)
# Metrics configuration for each node
site
[
'clusters'
].
sort
.
each
{
|
cluster_uid
,
cluster
|
cluster
[
'nodes'
].
each_sort_by_node_uid
{
|
node_uid
,
node
|
ipmi_credentials
=
credentials
.
fetch
(
site_uid
,
{}).
fetch
(
cluster_uid
,
""
).
sub
(
" "
,
":"
)
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kwollect-node.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kwollect/
#{
site_uid
}
/
#{
node_uid
}
.conf"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
}
}
# Metrics configuration for network device
site
[
'network_equipments'
].
each
{
|
neteq_uid
,
neteq
|
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kwollect-network.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kwollect/
#{
site_uid
}
/
#{
neteq_uid
}
.conf"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
}
# Wattmetre mapping configuration
wattmetre_port_per_node
=
{}
site
.
fetch
(
'pdus'
,
{}).
each
{
|
pdu_uid
,
pdu
|
next
if
pdu
.
fetch
(
'metrics'
,
[]).
none?
{
|
metric
|
metric
[
'source'
][
'protocol'
]
==
'wattmetre'
}
pdu
.
fetch
(
'ports'
,
{}).
each
{
|
port
,
node
|
if
not
wattmetre_port_per_node
.
key?
(
node
)
wattmetre_port_per_node
[
node
]
=
[]
end
wattmetre_port_per_node
[
node
].
append
(
"
#{
pdu_uid
}
-port
#{
port
}
"
)
}
}
if
not
wattmetre_port_per_node
.
empty?
output
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/kwollect-wattmetre-mapping.erb'
,
File
.
dirname
(
__FILE__
))),
nil
,
'-'
).
result
(
binding
)
output_file
=
Pathname
(
"
#{
options
[
:output_dir
]
}
//platforms/production/modules/generated/files/grid5000/kwollect-wattmetre/
#{
site_uid
}
/wattmetre-mapping.conf"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
)
end
}
end
lib/refrepo/gen/puppet/templates/kwollect-network.erb
0 → 100644
View file @
06b0bf54
#
# This file was generated from reference-repository.git
# Do not edit this file by hand. Your changes will be overwritten.
#
<%-
neteq
.
fetch
(
'metrics'
,
[]).
each
{
|
metric
|
next
if
metric
[
'source'
][
'protocol'
]
!=
'snmp'
if
metric
[
'source'
][
'id'
].
include?
(
'%SNMP_IFACE%'
)
neteq
[
'linecards'
].
each_with_index
{
|
linecard
,
linecard_uid
|
linecard
.
fetch
(
'ports'
,
[]).
each_with_index
{
|
lport
,
lport_uid
|
next
if
lport
.
empty?
lport_uid
+=
12
port_uid
=
neteq
[
'linecards'
].
length
>
1
?
"
#{
linecard_uid
}
_
#{
lport_uid
}
"
:
lport_uid
port_name
=
linecard
[
"snmp_pattern"
].
sub
(
"%LINECARD%"
,
linecard_uid
.
to_s
).
sub
(
"%PORT%"
,
lport_uid
.
to_s
)
# TODO: Handle secondary interface
port_node
=
lport
[
'uid'
]
-%>
- name:
<%=
metric
[
'name'
]
%>
device_id:
<%=
neteq_uid
%>
-port-
<%=
port_uid
%>
device_alias:
<%=
port_node
%>
url: snmp://
<%=
neteq
.
fetch
(
'snmp_community'
,
'public'
)
%>
@
<%=
neteq_uid
%>
.
<%=
site_uid
%>
.grid5000.fr/
<%=
metric
[
'source'
][
'id'
].
sub
(
'%SNMP_IFACE%'
,
"{{
#{
port_name
}
}}"
)
%>
update_every:
<%=
metric
[
'period'
]
>
0
?
metric
[
'period'
]
:
metric
[
'optional_period'
]
%>
<%-
if
metric
[
'period'
]
==
0
-%>
optional: true
<%-
end
-%>
<%-
}
}
else
-%>
- name:
<%=
metric
[
'name'
]
%>
device_id:
<%=
neteq_uid
%>
url: snmp://
<%=
neteq
.
fetch
(
'snmp_community'
,
'public'
)
%>
@
<%=
neteq_uid
%>
.
<%=
site_uid
%>
.grid5000.fr/
<%=
metric
[
'source'
][
'id'
]
%>
update_every:
<%=
metric
[
'period'
]
>
0
?
metric
[
'period'
]
:
metric
[
'optional_period'
]
%>
<%-
if
metric
[
'period'
]
==
0
-%>
optional: true
<%-
end
-%>
<%-
end
}
-%>
lib/refrepo/gen/puppet/templates/kwollect-node.erb
0 → 100644
View file @
06b0bf54
#
# This file was generated from reference-repository.git
# Do not edit this file by hand. Your changes will be overwritten.
#
<%-
cluster
.
fetch
(
'metrics'
,
[]).
each
{
|
metric
|
next
if
metric
[
'source'
][
'protocol'
]
==
"wattmetre"
next
if
metric
[
'source'
][
'protocol'
]
==
"network_equipment"
if
metric
[
'source'
][
'protocol'
]
==
"ipmisensor"
auth
=
ipmi_credentials
+
"@"
elsif
metric
[
'source'
][
'protocol'
]
==
"snmp"
auth
=
"public@"
else
auth
=
""
end
-%>
- name:
<%=
metric
[
'name'
]
%>
device_id:
<%=
node_uid
%>
url:
<%=
metric
[
'source'
][
'protocol'
]
%>
://
<%=
auth
%><%=
node_uid
%>
-bmc.
<%=
site_uid
%>
.grid5000.fr/
<%=
metric
[
'source'
][
'id'
]
%>
device_alias:
<%=
node_uid
%>
-bmc
update_every:
<%=
metric
[
'period'
]
>
0
?
metric
[
'period'
]
:
metric
[
'optional_period'
]
%>
<%-
if
metric
[
'period'
]
==
0
-%>
optional: true
<%-
end
-%>
<%-
}
-%>
lib/refrepo/gen/puppet/templates/kwollect-wattmetre-mapping.erb
0 → 100644
View file @
06b0bf54
#
# This file was generated from reference-repository.git
# Do not edit this file by hand. Your changes will be overwritten.
#
<%-
wattmetre_port_per_node
.
each
{
|
node
,
ports
|
-%>
<%=
node
%>
: [
<%=
ports
.
join
(
','
)
%>
]
<%-
}
-%>
lib/refrepo/valid/input/schemas/schema-cluster.yaml
View file @
06b0bf54
...
...
@@ -5,3 +5,4 @@ created_at: required # string or date ?
kavlan
:
boolean
queues
:
array
priority
:
optional_string
metrics
:
optional_array
lib/refrepo/valid/input/schemas/schema-network_equipments.yaml
View file @
06b0bf54
...
...
@@ -56,3 +56,4 @@ channels:
uid
:
string
kind
:
string
rate
:
integer
metrics
:
optional_array
lib/refrepo/valid/input/schemas/schema-site.yaml
View file @
06b0bf54
...
...
@@ -71,6 +71,7 @@ pdus:
mac
:
optional_string
vendor
:
optional_string
model
:
optional_string
metrics
:
optional_array
sensors
:
<array>
:
power
:
...
...
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