Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
3c386718
Commit
3c386718
authored
Nov 07, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner_exporter: calculating signature can be done on groups of files
It decreases the number of subprocesses created.
parent
76b5e25f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
slapos/resilient/runner_exporter.py
slapos/resilient/runner_exporter.py
+24
-14
slapos/test/test_runner_exporter.py
slapos/test/test_runner_exporter.py
+1
-1
No files found.
slapos/resilient/runner_exporter.py
View file @
3c386718
...
...
@@ -134,11 +134,16 @@ def getExcludePathList(path):
return
excluded_path_list
def
getSha256Sum
(
file_path
):
hash_sum
=
sha256
()
for
chunk
in
read_file_by_chunk
(
file_path
):
hash_sum
.
update
(
chunk
)
return
hash_sum
.
hexdigest
()
def
getSha256Sum
(
file_path_list
):
result_list
=
[]
for
file_path
in
file_path_list
:
hash_sum
=
sha256
()
for
chunk
in
read_file_by_chunk
(
file_path
):
hash_sum
.
update
(
chunk
)
result_list
.
append
(
"%s %s"
%
(
hash_sum
.
hexdigest
(),
file_path
))
return
result_list
def
synchroniseRunnerConfigurationDirectory
(
config
,
backup_path
):
...
...
@@ -189,24 +194,29 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign
signature_list
=
[]
for
dirpath
,
dirname_list
,
filename_list
in
os
.
walk
(
'.'
):
if
dirpath
==
'.'
:
if
dirpath
==
'.'
or
not
filename_list
:
continue
# Find if special signature function should be applied
for
special_slappart
in
special_slappart_list
:
if
dirpath
.
startswith
(
special_slappart
):
signature_function
=
lambda
x
:
subprocess
.
check_output
([
os
.
path
.
join
(
runner_working_path
,
slappart_signature_method_dict
[
special_slappart
]),
x
])
# We have to rstrip as most programs return an empty line
# at the end of their output
signature_function
=
lambda
file_path_list
:
subprocess
.
check_output
(
[
os
.
path
.
join
(
runner_working_path
,
slappart_signature_method_dict
[
special_slappart
]),
]
+
file_path_list
).
rstrip
(
'
\
n
'
).
split
(
'
\
n
'
)
break
else
:
signature_function
=
getSha256Sum
# Calculate all signatures
for
filename
in
filename_list
:
file_path
=
os
.
path
.
join
(
dirpath
,
filename
)
signature_list
.
append
(
"%s %s"
%
(
signature_function
(
file_path
),
file_path
))
# Calculate the signature of all files in this directory
signature_list
.
extend
(
signature_function
([
os
.
path
.
join
(
dirpath
,
filename
)
for
filename
in
filename_list
])
)
# Write the signatures in file
with
open
(
signature_file_path
,
'w+'
)
as
signature_file
:
...
...
slapos/test/test_runner_exporter.py
View file @
3c386718
...
...
@@ -95,7 +95,7 @@ class TestRunnerExporter(unittest.TestCase):
self
.
_createExecutableFile
(
'instance/slappart1/srv/.backup_identity_script'
,
'#!/bin/bash
\
n
md5sum $
1 | cut -d " " -f 1 | tr -d "
\
n
"
'
'#!/bin/bash
\
n
md5sum $
*
'
)
...
...
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