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
4f7a4e1b
Commit
4f7a4e1b
authored
Nov 08, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner_exporter: communicate with signature sub process by using stdin
parent
e6b3de84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
24 deletions
+39
-24
slapos/resilient/runner_exporter.py
slapos/resilient/runner_exporter.py
+38
-23
slapos/test/test_runner_exporter.py
slapos/test/test_runner_exporter.py
+1
-1
No files found.
slapos/resilient/runner_exporter.py
View file @
4f7a4e1b
...
...
@@ -200,32 +200,47 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign
# Find if special signature function should be applied
for
special_slappart
in
special_slappart_list
:
backup_identity_script_path
=
os
.
path
.
join
(
runner_working_path
,
slappart_signature_method_dict
[
special_slappart
]
)
if
dirpath
.
startswith
(
special_slappart
):
signature_process
=
subprocess
.
Popen
(
backup_identity_script_path
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
)
for
filename
in
filename_list
:
signature_process
.
stdin
.
write
(
os
.
path
.
join
(
dirpath
,
filename
)
+
'
\
0
'
)
signature_process
.
stdin
.
close
()
output
=
signature_process
.
stdout
.
read
()
while
signature_process
.
poll
()
is
None
:
time
.
sleep
(
1
)
output
+=
signature_process
.
stdout
.
read
()
output
+=
signature_process
.
stdout
.
read
()
if
signature_process
.
returncode
!=
0
:
print
(
"An issue occured when calculating the custom signature"
" with %s :
\
n
%s"
%
(
backup_identity_script_path
,
signature_process
.
stderr
.
read
()
)
)
system
.
exit
(
1
)
# 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 the signature of all files in this directory
# The number of files passed to the signature function is
# hardcoded in max_argument_number
max_argument_number
=
10
file_list_generator
=
(
os
.
path
.
join
(
dirpath
,
filename
)
for
filename
in
filename_list
)
arg_list
=
[
file_list_generator
]
*
max_argument_number
for
file_list
in
itertools
.
izip_longest
(
*
arg_list
):
# izip_longest fills with None
file_list
=
[
x
for
x
in
file_list
if
x
]
signature_list
.
extend
(
signature_function
(
file_list
)
)
signature_list
.
extend
(
output
.
strip
(
'
\
n
'
).
split
(
'
\
n
'
))
else
:
signature_list
.
extend
(
getSha256Sum
([
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 @
4f7a4e1b
...
...
@@ -96,7 +96,7 @@ class TestRunnerExporter(unittest.TestCase):
self
.
_createExecutableFile
(
'instance/slappart1/srv/.backup_identity_script'
,
'#!/bin/bash
\
n
md5sum $*'
"#!/bin/sh
\
n
exec xargs -0 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