Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
19
Merge Requests
19
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
d1e941b3
Commit
d1e941b3
authored
Oct 26, 2018
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
064ee487
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
17 deletions
+26
-17
slapos/cli/configure_local/__init__.py
slapos/cli/configure_local/__init__.py
+3
-2
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+5
-4
slapos/grid/svcbackend.py
slapos/grid/svcbackend.py
+3
-2
slapos/proxy/db_version.py
slapos/proxy/db_version.py
+2
-4
slapos/tests/slapproxy/__init__.py
slapos/tests/slapproxy/__init__.py
+5
-5
slapos/util.py
slapos/util.py
+8
-0
No files found.
slapos/cli/configure_local/__init__.py
View file @
d1e941b3
...
@@ -39,6 +39,7 @@ from slapos.cli.config import ConfigCommand
...
@@ -39,6 +39,7 @@ from slapos.cli.config import ConfigCommand
from
slapos.grid.slapgrid
import
create_slapgrid_object
from
slapos.grid.slapgrid
import
create_slapgrid_object
from
slapos.grid.utils
import
updateFile
,
createPrivateDirectory
from
slapos.grid.utils
import
updateFile
,
createPrivateDirectory
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.util
import
bytes2str
DEFAULT_COMPUTER_ID
=
'local_computer'
DEFAULT_COMPUTER_ID
=
'local_computer'
...
@@ -127,7 +128,7 @@ def _replaceParameterValue(original_content, to_replace):
...
@@ -127,7 +128,7 @@ def _replaceParameterValue(original_content, to_replace):
def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
template_arg_list = (__name__, '
..
/
..
/
slapos
.
cfg
.
example
')
template_arg_list = (__name__, '
..
/
..
/
slapos
.
cfg
.
example
')
slapos_node_configuration_template =
\
slapos_node_configuration_template =
\
pkg_resources.resource_string(*template_arg_list).decode('
utf
-
8
'
)
bytes2str(pkg_resources.resource_string(*template_arg_list)
)
master_url = '
http
:
//%
s
:
%
s
' % (args.daemon_listen_ip, args.daemon_listen_port)
master_url = '
http
:
//%
s
:
%
s
' % (args.daemon_listen_ip, args.daemon_listen_port)
slapos_home = args.slapos_buildout_directory
slapos_home = args.slapos_buildout_directory
to_replace = [
to_replace = [
...
@@ -154,7 +155,7 @@ def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
...
@@ -154,7 +155,7 @@ def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
def _generateSlaposProxyConfigurationFile(conf):
def _generateSlaposProxyConfigurationFile(conf):
template_arg_list = (__name__, '
..
/
..
/
slapos
-
proxy
.
cfg
.
example
')
template_arg_list = (__name__, '
..
/
..
/
slapos
-
proxy
.
cfg
.
example
')
slapos_proxy_configuration_template =
\
slapos_proxy_configuration_template =
\
pkg_resources.resource_string(*template_arg_list).decode('
utf
-
8
'
)
bytes2str(pkg_resources.resource_string(*template_arg_list)
)
slapos_proxy_configuration_path = os.path.join(
slapos_proxy_configuration_path = os.path.join(
conf.slapos_configuration_directory, '
slapos
-
proxy
.
cfg
')
conf.slapos_configuration_directory, '
slapos
-
proxy
.
cfg
')
listening_ip, listening_port =
\
listening_ip, listening_port =
\
...
...
slapos/grid/SlapObject.py
View file @
d1e941b3
...
@@ -51,6 +51,7 @@ from slapos.grid.exception import (BuildoutFailedError, WrongPermissionError,
...
@@ -51,6 +51,7 @@ from slapos.grid.exception import (BuildoutFailedError, WrongPermissionError,
PathDoesNotExistError
,
DiskSpaceError
)
PathDoesNotExistError
,
DiskSpaceError
)
from
slapos.grid.networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.grid.networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.human
import
bytes2human
from
slapos.human
import
bytes2human
from
slapos.util
import
bytes2str
WATCHDOG_MARK
=
'-on-watch'
WATCHDOG_MARK
=
'-on-watch'
...
@@ -481,8 +482,8 @@ class Partition(object):
...
@@ -481,8 +482,8 @@ class Partition(object):
}
}
def
addCustomGroup
(
self
,
group_suffix
,
partition_id
,
program_list
):
def
addCustomGroup
(
self
,
group_suffix
,
partition_id
,
program_list
):
group_partition_template
=
pkg_resources
.
resource_string
(
__name__
,
group_partition_template
=
bytes2str
(
pkg_resources
.
resource_string
(
__name__
,
'templates/group_partition_supervisord.conf.in'
)
.
decode
(
'utf-8'
)
'templates/group_partition_supervisord.conf.in'
))
group_id
=
'{}-{}'
.
format
(
partition_id
,
group_suffix
)
group_id
=
'{}-{}'
.
format
(
partition_id
,
group_suffix
)
self
.
supervisor_configuration_group
+=
group_partition_template
%
{
self
.
supervisor_configuration_group
+=
group_partition_template
%
{
...
@@ -568,8 +569,8 @@ class Partition(object):
...
@@ -568,8 +569,8 @@ class Partition(object):
# fill generated buildout with additional information
# fill generated buildout with additional information
buildout_text
=
open
(
config_location
).
read
()
buildout_text
=
open
(
config_location
).
read
()
buildout_text
+=
'
\
n
\
n
'
+
pkg_resources
.
resource_string
(
__name__
,
buildout_text
+=
'
\
n
\
n
'
+
bytes2str
(
pkg_resources
.
resource_string
(
__name__
,
'templates/buildout-tail.cfg.in'
)
.
decode
(
'utf-8'
)
%
{
'templates/buildout-tail.cfg.in'
))
%
{
'computer_id'
:
self
.
computer_id
,
'computer_id'
:
self
.
computer_id
,
'partition_id'
:
self
.
partition_id
,
'partition_id'
:
self
.
partition_id
,
'server_url'
:
self
.
server_url
,
'server_url'
:
self
.
server_url
,
...
...
slapos/grid/svcbackend.py
View file @
d1e941b3
...
@@ -38,6 +38,7 @@ import time
...
@@ -38,6 +38,7 @@ import time
from
six.moves
import
xmlrpc_client
as
xmlrpclib
from
six.moves
import
xmlrpc_client
as
xmlrpclib
from
slapos.grid.utils
import
(
createPrivateDirectory
,
SlapPopen
,
updateFile
)
from
slapos.grid.utils
import
(
createPrivateDirectory
,
SlapPopen
,
updateFile
)
from
slapos.util
import
bytes2str
from
supervisor
import
xmlrpc
,
states
from
supervisor
import
xmlrpc
,
states
...
@@ -89,8 +90,8 @@ def createSupervisordConfiguration(instance_root, watchdog_command=''):
...
@@ -89,8 +90,8 @@ def createSupervisordConfiguration(instance_root, watchdog_command=''):
# Creates supervisord configuration
# Creates supervisord configuration
updateFile
(
supervisord_configuration_file_path
,
updateFile
(
supervisord_configuration_file_path
,
pkg_resources
.
resource_string
(
__name__
,
bytes2str
(
pkg_resources
.
resource_string
(
__name__
,
'templates/supervisord.conf.in'
)
.
decode
(
'utf-8'
)
%
{
'templates/supervisord.conf.in'
))
%
{
'supervisord_configuration_directory'
:
supervisord_configuration_directory
,
'supervisord_configuration_directory'
:
supervisord_configuration_directory
,
'supervisord_socket'
:
os
.
path
.
abspath
(
supervisord_socket
),
'supervisord_socket'
:
os
.
path
.
abspath
(
supervisord_socket
),
'supervisord_loglevel'
:
'info'
,
'supervisord_loglevel'
:
'info'
,
...
...
slapos/proxy/db_version.py
View file @
d1e941b3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
pkg_resources
import
pkg_resources
from
slapos.util
import
bytes2str
DB_VERSION
=
pkg_resources
.
resource_stream
(
'slapos.proxy'
,
'schema.sql'
).
readline
().
strip
().
split
(
b':'
)[
1
]
DB_VERSION
=
bytes2str
(
pkg_resources
.
resource_stream
(
'slapos.proxy'
,
'schema.sql'
).
readline
().
strip
().
split
(
b':'
)[
1
])
import
six
if
six
.
PY3
:
DB_VERSION
=
DB_VERSION
.
decode
(
'utf-8'
)
slapos/tests/slapproxy/__init__.py
View file @
d1e941b3
...
@@ -46,7 +46,7 @@ import slapos.proxy
...
@@ -46,7 +46,7 @@ import slapos.proxy
import
slapos.proxy.views
as
views
import
slapos.proxy.views
as
views
import
slapos.slap
import
slapos.slap
import
slapos.slap.slap
import
slapos.slap.slap
from
slapos.util
import
sqlite_connect
from
slapos.util
import
sqlite_connect
,
bytes2str
import
sqlite3
import
sqlite3
import
pkg_resources
import
pkg_resources
...
@@ -1055,9 +1055,9 @@ database_uri = %(tempdir)s/lib/external_proxy.db
...
@@ -1055,9 +1055,9 @@ database_uri = %(tempdir)s/lib/external_proxy.db
Overwrite default slapos configuration file to enable specific multimaster
Overwrite default slapos configuration file to enable specific multimaster
behaviours.
behaviours.
"""
"""
configuration
=
pkg_resources
.
resource_string
(
configuration
=
bytes2str
(
pkg_resources
.
resource_string
(
'slapos.tests.slapproxy'
,
'slapos_multimaster.cfg.in'
'slapos.tests.slapproxy'
,
'slapos_multimaster.cfg.in'
)
.
decode
(
'utf-8'
)
%
{
))
%
{
'tempdir'
:
self
.
_tempdir
,
'proxyaddr'
:
self
.
proxyaddr
,
'tempdir'
:
self
.
_tempdir
,
'proxyaddr'
:
self
.
proxyaddr
,
'external_proxy_host'
:
self
.
external_proxy_host
,
'external_proxy_host'
:
self
.
external_proxy_host
,
'external_proxy_port'
:
self
.
external_proxy_port
'external_proxy_port'
:
self
.
external_proxy_port
...
@@ -1272,10 +1272,10 @@ class TestMigrateVersion10To11(TestInformation, TestRequest, TestSlaveRequest, T
...
@@ -1272,10 +1272,10 @@ class TestMigrateVersion10To11(TestInformation, TestRequest, TestSlaveRequest, T
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestMigrateVersion10To11
,
self
).
setUp
()
super
(
TestMigrateVersion10To11
,
self
).
setUp
()
schema
=
pkg_resources
.
resource_string
(
schema
=
bytes2str
(
pkg_resources
.
resource_string
(
'slapos.tests.slapproxy'
,
'slapos.tests.slapproxy'
,
'database_dump_version_10.sql'
'database_dump_version_10.sql'
)
.
decode
(
'utf-8'
)
%
dict
(
version
=
'11'
)
))
%
dict
(
version
=
'11'
)
self
.
db
=
sqlite_connect
(
self
.
proxy_db
)
self
.
db
=
sqlite_connect
(
self
.
proxy_db
)
self
.
db
.
cursor
().
executescript
(
schema
)
self
.
db
.
cursor
().
executescript
(
schema
)
self
.
db
.
commit
()
self
.
db
.
commit
()
...
...
slapos/util.py
View file @
d1e941b3
...
@@ -99,3 +99,11 @@ def sqlite_connect(dburi, timeout=None):
...
@@ -99,3 +99,11 @@ def sqlite_connect(dburi, timeout=None):
conn
=
sqlite3
.
connect
(
dburi
,
**
connect_kw
)
conn
=
sqlite3
.
connect
(
dburi
,
**
connect_kw
)
conn
.
text_factory
=
str
# allow 8-bit strings
conn
.
text_factory
=
str
# allow 8-bit strings
return
conn
return
conn
if
str
is
bytes
:
def
bytes2str
(
s
):
return
s
else
:
def
bytes2str
(
s
):
return
s
.
decode
()
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