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
745dbbc1
Commit
745dbbc1
authored
Dec 08, 2018
by
Lucas Nussbaum
Browse files
Many rubocop fixes
parent
7c040509
Changes
22
Hide whitespace changes
Inline
Side-by-side
Rakefile
View file @
745dbbc1
...
...
@@ -11,7 +11,7 @@ end
$LOAD_PATH
.
unshift
(
File
.
expand_path
(
File
.
join
(
File
.
dirname
(
__FILE__
),
'lib'
)))
require
'refrepo'
if
Dir
::
exist
s
?
(
ENV
[
'HOME'
]
+
'/.gpuppet/repo'
)
if
Dir
::
exist?
(
ENV
[
'HOME'
]
+
'/.gpuppet/repo'
)
PUPPET_ODIR
=
ENV
[
'HOME'
]
+
'/.gpuppet/repo'
else
PUPPET_ODIR
=
'/tmp/puppet'
...
...
lib/refrepo/g5kchecks_importer.rb
View file @
745dbbc1
...
...
@@ -60,12 +60,12 @@ def g5kchecks_importer(sourcedir)
write_yaml
(
new_filename
,
hash
)
contents
=
File
.
read
(
new_filename
)
File
.
open
(
new_filename
,
'w'
)
{
|
f
ile
|
f
ile
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
f
ile
.
write
(
contents
)
}
File
.
open
(
new_filename
,
'w'
)
do
|
f
d
|
f
d
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
f
d
.
write
(
contents
)
end
rescue
Exception
=>
e
rescue
StandardError
=>
e
puts
"
#{
node_uid
}
-
#{
e
.
class
}
:
#{
e
.
message
}
\n
Error:
#{
e
.
backtrace
}
"
end
end
...
...
lib/refrepo/gen/oar-properties.rb
View file @
745dbbc1
...
...
@@ -25,7 +25,7 @@ def get_ref_default_properties(_site_uid, site)
properties
[
node_uid
]
=
get_ref_node_properties_internal
(
cluster_uid
,
cluster
,
node_uid
,
node
)
rescue
MissingProperty
=>
e
puts
"Error (missing property) while processing node
#{
node_uid
}
:
#{
e
}
"
rescue
Exception
=>
e
rescue
StandardError
=>
e
puts
"FATAL ERROR while processing node
#{
node_uid
}
:
#{
e
}
"
puts
"Description of the node is:"
pp
node
...
...
@@ -477,7 +477,7 @@ end
def
oarcmd_create_properties
(
properties_keys
)
command
=
''
properties_keys
.
each
do
|
key
,
key_type
|
if
key_type
==
Fixnum
if
key_type
==
Fixnum
# rubocop:disable Lint/UnifiedInteger
command
+=
"property_exist '
#{
key
}
' || oarproperty -a
#{
key
}
\n
"
elsif
key_type
==
String
command
+=
"property_exist '
#{
key
}
' || oarproperty -a
#{
key
}
--varchar
\n
"
...
...
@@ -532,18 +532,18 @@ def oarcmd_set_disk_properties(host, disk, disk_properties)
end
# sudo exec
def
ssh_exec
(
site_uid
,
cmds
,
options
)
def
ssh_exec
(
site_uid
,
cmds
,
_
options
)
# The following is equivalent to : "cat cmds | bash"
#res = ""
c
=
Net
::
SSH
.
start
(
"oar.
#{
site_uid
}
.g5kadmin"
,
"g5kadmin"
)
c
.
open_channel
{
|
channel
|
channel
.
exec
(
'sudo bash'
)
{
|
ch
,
success
|
# stdout
channel
.
on_data
{
|
ch
,
data
|
channel
.
on_data
{
|
ch
2
,
data
|
puts
data
#if options[:verbose] # ssh cmd output
}
# stderr
channel
.
on_extended_data
do
|
ch
,
type
,
data
|
channel
.
on_extended_data
do
|
ch
2
,
type
,
data
|
puts
data
end
...
...
lib/refrepo/gen/puppet/bindg5k.rb
View file @
745dbbc1
...
...
@@ -197,7 +197,7 @@ def get_node_records(cluster_uid, node_uid, network_adapters)
return
records
end
def
get_node_kavlan_records
(
cluster_uid
,
node_uid
,
network_adapters
,
kavlan_adapters
)
def
get_node_kavlan_records
(
_
cluster_uid
,
node_uid
,
network_adapters
,
kavlan_adapters
)
records
=
[]
kavlan_adapters
.
each
{
|
net_uid
,
net_hash
|
...
...
@@ -290,7 +290,7 @@ end
def
include_manual_file
(
zone
)
manual_file_path
=
File
.
join
(
File
.
dirname
(
zone
.
file_path
),
File
.
basename
(
zone
.
file_path
).
sub
(
'.db'
,
''
)
+
'-manual.db'
)
if
(
File
.
exist
s
?
(
manual_file_path
))
if
(
File
.
exist?
(
manual_file_path
))
return
"$INCLUDE /etc/bind/zones/
#{
zone
.
site_uid
}
/
#{
File
.
basename
(
zone
.
file_path
).
sub
(
'.db'
,
''
)
+
'-manual.db'
}
\n
"
end
return
''
...
...
@@ -298,7 +298,7 @@ end
#
def
load_zone
(
zone_file_path
,
site_uid
,
site
,
header
)
if
File
.
exist
s
?
(
zone_file_path
)
if
File
.
exist?
(
zone_file_path
)
zone
=
DNS
::
Zone
.
load
(
File
.
read
(
zone_file_path
))
else
zone
=
DNS
::
Zone
.
new
...
...
@@ -388,7 +388,7 @@ def get_orphan_reverse_manual_zones(zones_dir, site_uid, site)
zones
=
[]
Dir
.
glob
(
File
.
join
(
zones_dir
,
"reverse-*-manual.db"
)).
each
{
|
reverse_manual_file
|
output_file
=
reverse_manual_file
.
sub
(
"-manual.db"
,
".db"
)
next
if
File
.
exist
s
?
(
File
.
join
(
output_file
))
next
if
File
.
exist?
(
File
.
join
(
output_file
))
puts
"Creating file for orphan reverse manual file:
#{
output_file
}
"
if
$options
[
:verbose
]
#Creating the zone will include automatically the manual file
zone
=
load_zone
(
output_file
,
site_uid
,
site
,
true
)
...
...
lib/refrepo/gen/puppet/dhcpg5k.rb
View file @
745dbbc1
...
...
@@ -17,8 +17,11 @@ def get_network_info(node_hash, network_interface)
node_network_interface
=
node_network_adapters
.
fetch
(
neti
)
raise
'"mac" is nil'
unless
node_mac
=
node_network_interface
.
fetch
(
"mac"
)
raise
'"ip" is nil'
unless
node_ip
=
node_network_interface
.
fetch
(
"ip"
)
node_mac
=
node_network_interface
.
fetch
(
"mac"
)
node_ip
=
node_network_interface
.
fetch
(
"ip"
)
raise
'"mac" is nil'
unless
node_mac
raise
'"ip" is nil'
unless
node_ip
return
[
node_ip
,
node_mac
]
end
...
...
lib/refrepo/gen/puppet/kadeployg5k.rb
View file @
745dbbc1
...
...
@@ -139,9 +139,9 @@ def generate_puppet_kadeployg5k(options)
overrides
=
conf
[
site_uid
][
cluster_uid
]
dupes
=
(
defaults
.
to_a
&
overrides
.
to_a
)
if
not
dupes
.
empty?
puts
"Warning: cluster-specific configuration for
#{
cluster_uid
}
overrides default values:
#{
dupes
.
to_s
}
"
puts
"Warning: cluster-specific configuration for
#{
cluster_uid
}
overrides default values:
#{
dupes
}
"
end
data
=
data
=
defaults
.
merge
(
overrides
)
data
=
defaults
.
merge
(
overrides
)
if
data
.
nil?
puts
"Warning: configuration not found in
#{
options
[
:conf_dir
]
}
/kadeployg5k
#{
suffix
}
.yaml for
#{
cluster_uid
}
. Skipped"
next
...
...
lib/refrepo/gen/wiki/generators/hardware.rb
View file @
745dbbc1
...
...
@@ -238,6 +238,7 @@ class G5KHardwareGenerator < WikiGenerator
generated_content
+=
"
\n
= Nodes models =
\n
"
table_columns
=
[
'Nodes model'
]
+
sites
+
[
'Nodes total'
]
generated_content
+=
MW
.
generate_table
(
table_options
,
table_columns
,
get_table_data
(
data
,
'node_models'
))
return
generated_content
end
def
init
(
data
,
key1
,
key2
)
...
...
@@ -295,8 +296,8 @@ class G5KHardwareGenerator < WikiGenerator
'Skylake'
=>
'2016'
,
'Zen'
=>
'2017'
}
date
=
release_dates
[
microarchitecture
.
to_s
]
raise
"ERROR: microarchitecture not found: '
#{
microarchitecture
.
to_s
}
'. Add in hardware.rb"
if
date
.
nil?
date
=
release_dates
[
microarchitecture
]
raise
"ERROR: microarchitecture not found: '
#{
microarchitecture
}
'. Add in hardware.rb"
if
date
.
nil?
date
end
...
...
lib/refrepo/gen/wiki/generators/oar_properties.rb
View file @
745dbbc1
...
...
@@ -149,7 +149,7 @@ class OarPropertiesGenerator < WikiGenerator
#Existing properties that won't be documented
@@ignored_properties
=
[
"maintenance"
,
"state"
,
"ip_virtual"
]
def
get_nodes_properties
(
site_uid
,
site
)
def
get_nodes_properties
(
_
site_uid
,
site
)
properties
=
{}
site
[
'clusters'
].
sort
.
to_h
.
each
do
|
cluster_uid
,
cluster
|
cluster
[
'nodes'
].
sort
.
to_h
.
each
do
|
node_uid
,
node
|
...
...
lib/refrepo/gen/wiki/generators/site_hardware.rb
View file @
745dbbc1
...
...
@@ -33,7 +33,7 @@ class SiteHardwareGenerator < WikiGenerator
# remove retired nodes
# FIXME this should probably move to a helper
h
[
'clusters'
].
each_pair
do
|
cl
,
v
|
v
[
'nodes'
].
delete_if
{
|
n
,
v
|
v
[
'status'
]
==
'retired'
}
v
[
'nodes'
].
delete_if
{
|
n
,
v
2
|
v
2
[
'status'
]
==
'retired'
}
end
h
[
'clusters'
].
delete_if
{
|
k
,
v
|
v
[
'nodes'
].
empty?
}
...
...
@@ -136,6 +136,7 @@ class SiteHardwareGenerator < WikiGenerator
generated_content
=
"
\n
= Cluster details =
\n
"
generated_content
+=
text_data
.
join
(
"
\n
"
)
return
generated_content
end
end
...
...
lib/refrepo/gen/wiki/mw_utils.rb
View file @
745dbbc1
...
...
@@ -75,6 +75,7 @@ module G5K
i
+=
1
end
s
+=
']'
return
s
end
def
self
.
get_size
(
x
,
unit
=
'IEC'
)
...
...
lib/refrepo/gen/wiki/wiki_generator.rb
View file @
745dbbc1
...
...
@@ -12,7 +12,7 @@ class WikiGenerator
return
G5K
::
get_global_hash
end
def
login
(
options
)
def
login
(
_
options
)
tries
=
3
begin
conf
=
RefRepo
::
Utils
.
get_api_config
...
...
@@ -164,7 +164,7 @@ class WikiGenerator
end
opt_parse
.
parse!
if
(
!
options
[
:diff
]
&&
!
options
[
:print
]
&&
!
options
[
:update
])
puts
"ERROR: At least one action must be given! (--diff, --print, --update)
\n
#{
opt_parse
.
to_s
}
"
puts
"ERROR: At least one action must be given! (--diff, --print, --update)
\n
#{
opt_parse
}
"
exit
(
1
)
end
return
options
...
...
lib/refrepo/input_loader.rb
View file @
745dbbc1
...
...
@@ -26,7 +26,7 @@ def load_yaml_file_hierarchy(directory = File.expand_path("../../input/grid5000/
raise
Exception
.
new
(
"loaded hash is empty"
)
end
# YAML::Psych raises an exception if the file cannot be loaded.
rescue
Exception
=>
e
rescue
StandardError
=>
e
puts
"Error loading '
#{
filename
}
',
#{
e
.
message
}
"
end
...
...
lib/refrepo/valid/homogeneity.rb
View file @
745dbbc1
...
...
@@ -122,7 +122,6 @@ end
def
get_site_dead_nodes
(
site_uid
,
options
)
oarnodes
=
''
api_uri
=
URI
.
parse
(
'https://api.grid5000.fr/stable/sites/'
+
site_uid
+
'/internal/oarapi/resources/details.json?limit=999999'
)
# Download the OAR properties from the OAR API (through G5K API)
...
...
@@ -167,7 +166,6 @@ def cluster_homogeneity(refapi_hash, options = {:verbose => false})
ignore_keys
=
global_ignore_keys
()
cignore_keys
=
cluster_ignore_keys
(
File
.
expand_path
(
"data/homogeneity.yaml.erb"
,
File
.
dirname
(
__FILE__
)))
input_data_dir
=
"../../input/grid5000/"
count
=
{}
total_count
=
0
...
...
lib/refrepo/valid/input/duplicates.rb
View file @
745dbbc1
...
...
@@ -38,11 +38,11 @@ def yaml_input_find_duplicates(options)
site
[
"clusters"
].
sort
.
each
do
|
cluster_uid
,
cluster
|
if
options
.
key?
(
:clusters
)
&&
(
not
options
[
:clusters
].
empty?
)
&&
!
options
[
:clusters
].
include?
(
cluster_uid
)
site
[
"clusters"
].
delete
(
cluster_uid
)
site
[
"clusters"
].
delete
(
cluster_uid
)
end
cluster
[
"nodes"
].
sort
.
each
do
|
node_uid
,
node
|
if
node
.
key?
(
"status"
)
&&
node
[
"status"
]
==
"retired"
cluster
[
"nodes"
].
delete
(
node_uid
)
if
node
.
key?
(
"status"
)
&&
node
[
"status"
]
==
"retired"
cluster
[
"nodes"
].
delete
(
node_uid
)
end
end
end
...
...
lib/refrepo/valid/input/lib/custom_validators.rb
View file @
745dbbc1
...
...
@@ -8,7 +8,7 @@ class HashValidator::Validator::LinecardPortValidator < HashValidator::Validator
@port_properties
=
[
"uid"
,
"name"
,
"port"
,
"kind"
,
"mtu"
,
"rate"
,
"site"
,
"aggregation"
]
end
def
validate
(
key
,
values
,
validations
,
errors
)
def
validate
(
key
,
values
,
_
validations
,
errors
)
if
values
.
is_a?
(
Hash
)
values
.
each
do
|
k
,
v
|
if
@port_properties
.
index
(
k
)
==
nil
...
...
@@ -32,7 +32,7 @@ class HashValidator::Validator::IpAddressValidator < HashValidator::Validator::B
super
(
'ip_address'
)
end
def
validate
(
key
,
values
,
validations
,
errors
)
def
validate
(
key
,
values
,
_
validations
,
errors
)
if
values
.
is_a?
(
String
)
unless
(
values
=~
Resolv
::
IPv4
::
Regex
||
values
=~
Resolv
::
IPv6
::
Regex
)
errors
[
key
]
=
"Invalid ip address format
#{
values
}
"
...
...
lib/refrepo/valid/input/lib/schema_validator.rb
View file @
745dbbc1
...
...
@@ -66,7 +66,7 @@ end
# Monkey patching of the SimpleValidator to get more useful error messages
class
HashValidator::Validator::SimpleValidator
<
HashValidator
::
Validator
::
Base
def
validate
(
key
,
value
,
validations
,
errors
)
def
validate
(
key
,
value
,
_
validations
,
errors
)
unless
lambda
.
call
(
value
)
errors
[
key
]
=
"
#{
self
.
name
}
required (current value:
#{
value
.
class
}
:
#{
value
}
)"
end
...
...
@@ -78,4 +78,5 @@ def load_yaml_schema(filename)
schema
=
YAML
::
load_file
(
filename
)
schema
=
add_optional_validator
(
schema
)
schema
=
replace_validators_keys
(
schema
)
return
schema
end
lib/refrepo/valid/input/monitoring.rb
View file @
745dbbc1
...
...
@@ -55,7 +55,6 @@ def check_monitoring_properties(data)
data
[
'sites'
].
each
do
|
site_uid
,
site
|
site_pdus
=
{}
site_pdu_outlets
=
{}
metric_nodes
=
{}
node_monitoring_wattmeter
=
{}
# if site['clusters'].nil?
# return
...
...
lib/refrepo/valid/input/schema.rb
View file @
745dbbc1
require_relative
"./lib/schema_validator"
def
run_validator
(
uid
,
data
,
schema
)
validator
=
HashValidator
.
validate
(
data
,
schema
,
strict
=
true
)
validator
=
HashValidator
.
validate
(
data
,
schema
,
true
)
if
!
validator
.
valid?
errors
=
{
uid
=>
validator
.
errors
}
puts
errors
.
to_yaml
...
...
lib/refrepo/valid/oar-properties.rb
View file @
745dbbc1
...
...
@@ -102,7 +102,7 @@ module RefRepo::Valid::OarProperties
end
if
options
[
:verbose
]
and
(
host_cpusets_max
-
host_cpusets_min
+
1
!=
nbcores
or
host_cores_max
-
host_cores_min
+
1
!=
nbcores
)
puts
"id cpu core cpuset"
pp
host_resources
.
map
{
|
e
|
[
e
[
'id'
],
e
[
'cpu'
],
e
[
'core'
],
e
[
'cpuset'
]
]
}
pp
(
host_resources
.
map
{
|
e
|
[
e
[
'id'
],
e
[
'cpu'
],
e
[
'core'
],
e
[
'cpuset'
]
]
}
)
end
end
end
...
...
scripts/edit-input-files.rb
100644 → 100755
View file @
745dbbc1
...
...
@@ -61,7 +61,7 @@ else
end
##Modify node yaml hash here
def
modify_node_data
(
hash
,
node_uid
,
cluster_uid
,
site_uid
)
def
modify_node_data
(
hash
,
node_uid
,
cluster_uid
,
site_uid
)
#rubocop:disable Lint/UnusedMethodArgument
#example content:
hash
[
"network_adapters"
].
each
{
|
na_id
,
na
|
...
...
@@ -103,12 +103,12 @@ list_of_yaml_files.each { |filename|
write_yaml
(
new_filename
,
hash
)
contents
=
File
.
read
(
new_filename
)
File
.
open
(
new_filename
,
'w'
)
{
|
f
ile
|
f
ile
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
f
ile
.
write
(
contents
)
File
.
open
(
new_filename
,
'w'
)
{
|
f
d
|
f
d
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
f
d
.
write
(
contents
)
}
rescue
Exception
=>
e
rescue
StandardError
=>
e
puts
"
#{
node_uid
}
-
#{
e
.
class
}
:
#{
e
.
message
}
"
puts
e
.
backtrace
end
...
...
Prev
1
2
Next
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