__all__ = ["ContainerManager", "ContainerEngine", "LXC", "Docker", "Container"]
-SUPERVISOR_CONF = '/etc/supervisord.conf'
+SUPERVISOR_CONF = '/etc/supervisor/supervisord.conf'
class ContainerManager(object):
if isinstance(self, LXC):
self.execute('sleep 3; apt-get update')
self.execute('apt-get install -y supervisor')
- self.execute('echo "{config}" > {config_file} && '
- 'supervisord -c {config_file}'.
- format(
- config='[unix_http_server]\n'
- 'file = /tmp/supervisor.sock\n\n'
- '[rpcinterface:supervisor]\n'
- 'supervisor.rpcinterface_factory = '
- 'supervisor.rpcinterface:make_main_rpcinterface\n\n'
- '[supervisorctl]\n'
- 'serverurl = unix:///tmp/supervisor.sock\n\n'
- '[supervisord]\n'
- 'pidfile = /tmp/supervisord.pid\n'
- 'identifier = supervisor\n'
- 'directory = /tmp\n'
- 'logfile=/tmp/supervisord.log\n'
- 'loglevel=debug\n'
- 'nodaemon=false\n\n',
- config_file=SUPERVISOR_CONF))
+ self.execute('echo "{config}" > {config_file} && '
+ 'supervisord -c {config_file}'.
+ format(
+ config='[unix_http_server]\n'
+ 'file = /tmp/supervisor.sock\n\n'
+ '[rpcinterface:supervisor]\n'
+ 'supervisor.rpcinterface_factory = supervisor.'
+ 'rpcinterface:make_main_rpcinterface\n\n'
+ '[supervisorctl]\n'
+ 'serverurl = unix:///tmp/supervisor.sock\n\n'
+ '[supervisord]\n'
+ 'pidfile = /tmp/supervisord.pid\n'
+ 'identifier = supervisor\n'
+ 'directory = /tmp\n'
+ 'logfile = /tmp/supervisord.log\n'
+ 'loglevel = debug\n'
+ 'nodaemon = false\n\n',
+ config_file=SUPERVISOR_CONF))
def start_vpp(self):
"""Start VPP inside a container."""
- self.execute('echo "{config}" >> {config_file}'.
+ self.execute('echo "{config}" >> {config_file} && '
+ 'supervisorctl reload'.
format(
config='[program:vpp]\n'
- 'command=/usr/bin/vpp -c /etc/vpp/startup.conf\n'
- 'autostart=false\n'
- 'autorestart=false\n'
- 'redirect_stderr=true\n'
- 'priority=1',
+ 'command = /usr/bin/vpp -c /etc/vpp/startup.conf\n'
+ 'autostart = false\n'
+ 'autorestart = false\n'
+ 'redirect_stderr = true\n'
+ 'priority = 1',
config_file=SUPERVISOR_CONF))
- self.execute('supervisorctl reload')
self.execute('supervisorctl start vpp')
from robot.libraries.BuiltIn import BuiltIn
:raises RuntimeError: If creating the container fails.
"""
if self.container.mnt:
+ # LXC fix for tmpfs
+ # https://github.com/lxc/lxc/issues/434
+ ret, _, _ = self.container.ssh.exec_command_sudo(
+ "sh -c 'echo \"{e}\" >> /var/lib/lxc/{c.name}/config'".
+ format(e="lxc.mount.entry = tmpfs run tmpfs defaults",
+ c=self.container))
+ if int(ret) != 0:
+ raise RuntimeError('Failed to write {c.name} config.'.
+ format(c=self.container))
+
for mount in self.container.mnt:
host_dir, guest_dir = mount.split(':')
- if host_dir.endswith('/'):
- self.container.ssh.exec_command_sudo(
- "sh -c 'mkdir -p {host_dir}'".format(host_dir=host_dir))
options = 'bind,create=dir' \
if guest_dir.endswith('/') else 'bind,create=file'
entry = 'lxc.mount.entry = {host_dir} {guest_dir} none ' \
if self.container.cpuset_cpus else ''
ret, _, _ = self.container.ssh.exec_command_sudo(
- 'lxc-start --name {c.name} --daemon'.
- format(c=self.container))
+ 'lxc-start --name {c.name} --daemon'.format(c=self.container))
if int(ret) != 0:
raise RuntimeError('Failed to start container {c.name}.'.
format(c=self.container))