X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FContainerUtils.py;h=50868cb8f2c3d8305ed264b1f6a06323cd887038;hb=d5e00a369ffef5edf929ef5b03b7c544021b2e41;hp=cd48fc6c1f3ad177113296176d84d59a697015f5;hpb=c4528bcd137c0813d34b1b248bc92670736e78e6;p=csit.git diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index cd48fc6c1f..50868cb8f2 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -398,6 +398,7 @@ class ContainerEngine(object): self.execute('sleep 3; apt-get update') self.execute('apt-get install -y supervisor') self.execute('echo "{config}" > {config_file} && ' + 'unlink /tmp/supervisor.sock && ' 'supervisord -c {config_file}'. format( config='[unix_http_server]\n' @@ -411,9 +412,9 @@ class ContainerEngine(object): 'pidfile = /tmp/supervisord.pid\n' 'identifier = supervisor\n' 'directory = /tmp\n' - 'logfile=/tmp/supervisord.log\n' - 'loglevel=debug\n' - 'nodaemon=false\n\n', + 'logfile = /tmp/supervisord.log\n' + 'loglevel = debug\n' + 'nodaemon = false\n\n', config_file=SUPERVISOR_CONF)) def start_vpp(self): @@ -421,11 +422,11 @@ class ContainerEngine(object): self.execute('echo "{config}" >> {config_file}'. 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') @@ -633,16 +634,24 @@ class LXC(ContainerEngine): :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(':') options = 'bind,create=dir' \ if guest_dir.endswith('/') else 'bind,create=file' - entry = 'lxc.mount.entry = {host_dir} '\ - '/var/lib/lxc/{c.name}/rootfs{guest_dir} none ' \ - '{options} 0 0'.format(c=self.container, - host_dir=host_dir, - guest_dir=guest_dir, - options=options) + entry = 'lxc.mount.entry = {host_dir} {guest_dir} none ' \ + '{options} 0 0'.format( + host_dir=host_dir, guest_dir=guest_dir[1:], + options=options) ret, _, _ = self.container.ssh.exec_command_sudo( "sh -c 'echo \"{e}\" >> /var/lib/lxc/{c.name}/config'". format(e=entry, c=self.container)) @@ -655,8 +664,7 @@ class LXC(ContainerEngine): 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))