Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
slapos
Commits
96ae404d
Commit
96ae404d
authored
Jan 29, 2020
by
Bryton Lacquement
🚪
Committed by
Julien Muchembled
Mar 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recipes: more py3 fixes
parent
77934993
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
25 additions
and
17 deletions
+25
-17
slapos/recipe/certificate_authority/__init__.py
slapos/recipe/certificate_authority/__init__.py
+2
-1
slapos/recipe/certificate_authority/certificate_authority.py
slapos/recipe/certificate_authority/certificate_authority.py
+2
-1
slapos/recipe/free_port.py
slapos/recipe/free_port.py
+2
-1
slapos/recipe/notifier.py
slapos/recipe/notifier.py
+2
-1
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+1
-1
slapos/recipe/promise_plugin.py
slapos/recipe/promise_plugin.py
+1
-1
slapos/recipe/random.py
slapos/recipe/random.py
+2
-1
slapos/recipe/softwaretype.py
slapos/recipe/softwaretype.py
+9
-8
slapos/recipe/sshkeys_authority.py
slapos/recipe/sshkeys_authority.py
+2
-1
slapos/recipe/switch_softwaretype.py
slapos/recipe/switch_softwaretype.py
+2
-1
No files found.
slapos/recipe/certificate_authority/__init__.py
View file @
96ae404d
...
...
@@ -30,6 +30,7 @@ from six.moves import configparser
import
tempfile
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.util
import
str2bytes
from
.certificate_authority
import
popenCommunicate
class
Recipe
(
GenericBaseRecipe
):
...
...
@@ -108,7 +109,7 @@ class Request(Recipe):
request_needed
=
True
name
=
self
.
options
[
'name'
]
hash_
=
hashlib
.
sha512
(
name
).
hexdigest
()
hash_
=
hashlib
.
sha512
(
str2bytes
(
name
)
).
hexdigest
()
key
=
os
.
path
.
join
(
self
.
ca_private
,
hash_
+
self
.
ca_key_ext
)
certificate
=
os
.
path
.
join
(
self
.
ca_certs
,
hash_
+
self
.
ca_crt_ext
)
...
...
slapos/recipe/certificate_authority/certificate_authority.py
View file @
96ae404d
...
...
@@ -8,7 +8,8 @@ import uuid
def
popenCommunicate
(
command_list
,
input
=
None
):
subprocess_kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
subprocess_kw
=
dict
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
universal_newlines
=
True
)
if
input
is
not
None
:
subprocess_kw
.
update
(
stdin
=
subprocess
.
PIPE
)
popen
=
subprocess
.
Popen
(
command_list
,
**
subprocess_kw
)
...
...
slapos/recipe/free_port.py
View file @
96ae404d
...
...
@@ -29,6 +29,7 @@ from six.moves import configparser
import
os
import
netaddr
import
socket
from
six.moves
import
range
class
Recipe
(
object
):
"""
...
...
@@ -89,7 +90,7 @@ class Recipe(object):
This algorithm thus returns always the same value with the same parameters in
a standard environment.
"""
for
port
in
x
range
(
self
.
minimum
,
self
.
maximum
):
for
port
in
range
(
self
.
minimum
,
self
.
maximum
):
sock
=
socket
.
socket
(
self
.
inet_family
,
socket
.
SOCK_STREAM
)
try
:
sock
.
bind
((
self
.
ip
,
port
))
...
...
slapos/recipe/notifier.py
View file @
96ae404d
...
...
@@ -27,6 +27,7 @@
import
os
from
hashlib
import
sha512
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.util
import
str2bytes
class
Recipe
(
GenericBaseRecipe
):
...
...
@@ -49,7 +50,7 @@ class Callback(GenericBaseRecipe):
# XXX: hashing the name here and in
# slapos.toolbox/slapos/pubsub/__init__.py is completely messed up and
# prevent any debug.
callback_id
=
sha512
(
notification_id
).
hexdigest
()
callback_id
=
sha512
(
str2bytes
(
notification_id
)
).
hexdigest
()
filepath
=
os
.
path
.
join
(
self
.
options
[
'callbacks'
],
callback_id
)
self
.
addLineToFile
(
filepath
,
callback
)
...
...
slapos/recipe/pbs.py
View file @
96ae404d
...
...
@@ -46,7 +46,7 @@ def promise(ssh_client, user, host, port):
with
open
(
os
.
devnull
)
as
_dev_null
:
ssh
=
subprocess
.
Popen
(
(
ssh_client
,
'%s@%s'
%
(
user
,
host
),
'-p'
,
str
(
port
)),
stdin
=
subprocess
.
PIPE
,
stdout
=
_dev_null
)
stdin
=
subprocess
.
PIPE
,
stdout
=
_dev_null
,
universal_newlines
=
True
)
ssh
.
communicate
(
'q'
+
chr
(
255
)
+
chr
(
0
)
*
7
)
if
ssh
.
returncode
:
sys
.
stderr
.
write
(
"SSH Connection failed
\
n
"
)
...
...
slapos/recipe/promise_plugin.py
View file @
96ae404d
...
...
@@ -47,7 +47,7 @@ extra_config_dict = %(config)s
# The solution is to delete all cached 'slapos' modules as well as all cached
# 'pkg_resources' modules which is responsible of namespace declaration.
# They will be re-imported again using the updated sys.path
for module in
sys.modules.keys(
):
for module in
list(sys.modules
):
if 'slapos' in module or 'pkg_resources' in module:
del sys.modules[module]
...
...
slapos/recipe/random.py
View file @
96ae404d
...
...
@@ -38,6 +38,7 @@ import random
import
string
from
.librecipe
import
GenericBaseRecipe
from
.publish_early
import
volatileOptions
from
slapos.util
import
str2bytes
class
Integer
(
object
):
"""
...
...
@@ -174,7 +175,7 @@ class Password(object):
fd
=
os
.
open
(
self
.
storage_path
,
os
.
O_CREAT
|
os
.
O_EXCL
|
os
.
O_WRONLY
|
os
.
O_TRUNC
,
0o600
)
try
:
os
.
write
(
fd
,
s
elf
.
passwd
)
os
.
write
(
fd
,
s
tr2bytes
(
self
.
passwd
)
)
finally
:
os
.
close
(
fd
)
if
not
self
.
create_once
:
...
...
slapos/recipe/softwaretype.py
View file @
96ae404d
...
...
@@ -28,7 +28,7 @@
import
os
import
sys
import
copy
from
ConfigP
arser
import
ConfigParser
from
six.moves.configp
arser
import
ConfigParser
import
json
import
subprocess
import
slapos.slap
...
...
@@ -38,6 +38,7 @@ import errno
import
re
import
zc.buildout
import
six
class
SlapConfigParser
(
ConfigParser
,
object
):
"""
...
...
@@ -57,9 +58,6 @@ class SlapConfigParser(ConfigParser, object):
def
write
(
self
,
fp
):
"""Write an .ini-format representation of the configuration state."""
if
sys
.
version_info
[
0
]
>
2
:
return
super
(
SlapConfigParser
,
self
).
write
(
fp
)
regex
=
re
.
compile
(
r'^(.*)\
s+([+-]{
1})$'
)
if
self
.
_defaults
:
fp
.
write
(
"[%s]
\
n
"
%
DEFAULTSECT
)
...
...
@@ -138,9 +136,9 @@ class Recipe:
for
name
,
ip
in
self
.
parameter_dict
[
'ip_list'
]:
if
name
:
return
name
raise
AttributeError
,
"Not network interface found"
raise
AttributeError
(
"Not network interface found"
)
def
mkdir_p
(
self
,
path
,
mode
=
0700
):
def
mkdir_p
(
self
,
path
,
mode
=
0
o
700
):
"""
Creates a directory and its parents, if needed.
NB: If the directory already exists, it does not change its permission.
...
...
@@ -193,6 +191,9 @@ class Recipe:
raise
zc
.
buildout
.
UserError
(
"The specified buildout config file %r does "
"not exist."
%
instance_file_path
)
if
six
.
PY3
:
buildout
=
SlapConfigParser
(
strict
=
False
)
else
:
buildout
=
SlapConfigParser
()
with
open
(
instance_file_path
)
as
instance_path
:
buildout
.
readfp
(
instance_path
)
...
...
@@ -231,7 +232,7 @@ class Recipe:
# Copy/paste slap_connection
buildout
.
add_section
(
'slap-connection'
)
for
key
,
value
in
s
elf
.
buildout
[
'slap_connection'
].
iteritems
(
):
for
key
,
value
in
s
ix
.
iteritems
(
self
.
buildout
[
'slap_connection'
]
):
# XXX: Waiting for SlapBaseRecipe to use dash instead of underscores
buildout
.
set
(
'slap-connection'
,
key
.
replace
(
'_'
,
'-'
),
value
)
# XXX: Needed for lxc. Use non standard API
...
...
slapos/recipe/sshkeys_authority.py
View file @
96ae404d
...
...
@@ -32,6 +32,7 @@ import re
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe.inotify
import
subfiles
from
slapos.util
import
str2bytes
# This authority only works with dropbear or openssh sshkey generators
def
sshkeys_authority
(
request_directory
,
keygen_binary
):
...
...
@@ -112,7 +113,7 @@ class Request(GenericBaseRecipe):
keys_directory
=
options
[
'keys-directory'
]
self
.
private_key
=
os
.
path
.
join
(
keys_directory
,
hashlib
.
sha256
(
options
[
'name'
]
).
hexdigest
())
hashlib
.
sha256
(
str2bytes
(
options
[
'name'
])
).
hexdigest
())
self
.
public_key
=
self
.
private_key
+
'.pub'
options
[
'public-key-value'
]
=
''
...
...
slapos/recipe/switch_softwaretype.py
View file @
96ae404d
...
...
@@ -26,6 +26,7 @@
##############################################################################
import
os
,
subprocess
,
sys
import
six
class
Recipe
:
...
...
@@ -41,7 +42,7 @@ class Recipe:
# XXX-Antoine: We gotta find a better way to do this. I tried to check
# out how slapgrid-cp was running buildout. But it is worse than that.
args
=
sys
.
argv
[:]
for
x
in
s
elf
.
buildout
[
"slap-connection"
].
iteritems
(
):
for
x
in
s
ix
.
iteritems
(
self
.
buildout
[
"slap-connection"
]
):
args
.
append
(
"slap-connection:%s=%s"
%
x
)
for
x
in
"directory"
,
"eggs-directory"
,
"develop-eggs-directory"
:
args
.
append
(
"buildout:%s=%s"
%
(
x
,
self
.
buildout
[
"buildout"
][
x
]))
...
...
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