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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
0f8706b4
Commit
0f8706b4
authored
Jan 19, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: Create supervisor configuration when running CLI.
Also move and simplify management of configuration files.
parent
04864195
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
144 additions
and
137 deletions
+144
-137
slapos/cli/configure_local/__init__.py
slapos/cli/configure_local/__init__.py
+1
-13
slapos/cli/supervisorctl.py
slapos/cli/supervisorctl.py
+7
-11
slapos/cli/supervisord.py
slapos/cli/supervisord.py
+6
-8
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+17
-68
slapos/grid/svcbackend.py
slapos/grid/svcbackend.py
+78
-4
slapos/grid/templates/supervisord.conf.in
slapos/grid/templates/supervisord.conf.in
+1
-0
slapos/tests/configure_local.py
slapos/tests/configure_local.py
+1
-2
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+33
-31
No files found.
slapos/cli/configure_local/__init__.py
View file @
0f8706b4
...
@@ -245,17 +245,6 @@ def do_configure(args, fetch_config_func, logger):
...
@@ -245,17 +245,6 @@ def do_configure(args, fetch_config_func, logger):
configp = fetch_config_func(args)
configp = fetch_config_func(args)
conf = FormatConfig(logger=logger)
conf = FormatConfig(logger=logger)
conf.mergeConfig(args, configp)
conf.mergeConfig(args, configp)
supervisord_socket_path = os.path.join(conf.instance_root,
'
supervisord
.
socket
')
supervisord_conf_path = os.path.join(conf.instance_root,
'
etc
', '
supervisord
.
conf
')
conf_property_list = (
('
supervisord_socket
', supervisord_socket_path),
('
supervisord_configuration_path
', supervisord_conf_path),
)
for key, value in conf_property_list:
if not getattr(conf, key, None):
setattr(conf, key, value)
slapgrid = create_slapgrid_object(conf.__dict__, logger)
slapgrid = create_slapgrid_object(conf.__dict__, logger)
createPrivateDirectory(os.path.join(conf.slapos_buildout_directory, '
log
'))
createPrivateDirectory(os.path.join(conf.slapos_buildout_directory, '
log
'))
_runFormat(conf.slapos_buildout_directory)
_runFormat(conf.slapos_buildout_directory)
...
@@ -268,7 +257,6 @@ def do_configure(args, fetch_config_func, logger):
...
@@ -268,7 +257,6 @@ def do_configure(args, fetch_config_func, logger):
slapos_client_cfg_path = '
%
s
/
.
slapos
/
slapos
-
client
.
cfg
' % home_folder_path
slapos_client_cfg_path = '
%
s
/
.
slapos
/
slapos
-
client
.
cfg
' % home_folder_path
if not os.path.exists(slapos_client_cfg_path):
if not os.path.exists(slapos_client_cfg_path):
os.symlink(slapos_node_config_path, slapos_client_cfg_path)
os.symlink(slapos_node_config_path, slapos_client_cfg_path)
launchSupervisord(socket=supervisord_socket_path,
launchSupervisord(instance_root=conf.instance_root, logger=logger)
configuration_file=supervisord_conf_path, logger=logger)
_runFormat(conf.slapos_buildout_directory)
_runFormat(conf.slapos_buildout_directory)
return 0
return 0
slapos/cli/supervisorctl.py
View file @
0f8706b4
...
@@ -28,13 +28,10 @@
...
@@ -28,13 +28,10 @@
##############################################################################
##############################################################################
import
argparse
import
argparse
import
os
from
slapos.cli.command
import
check_root_user
from
slapos.cli.command
import
check_root_user
from
slapos.cli.config
import
ConfigCommand
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.svcbackend
import
(
launchSupervisord
,
_getSupervisordConfigurationFilePath
)
from
slapos.util
import
string_to_boolean
import
supervisor.supervisorctl
import
supervisor.supervisorctl
...
@@ -54,7 +51,7 @@ class SupervisorctlCommand(ConfigCommand):
...
@@ -54,7 +51,7 @@ class SupervisorctlCommand(ConfigCommand):
def
_should_check_current_user_is_root
(
self
,
configp
):
def
_should_check_current_user_is_root
(
self
,
configp
):
if
not
configp
.
has_option
(
'slapos'
,
'root_check'
):
if
not
configp
.
has_option
(
'slapos'
,
'root_check'
):
return
True
return
True
return
configp
.
getboolean
(
'slapos'
,
'root_check'
)
return
configp
.
getboolean
(
'slapos'
,
'root_check'
)
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
...
@@ -63,14 +60,13 @@ class SupervisorctlCommand(ConfigCommand):
...
@@ -63,14 +60,13 @@ class SupervisorctlCommand(ConfigCommand):
# Parse if we have to check if running from root
# Parse if we have to check if running from root
# XXX document this feature.
# XXX document this feature.
if
self
.
_should_check_current_user_is_root
(
configp
):
if
self
.
_should_check_current_user_is_root
(
configp
):
check_root_user
(
self
)
check_root_user
(
self
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
configuration_file
=
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf'
)
launchSupervisord
(
instance_root
=
instance_root
,
logger
=
self
.
app
.
log
)
launchSupervisord
(
socket
=
os
.
path
.
join
(
instance_root
,
'supervisord.socket'
),
supervisor
.
supervisorctl
.
main
(
configuration_file
=
configuration_file
,
args
=
[
'-c'
,
_getSupervisordConfigurationFilePath
(
instance_root
)]
+
args
.
supervisor_args
logger
=
self
.
app
.
log
)
)
supervisor
.
supervisorctl
.
main
(
args
=
[
'-c'
,
configuration_file
]
+
args
.
supervisor_args
)
class
SupervisorctlAliasCommand
(
SupervisorctlCommand
):
class
SupervisorctlAliasCommand
(
SupervisorctlCommand
):
...
...
slapos/cli/supervisord.py
View file @
0f8706b4
...
@@ -27,11 +27,8 @@
...
@@ -27,11 +27,8 @@
#
#
##############################################################################
##############################################################################
import
os
from
slapos.cli.config
import
ConfigCommand
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.svcbackend
import
(
launchSupervisord
,
createSupervisordConfiguration
)
class
SupervisordCommand
(
ConfigCommand
):
class
SupervisordCommand
(
ConfigCommand
):
"""
"""
...
@@ -54,7 +51,8 @@ class SupervisordCommand(ConfigCommand):
...
@@ -54,7 +51,8 @@ class SupervisordCommand(ConfigCommand):
supervisord_additional_argument_list
=
[
'--nodaemon'
]
supervisord_additional_argument_list
=
[
'--nodaemon'
]
else
:
else
:
supervisord_additional_argument_list
=
[]
supervisord_additional_argument_list
=
[]
launchSupervisord
(
socket
=
os
.
path
.
join
(
instance_root
,
'supervisord.socket'
),
createSupervisordConfiguration
(
instance_root
)
configuration_file
=
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf'
),
launchSupervisord
(
logger
=
self
.
app
.
log
,
instance_root
=
instance_root
,
logger
=
self
.
app
.
log
,
supervisord_additional_argument_list
=
supervisord_additional_argument_list
)
supervisord_additional_argument_list
=
supervisord_additional_argument_list
)
slapos/grid/slapgrid.py
View file @
0f8706b4
...
@@ -37,7 +37,6 @@ import subprocess
...
@@ -37,7 +37,6 @@ import subprocess
import
sys
import
sys
import
tempfile
import
tempfile
import
time
import
time
import
stat
import
traceback
import
traceback
import
warnings
import
warnings
import
logging
import
logging
...
@@ -53,9 +52,11 @@ from slapos.slap.slap import ServerError
...
@@ -53,9 +52,11 @@ from slapos.slap.slap import ServerError
from
slapos.util
import
mkdir_p
,
chownDirectory
from
slapos.util
import
mkdir_p
,
chownDirectory
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.exception
import
BuildoutFailedError
from
slapos.grid.SlapObject
import
Software
,
Partition
from
slapos.grid.SlapObject
import
Software
,
Partition
from
slapos.grid.svcbackend
import
launchSupervisord
from
slapos.grid.svcbackend
import
(
launchSupervisord
,
from
slapos.grid.utils
import
(
md5digest
,
createPrivateDirectory
,
dropPrivileges
,
createSupervisordConfiguration
,
SlapPopen
,
updateFile
)
_getSupervisordConfigurationDirectory
,
_getSupervisordSocketPath
)
from
slapos.grid.utils
import
(
md5digest
,
dropPrivileges
,
SlapPopen
)
from
slapos.human
import
human2bytes
from
slapos.human
import
human2bytes
import
slapos.slap
import
slapos.slap
...
@@ -71,12 +72,12 @@ SLAPGRID_FAIL = 1
...
@@ -71,12 +72,12 @@ SLAPGRID_FAIL = 1
SLAPGRID_PROMISE_FAIL
=
2
SLAPGRID_PROMISE_FAIL
=
2
PROMISE_TIMEOUT
=
3
PROMISE_TIMEOUT
=
3
# XXX hardcoded watchdog_path
WATCHDOG_PATH
=
'/opt/slapos/bin/slapos-watchdog'
COMPUTER_PARTITION_TIMESTAMP_FILENAME
=
'.timestamp'
COMPUTER_PARTITION_TIMESTAMP_FILENAME
=
'.timestamp'
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
=
'.slapos_latest_bang_timestamp'
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
=
'.slapos_latest_bang_timestamp'
# XXX hardcoded watchdog_path
WATCHDOG_PATH
=
'/opt/slapos/bin/slapos-watchdog'
class
_formatXMLError
(
Exception
):
class
_formatXMLError
(
Exception
):
pass
pass
...
@@ -149,15 +150,6 @@ def merged_options(args, configp):
...
@@ -149,15 +150,6 @@ def merged_options(args, configp):
if
options
.
get
(
'all'
):
if
options
.
get
(
'all'
):
options
[
'develop'
]
=
True
options
[
'develop'
]
=
True
# Supervisord configuration location
if
not
options
.
get
(
'supervisord_configuration_path'
):
options
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
# Supervisord socket
if
not
options
.
get
(
'supervisord_socket'
):
options
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'supervisord.socket'
)
# Parse cache / binary cache options
# Parse cache / binary cache options
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
if
(
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
if
(
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
...
@@ -209,8 +201,6 @@ def create_slapgrid_object(options, logger):
...
@@ -209,8 +201,6 @@ def create_slapgrid_object(options, logger):
instance_root
=
op
[
'instance_root'
],
instance_root
=
op
[
'instance_root'
],
master_url
=
op
[
'master_url'
],
master_url
=
op
[
'master_url'
],
computer_id
=
op
[
'computer_id'
],
computer_id
=
op
[
'computer_id'
],
supervisord_socket
=
op
[
'supervisord_socket'
],
supervisord_configuration_path
=
op
[
'supervisord_configuration_path'
],
buildout
=
op
.
get
(
'buildout'
),
buildout
=
op
.
get
(
'buildout'
),
logger
=
logger
,
logger
=
logger
,
maximum_periodicity
=
op
.
get
(
'maximum_periodicity'
,
86400
),
maximum_periodicity
=
op
.
get
(
'maximum_periodicity'
,
86400
),
...
@@ -267,8 +257,6 @@ class Slapgrid(object):
...
@@ -267,8 +257,6 @@ class Slapgrid(object):
instance_root
,
instance_root
,
master_url
,
master_url
,
computer_id
,
computer_id
,
supervisord_socket
,
supervisord_configuration_path
,
buildout
,
buildout
,
logger
,
logger
,
maximum_periodicity
=
86400
,
maximum_periodicity
=
86400
,
...
@@ -303,8 +291,7 @@ class Slapgrid(object):
...
@@ -303,8 +291,7 @@ class Slapgrid(object):
self
.
instance_root
=
os
.
path
.
abspath
(
instance_root
)
self
.
instance_root
=
os
.
path
.
abspath
(
instance_root
)
self
.
master_url
=
master_url
self
.
master_url
=
master_url
self
.
computer_id
=
computer_id
self
.
computer_id
=
computer_id
self
.
supervisord_socket
=
supervisord_socket
self
.
supervisord_socket
=
_getSupervisordSocketPath
(
instance_root
)
self
.
supervisord_configuration_path
=
supervisord_configuration_path
self
.
key_file
=
key_file
self
.
key_file
=
key_file
self
.
cert_file
=
cert_file
self
.
cert_file
=
cert_file
self
.
master_ca_file
=
master_ca_file
self
.
master_ca_file
=
master_ca_file
...
@@ -332,8 +319,6 @@ class Slapgrid(object):
...
@@ -332,8 +319,6 @@ class Slapgrid(object):
cert_file
=
self
.
cert_file
,
master_ca_file
=
self
.
master_ca_file
)
cert_file
=
self
.
cert_file
,
master_ca_file
=
self
.
master_ca_file
)
self
.
computer
=
self
.
slap
.
registerComputer
(
self
.
computer_id
)
self
.
computer
=
self
.
slap
.
registerComputer
(
self
.
computer_id
)
# Defines all needed paths
# Defines all needed paths
self
.
supervisord_configuration_directory
=
\
os
.
path
.
join
(
self
.
instance_root
,
'etc'
,
'supervisord.conf.d'
)
self
.
buildout
=
buildout
self
.
buildout
=
buildout
self
.
promise_timeout
=
promise_timeout
self
.
promise_timeout
=
promise_timeout
self
.
develop
=
develop
self
.
develop
=
develop
...
@@ -350,7 +335,7 @@ class Slapgrid(object):
...
@@ -350,7 +335,7 @@ class Slapgrid(object):
self
.
software_min_free_space
=
software_min_free_space
self
.
software_min_free_space
=
software_min_free_space
self
.
instance_min_free_space
=
instance_min_free_space
self
.
instance_min_free_space
=
instance_min_free_space
def
getWatchdogLine
(
self
):
def
_
getWatchdogLine
(
self
):
invocation_list
=
[
WATCHDOG_PATH
]
invocation_list
=
[
WATCHDOG_PATH
]
invocation_list
.
append
(
"--master-url '%s' "
%
self
.
master_url
)
invocation_list
.
append
(
"--master-url '%s' "
%
self
.
master_url
)
if
self
.
certificate_repository_path
:
if
self
.
certificate_repository_path
:
...
@@ -367,42 +352,11 @@ class Slapgrid(object):
...
@@ -367,42 +352,11 @@ class Slapgrid(object):
# Checks for software_root and instance_root existence
# Checks for software_root and instance_root existence
if
not
os
.
path
.
isdir
(
self
.
software_root
):
if
not
os
.
path
.
isdir
(
self
.
software_root
):
raise
OSError
(
'%s does not exist.'
%
self
.
software_root
)
raise
OSError
(
'%s does not exist.'
%
self
.
software_root
)
if
not
os
.
path
.
isdir
(
self
.
instance_root
):
raise
OSError
(
'%s does not exist.'
%
self
.
instance_root
)
createSupervisordConfiguration
(
self
.
instance_root
,
self
.
_getWatchdogLine
())
# Creates everything needed
def
_launchSupervisord
(
self
):
# Create directory accessible for the instances.
launchSupervisord
(
instance_root
=
self
.
instance_root
,
logger
=
self
.
logger
)
var_directory
=
os
.
path
.
join
(
self
.
instance_root
,
'var'
)
if
not
os
.
path
.
isdir
(
var_directory
):
os
.
mkdir
(
var_directory
)
os
.
chmod
(
var_directory
,
stat
.
S_IRWXU
|
stat
.
S_IROTH
|
stat
.
S_IXOTH
|
\
stat
.
S_IRGRP
|
stat
.
S_IXGRP
)
mkdir_p
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
),
0o755
)
# Creates instance_root structure
createPrivateDirectory
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'log'
))
createPrivateDirectory
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
))
createPrivateDirectory
(
os
.
path
.
join
(
self
.
instance_root
,
'etc'
))
createPrivateDirectory
(
self
.
supervisord_configuration_directory
)
# Creates supervisord configuration
updateFile
(
self
.
supervisord_configuration_path
,
pkg_resources
.
resource_stream
(
__name__
,
'templates/supervisord.conf.in'
).
read
()
%
{
'supervisord_configuration_directory'
:
self
.
supervisord_configuration_directory
,
'supervisord_socket'
:
os
.
path
.
abspath
(
self
.
supervisord_socket
),
'supervisord_loglevel'
:
'info'
,
'supervisord_logfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'log'
,
'supervisord.log'
)),
'supervisord_logfile_maxbytes'
:
'50MB'
,
'supervisord_nodaemon'
:
'false'
,
'supervisord_pidfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)),
'supervisord_logfile_backups'
:
'10'
,
'watchdog_command'
:
self
.
getWatchdogLine
(),
}
)
def
getComputerPartitionList
(
self
):
def
getComputerPartitionList
(
self
):
try
:
try
:
...
@@ -501,11 +455,6 @@ class Slapgrid(object):
...
@@ -501,11 +455,6 @@ class Slapgrid(object):
return
SLAPGRID_FAIL
return
SLAPGRID_FAIL
return
SLAPGRID_SUCCESS
return
SLAPGRID_SUCCESS
def
_launchSupervisord
(
self
):
launchSupervisord
(
self
.
supervisord_socket
,
self
.
supervisord_configuration_path
,
logger
=
self
.
logger
)
def
_checkPromises
(
self
,
computer_partition
):
def
_checkPromises
(
self
,
computer_partition
):
self
.
logger
.
info
(
"Checking promises..."
)
self
.
logger
.
info
(
"Checking promises..."
)
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition
.
getId
())
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition
.
getId
())
...
@@ -678,7 +627,7 @@ class Slapgrid(object):
...
@@ -678,7 +627,7 @@ class Slapgrid(object):
software_path
=
software_path
,
software_path
=
software_path
,
instance_path
=
instance_path
,
instance_path
=
instance_path
,
supervisord_partition_configuration_path
=
os
.
path
.
join
(
supervisord_partition_configuration_path
=
os
.
path
.
join
(
self
.
supervisord_configuration_directory
,
'%s.conf'
%
_getSupervisordConfigurationDirectory
(
self
.
instance_root
)
,
'%s.conf'
%
computer_partition_id
),
computer_partition_id
),
supervisord_socket
=
self
.
supervisord_socket
,
supervisord_socket
=
self
.
supervisord_socket
,
computer_partition
=
computer_partition
,
computer_partition
=
computer_partition
,
...
@@ -1136,7 +1085,7 @@ class Slapgrid(object):
...
@@ -1136,7 +1085,7 @@ class Slapgrid(object):
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition
.
getId
()),
computer_partition
.
getId
()),
supervisord_partition_configuration_path
=
os
.
path
.
join
(
supervisord_partition_configuration_path
=
os
.
path
.
join
(
self
.
supervisord_configuration_directory
,
'%s.conf'
%
_getSupervisordConfigurationDirectory
(
self
.
instance_root
)
,
'%s.conf'
%
computer_partition_id
),
computer_partition_id
),
supervisord_socket
=
self
.
supervisord_socket
,
supervisord_socket
=
self
.
supervisord_socket
,
computer_partition
=
computer_partition
,
computer_partition
=
computer_partition
,
...
...
slapos/grid/svcbackend.py
View file @
0f8706b4
...
@@ -29,14 +29,17 @@
...
@@ -29,14 +29,17 @@
##############################################################################
##############################################################################
import
os
import
os
import
pkg_resources
import
socket
as
socketlib
import
subprocess
import
stat
import
sys
import
sys
import
time
import
time
import
xmlrpclib
import
xmlrpclib
import
socket
as
socketlib
import
subprocess
from
slapos.grid.utils
import
(
createPrivateDirectory
,
SlapPopen
,
updateFile
)
from
supervisor
import
xmlrpc
from
supervisor
import
xmlrpc
from
slapos.grid.utils
import
SlapPopen
def
getSupervisorRPC
(
socket
):
def
getSupervisorRPC
(
socket
):
...
@@ -47,7 +50,65 @@ def getSupervisorRPC(socket):
...
@@ -47,7 +50,65 @@ def getSupervisorRPC(socket):
return
getattr
(
server_proxy
,
'supervisor'
)
return
getattr
(
server_proxy
,
'supervisor'
)
def
launchSupervisord
(
socket
,
configuration_file
,
logger
,
supervisord_additional_argument_list
=
None
):
def
_getSupervisordSocketPath
(
instance_root
):
return
os
.
path
.
join
(
instance_root
,
'supervisord.socket'
)
def
_getSupervisordConfigurationFilePath
(
instance_root
):
return
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf'
)
def
_getSupervisordConfigurationDirectory
(
instance_root
):
return
os
.
path
.
join
(
instance_root
,
'etc'
,
'supervisord.conf.d'
)
def
createSupervisordConfiguration
(
instance_root
,
watchdog_command
=
'sleep 10'
):
"""
Create supervisord related files and directories.
"""
if
not
os
.
path
.
isdir
(
instance_root
):
raise
OSError
(
'%s does not exist.'
%
instance_root
)
supervisord_configuration_file_path
=
_getSupervisordConfigurationFilePath
(
instance_root
)
supervisord_configuration_directory
=
_getSupervisordConfigurationDirectory
(
instance_root
)
supervisord_socket
=
_getSupervisordSocketPath
(
instance_root
)
# Create directory accessible for the instances.
var_directory
=
os
.
path
.
join
(
instance_root
,
'var'
)
if
not
os
.
path
.
isdir
(
var_directory
):
os
.
mkdir
(
var_directory
)
os
.
chmod
(
var_directory
,
stat
.
S_IRWXU
|
stat
.
S_IROTH
|
stat
.
S_IXOTH
|
\
stat
.
S_IRGRP
|
stat
.
S_IXGRP
)
etc_directory
=
os
.
path
.
join
(
instance_root
,
'etc'
)
if
not
os
.
path
.
isdir
(
etc_directory
):
os
.
mkdir
(
etc_directory
)
# Creates instance_root structure
createPrivateDirectory
(
os
.
path
.
join
(
instance_root
,
'var'
,
'log'
))
createPrivateDirectory
(
os
.
path
.
join
(
instance_root
,
'var'
,
'run'
))
createPrivateDirectory
(
os
.
path
.
join
(
instance_root
,
'etc'
))
createPrivateDirectory
(
supervisord_configuration_directory
)
# Creates supervisord configuration
updateFile
(
supervisord_configuration_file_path
,
pkg_resources
.
resource_stream
(
__name__
,
'templates/supervisord.conf.in'
).
read
()
%
{
'supervisord_configuration_directory'
:
supervisord_configuration_directory
,
'supervisord_socket'
:
os
.
path
.
abspath
(
supervisord_socket
),
'supervisord_loglevel'
:
'info'
,
'supervisord_logfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
instance_root
,
'var'
,
'log'
,
'supervisord.log'
)),
'supervisord_logfile_maxbytes'
:
'50MB'
,
'supervisord_nodaemon'
:
'false'
,
'supervisord_pidfile'
:
os
.
path
.
abspath
(
os
.
path
.
join
(
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)),
'supervisord_logfile_backups'
:
'10'
,
'watchdog_command'
:
watchdog_command
,
}
)
def
launchSupervisord
(
instance_root
,
logger
,
supervisord_additional_argument_list
=
None
):
configuration_file
=
_getSupervisordConfigurationFilePath
(
instance_root
)
socket
=
_getSupervisordSocketPath
(
instance_root
)
if
os
.
path
.
exists
(
socket
):
if
os
.
path
.
exists
(
socket
):
trynum
=
1
trynum
=
1
while
trynum
<
6
:
while
trynum
<
6
:
...
@@ -66,6 +127,18 @@ def launchSupervisord(socket, configuration_file, logger, supervisord_additional
...
@@ -66,6 +127,18 @@ def launchSupervisord(socket, configuration_file, logger, supervisord_additional
else
:
else
:
if
status
[
'statename'
]
==
'RUNNING'
and
status
[
'statecode'
]
==
1
:
if
status
[
'statename'
]
==
'RUNNING'
and
status
[
'statecode'
]
==
1
:
logger
.
debug
(
'Supervisord already running.'
)
logger
.
debug
(
'Supervisord already running.'
)
# Update watchdog
supervisor
=
getSupervisorRPC
(
socket
)
try
:
# XXX workaround for https://github.com/Supervisor/supervisor/issues/339
# In theory, only reloadConfig is needed.
supervisor
.
stopProcess
(
'watchdog'
)
supervisor
.
removeProcessGroup
(
'watchdog'
)
except
:
pass
supervisor
.
reloadConfig
()
supervisor
.
addProcessGroup
(
'watchdog'
)
return
return
elif
status
[
'statename'
]
==
'SHUTDOWN_STATE'
and
status
[
'statecode'
]
==
6
:
elif
status
[
'statename'
]
==
'SHUTDOWN_STATE'
and
status
[
'statecode'
]
==
6
:
logger
.
info
(
'Supervisor in shutdown procedure, will check again later.'
)
logger
.
info
(
'Supervisor in shutdown procedure, will check again later.'
)
...
@@ -123,3 +196,4 @@ def launchSupervisord(socket, configuration_file, logger, supervisord_additional
...
@@ -123,3 +196,4 @@ def launchSupervisord(socket, configuration_file, logger, supervisord_additional
logger
.
warning
(
'Issue while checking supervisord.'
)
logger
.
warning
(
'Issue while checking supervisord.'
)
finally
:
finally
:
socketlib
.
setdefaulttimeout
(
default_timeout
)
socketlib
.
setdefaulttimeout
(
default_timeout
)
slapos/grid/templates/supervisord.conf.in
View file @
0f8706b4
...
@@ -22,3 +22,4 @@ chmod=0700
...
@@ -22,3 +22,4 @@ chmod=0700
[eventlistener:watchdog]
[eventlistener:watchdog]
command=%(watchdog_command)s
command=%(watchdog_command)s
events=PROCESS_STATE_EXITED, PROCESS_STATE_FATAL
events=PROCESS_STATE_EXITED, PROCESS_STATE_FATAL
autorestart=true
slapos/tests/configure_local.py
View file @
0f8706b4
...
@@ -38,8 +38,7 @@ from ConfigParser import ConfigParser
...
@@ -38,8 +38,7 @@ from ConfigParser import ConfigParser
# Disable any command to launch slapformat and supervisor
# Disable any command to launch slapformat and supervisor
slapos
.
cli
.
configure_local
.
_runFormat
=
lambda
x
:
"Do nothing"
slapos
.
cli
.
configure_local
.
_runFormat
=
lambda
x
:
"Do nothing"
slapos
.
cli
.
configure_local
.
launchSupervisord
=
lambda
socket
,
\
slapos
.
cli
.
configure_local
.
launchSupervisord
=
lambda
instance_root
,
logger
:
"Do nothing"
configuration_file
,
logger
:
"Do nothing"
class
TestConfigureLocal
(
unittest
.
TestCase
):
class
TestConfigureLocal
(
unittest
.
TestCase
):
...
...
slapos/tests/slapgrid.py
View file @
0f8706b4
...
@@ -122,8 +122,6 @@ class BasicMixin(object):
...
@@ -122,8 +122,6 @@ class BasicMixin(object):
self
.
instance_root
,
self
.
instance_root
,
self
.
master_url
,
self
.
master_url
,
self
.
computer_id
,
self
.
computer_id
,
self
.
supervisord_socket
,
self
.
supervisord_configuration_path
,
self
.
buildout
,
self
.
buildout
,
develop
=
develop
,
develop
=
develop
,
logger
=
logging
.
getLogger
())
logger
=
logging
.
getLogger
())
...
@@ -185,6 +183,12 @@ class BasicMixin(object):
...
@@ -185,6 +183,12 @@ class BasicMixin(object):
self
.
fail
(
'%s should not be created'
%
path
)
self
.
fail
(
'%s should not be created'
%
path
)
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
def
assertInstanceDirectoryListEqual
(
self
,
instance_list
):
instance_list
.
append
(
'etc'
)
instance_list
.
append
(
'var'
)
instance_list
.
append
(
'supervisord.socket'
)
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
instance_list
)
def
tearDown
(
self
):
def
tearDown
(
self
):
# XXX: Hardcoded pid, as it is not configurable in slapos
# XXX: Hardcoded pid, as it is not configurable in slapos
svc
=
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)
svc
=
os
.
path
.
join
(
self
.
instance_root
,
'var'
,
'run'
,
'supervisord.pid'
)
...
@@ -520,7 +524,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -520,7 +524,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
computer
=
ComputerForTest
(
self
.
software_root
,
self
.
instance_root
,
0
,
0
)
with
httmock
.
HTTMock
(
computer
.
request_handler
):
with
httmock
.
HTTMock
(
computer
.
request_handler
):
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'etc'
,
'var'
])
self
.
assertI
nstanceDirectoryListEqual
([
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[])
st
=
os
.
stat
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
))
st
=
os
.
stat
(
os
.
path
.
join
(
self
.
instance_root
,
'var'
))
self
.
assertEquals
(
stat
.
S_IMODE
(
st
.
st_mode
),
0o755
)
self
.
assertEquals
(
stat
.
S_IMODE
(
st
.
st_mode
),
0o755
)
...
@@ -530,7 +534,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -530,7 +534,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
with
httmock
.
HTTMock
(
computer
.
request_handler
):
with
httmock
.
HTTMock
(
computer
.
request_handler
):
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'buildout.cfg'
,
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -548,7 +552,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -548,7 +552,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
with
httmock
.
HTTMock
(
computer
.
request_handler
):
with
httmock
.
HTTMock
(
computer
.
request_handler
):
instance
=
computer
.
instance_list
[
0
]
instance
=
computer
.
instance_list
[
0
]
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'buildout.cfg'
,
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -568,7 +572,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -568,7 +572,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
partition
=
computer
.
instance_list
[
0
]
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'destroyed'
partition
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[])
self
.
assertEqual
(
partition
.
sequence
,
[])
self
.
assertEqual
(
partition
.
sequence
,
[])
...
@@ -580,7 +584,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -580,7 +584,7 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -617,7 +621,7 @@ HEREDOC
...
@@ -617,7 +621,7 @@ HEREDOC
chmod 755 etc/run/wrapper
chmod 755 etc/run/wrapper
"""
%
{
'python'
:
sys
.
executable
})
"""
%
{
'python'
:
sys
.
executable
})
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -632,7 +636,7 @@ chmod 755 etc/run/wrapper
...
@@ -632,7 +636,7 @@ chmod 755 etc/run/wrapper
computer
.
sequence
=
[]
computer
.
sequence
=
[]
instance
.
requested_state
=
'stopped'
instance
.
requested_state
=
'stopped'
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -672,7 +676,7 @@ HEREDOC
...
@@ -672,7 +676,7 @@ HEREDOC
chmod 755 etc/run/wrapper
chmod 755 etc/run/wrapper
"""
%
{
'python'
:
sys
.
executable
})
"""
%
{
'python'
:
sys
.
executable
})
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -691,8 +695,7 @@ chmod 755 etc/run/wrapper
...
@@ -691,8 +695,7 @@ chmod 755 etc/run/wrapper
exit 1
exit 1
"""
)
"""
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_FAIL
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_FAIL
)
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertInstanceDirectoryListEqual
([
'0'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -710,7 +713,7 @@ exit 1
...
@@ -710,7 +713,7 @@ exit 1
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
[
'.slapgrid'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -724,7 +727,7 @@ exit 1
...
@@ -724,7 +727,7 @@ exit 1
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
computer
.
sequence
=
[]
computer
.
sequence
=
[]
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'etc'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'etc'
,
...
@@ -754,7 +757,7 @@ exit 1
...
@@ -754,7 +757,7 @@ exit 1
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
dummy_file_name
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
dummy_file_name
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
...
@@ -799,7 +802,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
...
@@ -799,7 +802,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
partition
.
software
.
setBuildout
(
DAEMON_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.slapgrid'
,
'.0_daemon.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -844,8 +847,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
...
@@ -844,8 +847,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
partition
.
software
.
setBuildout
(
BUILDOUT_RUN_CONTENT
)
partition
.
software
.
setBuildout
(
BUILDOUT_RUN_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
instance_root
),
self
.
assertInstanceDirectoryListEqual
([
'0'
])
[
'0'
,
'etc'
,
'var'
])
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
.
partition_path
),
[
'.slapgrid'
,
'.0_daemon.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_daemon.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1126,7 +1128,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
...
@@ -1126,7 +1128,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1146,7 +1148,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
...
@@ -1146,7 +1148,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
...
@@ -1169,7 +1171,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
...
@@ -1169,7 +1171,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1187,7 +1189,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
...
@@ -1187,7 +1189,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1212,7 +1214,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
...
@@ -1212,7 +1214,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
timestamp
instance
.
timestamp
=
timestamp
self
.
launchSlapgrid
()
self
.
launchSlapgrid
()
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
partition
=
os
.
path
.
join
(
self
.
instance_root
,
'0'
)
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
self
.
assertItemsEqual
(
os
.
listdir
(
partition
),
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
[
'.slapgrid'
,
'.timestamp'
,
'buildout.cfg'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1536,7 +1538,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1536,7 +1538,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1554,7 +1556,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1554,7 +1556,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
...
@@ -1585,7 +1587,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1585,7 +1587,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
[
instance
.
software
.
software_hash
])
...
@@ -1607,7 +1609,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1607,7 +1609,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'started'
instance
.
requested_state
=
'started'
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
instance
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1623,13 +1625,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1623,13 +1625,13 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
# Then run usage report and see if it is still working
# Then run usage report and see if it is still working
computer
.
sequence
=
[]
computer
.
sequence
=
[]
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
self
.
assertLogContent
(
wrapper_log
,
'Working'
)
self
.
assertLogContent
(
wrapper_log
,
'Working'
)
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
[
'.slapgrid'
,
'.0_wrapper.log'
,
'buildout.cfg'
,
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
...
@@ -1653,7 +1655,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1653,7 +1655,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'/getFullComputerInformation'
])
self
.
assertEqual
(
computer
.
sequence
,
[
'/getFullComputerInformation'
])
...
@@ -1672,7 +1674,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
...
@@ -1672,7 +1674,7 @@ class TestSlapgridUsageReport(MasterMixin, unittest.TestCase):
instance
.
requested_state
=
'destroyed'
instance
.
requested_state
=
'destroyed'
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
agregateAndSendUsage
(),
slapgrid
.
SLAPGRID_SUCCESS
)
# Assert partition directory is empty
# Assert partition directory is empty
self
.
assertI
temsEqual
(
os
.
listdir
(
self
.
instance_root
),
[
'0'
,
'etc'
,
'var
'
])
self
.
assertI
nstanceDirectoryListEqual
([
'0
'
])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
instance
.
partition_path
),
[])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertItemsEqual
(
os
.
listdir
(
self
.
software_root
),
[
instance
.
software
.
software_hash
])
self
.
assertEqual
(
computer
.
sequence
,
[
'/getFullComputerInformation'
])
self
.
assertEqual
(
computer
.
sequence
,
[
'/getFullComputerInformation'
])
...
...
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