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
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
Léo-Paul Géneau
slapos.core
Commits
18d21724
Commit
18d21724
authored
Jan 19, 2015
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: allow to use supervisorctl without automatically starting supervisord.
parent
0f8706b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
slapos/cli/supervisorctl.py
slapos/cli/supervisorctl.py
+16
-4
slapos/tests/cli.py
slapos/tests/cli.py
+25
-0
No files found.
slapos/cli/supervisorctl.py
View file @
18d21724
...
...
@@ -31,7 +31,6 @@ import argparse
from
slapos.cli.command
import
check_root_user
from
slapos.cli.config
import
ConfigCommand
from
slapos.grid.svcbackend
import
(
launchSupervisord
,
_getSupervisordConfigurationFilePath
)
import
supervisor.supervisorctl
...
...
@@ -54,6 +53,11 @@ class SupervisorctlCommand(ConfigCommand):
return
True
return
configp
.
getboolean
(
'slapos'
,
'root_check'
)
def
_should_forbid_supervisord_launch
(
self
,
configp
):
if
not
configp
.
has_option
(
'supervisorctl'
,
'forbid_supervisord_automatic_launch'
):
return
False
return
configp
.
getboolean
(
'supervisorctl'
,
'forbid_supervisord_automatic_launch'
)
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
...
...
@@ -63,11 +67,19 @@ class SupervisorctlCommand(ConfigCommand):
check_root_user
(
self
)
instance_root
=
configp
.
get
(
'slapos'
,
'instance_root'
)
launchSupervisord
(
instance_root
=
instance_root
,
logger
=
self
.
app
.
log
)
supervisor
.
supervisorctl
.
main
(
args
=
[
'-c'
,
_getSupervisordConfigurationFilePath
(
instance_root
)]
+
args
.
supervisor_args
forbid_supervisord_launch
=
self
.
_should_forbid_supervisord_launch
(
configp
)
do_supervisorctl
(
self
.
app
.
log
,
instance_root
,
args
.
supervisor_args
,
forbid_supervisord_launch
)
def
do_supervisorctl
(
logger
,
instance_root
,
supervisor_args
,
forbid_supervisord_launch
=
False
):
from
slapos.grid.svcbackend
import
(
launchSupervisord
,
_getSupervisordConfigurationFilePath
)
if
forbid_supervisord_launch
is
False
:
launchSupervisord
(
instance_root
=
instance_root
,
logger
=
logger
)
supervisor
.
supervisorctl
.
main
(
args
=
[
'-c'
,
_getSupervisordConfigurationFilePath
(
instance_root
)]
+
supervisor_args
)
class
SupervisorctlAliasCommand
(
SupervisorctlCommand
):
def
take_action
(
self
,
args
):
...
...
slapos/tests/cli.py
View file @
18d21724
...
...
@@ -33,10 +33,14 @@ from mock import patch, create_autospec
import
slapos.cli.list
import
slapos.cli.info
import
slapos.cli.supervisorctl
from
slapos.client
import
ClientConfig
import
slapos.grid.svcbackend
import
slapos.proxy
import
slapos.slap
import
supervisor.supervisorctl
def
raiseNotFoundError
(
*
args
,
**
kwargs
):
raise
slapos
.
slap
.
NotFoundError
()
...
...
@@ -126,3 +130,24 @@ class TestCliInfo(CliMixin):
self
.
logger
.
warning
.
assert_called_once_with
(
'Instance %s does not exist.'
,
self
.
conf
.
reference
)
@
patch
.
object
(
supervisor
.
supervisorctl
,
'main'
)
class
TestCliSupervisorctl
(
CliMixin
):
def
test_allow_supervisord_launch
(
self
,
_
):
"""
Test that "slapos node supervisorctl" tries to launch supervisord
"""
instance_root
=
'/foo/bar'
with
patch
.
object
(
slapos
.
grid
.
svcbackend
,
'launchSupervisord'
)
as
launchSupervisord
:
slapos
.
cli
.
supervisorctl
.
do_supervisorctl
(
self
.
logger
,
instance_root
,
[
'status'
],
False
)
launchSupervisord
.
assert_any_call
(
instance_root
=
instance_root
,
logger
=
self
.
logger
)
def
test_forbid_supervisord_launch
(
self
,
_
):
"""
Test that "slapos node supervisorctl" does not try to launch supervisord
"""
instance_root
=
'/foo/bar'
with
patch
.
object
(
slapos
.
grid
.
svcbackend
,
'launchSupervisord'
)
as
launchSupervisord
:
slapos
.
cli
.
supervisorctl
.
do_supervisorctl
(
self
.
logger
,
instance_root
,
[
'status'
],
True
)
self
.
assertFalse
(
launchSupervisord
.
called
)
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