aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/LXCUtils.py
blob: 9f4254098653aff198e8b1e76e02c28b5bda27ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
/*
 * Copyright (c) 2018-2019 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <vnet/tcp/tcp.h>
#include <math.h>

#define beta_cubic 	0.7
#define cubic_c		0.4
#define west_const 	(3 * (1 - beta_cubic) / (1 + beta_cubic))

typedef struct cubic_cfg_
{
  u8 fast_convergence;
} cubic_cfg_t;

static cubic_cfg_t cubic_cfg = {
  .fast_convergence = 1,
};

typedef struct cubic_data_
{
  /** time period (in seconds) needed to increase the current window
   *  size to W_max if there are no further congestion events */
  f64 K;

  /** time (in sec) since the start of current congestion avoidance */
  f64 t_start;

  /** Inflection point of the cubic function (in snd_mss segments) */
  u32 w_max;

} __clib_packed cubic_data_t;

STATIC_ASSERT (sizeof (cubic_data_t) <= TCP_CC_D
# Copyright (c) 2017 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Library to manipulate LXC."""

from resources.libraries.python.ssh import SSH
from resources.libraries.python.constants import Constants
from resources.libraries.python.topology import NodeType


__all__ = ["LXCUtils"]

class LXCUtils(object):
    """LXC utilities."""

    def __init__(self, container_name='slave'):
        # LXC container name
        self._container_name = container_name
        self._node = None
        # Host hugepages dir that will be mounted inside LXC
        self._host_hugepages_dir = '/dev/hugepages'
        # Host dir that will be mounted inside LXC
        self._host_dir = '/tmp/'
        # Guest dir to mount host dir to
        self._guest_dir = '/mnt/host'
        # LXC container env variables
        self._env_vars = ['LC_ALL="en_US.UTF-8"',
                          'DEBIAN_FRONTEND=noninteractive']

    def set_node(self, node):
        """Set node for LXC execution.

        :param node: Node to execute LXC on.
        :type node: dict
        :raises RuntimeError: If Node type is not DUT.
        """
        if node['type'] != NodeType.DUT:
            raise RuntimeError('Node type is not DUT.')
        self._node = node

    def set_host_dir(self, node, host_dir):
        """Set shared dir on parent node for LXC.

        :param node: Node to control LXC on.
        :type node: dict
        :raises RuntimeError: If Node type is not DUT.
        """
        if node['type'] != NodeType.DUT:
            raise RuntimeError('Node type is not DUT.')
        self._host_dir = host_dir

    def set_guest_dir(self, node, guest_dir):
        """Set mount dir on LXC.

        :param node: Node to control LXC on.
        :param guest_dir: Guest dir for mount.
        :type node: dict
        :type guest_dir: str
        :raises RuntimeError: If Node type is not DUT.
        """
        if node['type'] != NodeType.DUT:
            raise RuntimeError('Node type is not DUT.')
        self._guest_dir = guest_dir

    def _lxc_checkconfig(self):
        """Check the current kernel for LXC support.

        :raises RuntimeError: If failed to check LXC support.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo('lxc-checkconfig')
        if int(ret) != 0:
            raise RuntimeError('Failed to check LXC support.')

    def _lxc_create(self, distro='ubuntu', release='xenial', arch='amd64'):
        """Creates a privileged system object where is stored the configuration
        information and where can be stored user information.

        :param distro: Linux distribution name.
        :param release: Linux distribution release.
        :param arch: Linux distribution architecture.
        :type distro: str
        :type release: str
        :type arch: str
        :raises RuntimeError: If failed to create a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-create -t download --name {0} -- -d {1} -r {2} -a {3}'
            .format(self._container_name, distro, release, arch), timeout=1800)
        if int(ret) != 0:
            raise RuntimeError('Failed to create LXC container.')

    def _lxc_info(self):
        """Queries and shows information about a container.

        :raises RuntimeError: If failed to get info about a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-info --name {0}'.format(self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to get info about LXC container {0}.'
                               .format(self._container_name))

    def _lxc_start(self):
        """Start an application inside a container.

        :raises RuntimeError: If failed to start container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-start --name {0} --daemon'.format(self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to start LXC container {0}.'
                               .format(self._container_name))

    def _lxc_stop(self):
        """Stop an application inside a container.

        :raises RuntimeError: If failed to stop container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-stop --name {0}'.format(self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to stop LXC container {}.'
                               .format(self._container_name))

    def _lxc_destroy(self):
        """Destroy a container.

        :raises RuntimeError: If failed to destroy container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-destroy --force --name {0}'.format(self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to destroy LXC container {}.'
                               .format(self._container_name))

    def _lxc_wait(self, state):
        """Wait for a specific container state.

        :param state: Specify the container state(s) to wait for.
        :type state: str
        :raises RuntimeError: If failed to wait for state of a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-wait --name {0} --state "{1}"'
            .format(self._container_name, state))
        if int(ret) != 0:
            raise RuntimeError('Failed to wait for "{0}" of LXC container {1}.'
                               .format(state, self._container_name))

    def _lxc_cgroup(self, state_object, value=''):
        """Manage the control group associated with a container.

        :param state_object: Specify the state object name.
        :param value: Specify the value to assign to the state object. If empty,
        then action is GET, otherwise is action SET.
        :type state_object: str
        :type value: str
        :raises RuntimeError: If failed to get/set for state of a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-cgroup --name {0} {1} {2}'
            .format(self._container_name, state_object, value))
        if int(ret) != 0:
            if value:
                raise RuntimeError('Failed to set {0} of LXC container {1}.'
                                   .format(state_object, self._container_name))
            else:
                raise RuntimeError('Failed to get {0} of LXC container {1}.'
                                   .format(state_object, self._container_name))

    def lxc_attach(self, command):
        """Start a process inside a running container. Runs the specified
        command inside the container specified by name. The container has to
        be running already.

        :param command: Command to run inside container.
        :type command: str
        :raises RuntimeError: If container is not running.
        :raises RuntimeError: If failed to run the command.
        """
        env_var = '--keep-env {0}'\
            .format(' '.join('--set-var %s' % var for var in self._env_vars))

        ssh = SSH()
        ssh.connect(self._node)

        if not self.is_container_running():
            raise RuntimeError('LXC {0} is not running.'
                               .format(self._container_name))

        ret, _, _ = ssh.exec_command_lxc(lxc_cmd=command,
                                         lxc_name=self._container_name,
                                         lxc_params=env_var, timeout=180)
        if int(ret) != 0:
            raise RuntimeError('Failed to run "{0}" on LXC container {1}.'
                               .format(command, self._container_name))

    def is_container_present(self):
        """Check if LXC container is existing on node."""

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo(
            'lxc-info --name {0}'.format(self._container_name))
        return False if int(ret) else True

    def create_container(self, force_create=True):
        """Create and start a container.

        :param force_create: Destroy a container if exists and create.
        :type force_create: bool
        """
        if self.is_container_present():
            if force_create:
                self.destroy_container()
            else:
                return

        self._lxc_checkconfig()
        self._lxc_create(distro='ubuntu', release='xenial', arch='amd64')
        self.start_container()

    def start_container(self):
        """Start a container and wait for running state."""

        self._lxc_start()
        self._lxc_wait('RUNNING')
        self._lxc_info()

    def is_container_running(self):
        """Check if LXC container is running on node.

        :raises RuntimeError: If failed to get info about a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, stdout, _ = ssh.exec_command_sudo(
            'lxc-info --state --name {0}'.format(self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to get info about LXC container {0}.'
                               .format(self._container_name))

        return True if 'RUNNING' in stdout else False

    def stop_container(self):
        """Stop a container and wait for stopped state."""

        self._lxc_stop()
        self._lxc_wait('STOPPED|FROZEN')
        self._lxc_info()

    def restart_container(self):
        """Restart container."""

        self.stop_container()
        self.start_container()

    def destroy_container(self):
        """Stop and destroy a container."""

        self._lxc_destroy()

    def container_cpuset_cpus(self, container_cpu):
        """Set cpuset.cpus control group associated with a container.

        :param container_cpu: Cpuset.cpus string.
        :type container_cpu: str
        :raises RuntimeError: If failed to set cgroup for a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        ret, _, _ = ssh.exec_command_sudo('cgset --copy-from / lxc')
        if int(ret) != 0:
            raise RuntimeError('Failed to copy cgroup settings from root.')

        self._lxc_cgroup(state_object='cpuset.cpus')
        self._lxc_cgroup(state_object='cpuset.cpus', value=container_cpu)
        self._lxc_cgroup(state_object='cpuset.cpus')

    def mount_host_dir_in_container(self):
        """Mount shared folder inside container.

        :raises RuntimeError: If failed to mount host dir in a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        mnt_cfg = 'lxc.mount.entry = {0} /var/lib/lxc/{1}/rootfs{2} ' \
            'none bind,create=dir 0 0'.format(self._host_dir,
                                              self._container_name,
                                              self._guest_dir)
        ret, _, _ = ssh.exec_command_sudo(
            "sh -c 'echo \"{0}\" >> /var/lib/lxc/{1}/config'"
            .format(mnt_cfg, self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to mount {0} in lxc: {1}'
                               .format(self._host_dir, self._container_name))

        self.restart_container()

    def mount_hugepages_in_container(self):
        """Mount hugepages inside container.

        :raises RuntimeError: If failed to mount hugepages in a container.
        """

        ssh = SSH()
        ssh.connect(self._node)

        mnt_cfg = 'lxc.mount.entry = {0} dev/hugepages ' \
            'none bind,create=dir 0 0'.format(self._host_hugepages_dir)
        ret, _, _ = ssh.exec_command_sudo(
            "sh -c 'echo \"{0}\" >> /var/lib/lxc/{1}/config'"
            .format(mnt_cfg, self._container_name))
        if int(ret) != 0:
            raise RuntimeError('Failed to mount {0} in lxc: {1}'
                               .format(self._host_hugepages_dir,
                                       self._container_name))

        self.restart_container()

    def install_vpp_in_container(self, install_dkms=False):
        """Install vpp inside a container.

        :param install_dkms: If install dkms package. This will impact install
        time. Dkms is required for installation of vpp-dpdk-dkms. Default is
        false.
        :type install_dkms: bool
        """

        ssh = SSH()
        ssh.connect(self._node)

        self.lxc_attach('apt-get update')
        if install_dkms:
            self.lxc_attach('apt-get install -y dkms && '
                            'dpkg -i --force-all {0}/install_dir/*.deb'
                            .format(self._guest_dir))
        else:
            self.lxc_attach('for i in $(ls -I \"*dkms*\" {0}/install_dir/); '
                            'do dpkg -i --force-all {0}/install_dir/$i; done'
                            .format(self._guest_dir))
        self.lxc_attach('apt-get -f install -y')

    def restart_vpp_in_container(self):
        """Restart vpp service inside a container."""

        ssh = SSH()
        ssh.connect(self._node)

        self.lxc_attach('service vpp restart')

    def create_vpp_cfg_in_container(self, vat_template_file, **args):
        """Create VPP exec config for a container on given node.

        :param vat_template_file: Template file name of a VAT script.
        :param args: Parameters for VAT script.
        :type vat_template_file: str
        :type args: dict
        """
        ssh = SSH()
        ssh.connect(self._node)

        vat_file_path = '{}/{}'.format(Constants.RESOURCES_TPL_VAT,
                                       vat_template_file)

        with open(vat_file_path, 'r') as template_file:
            cmd_template = template_file.readlines()
            for line_tmpl in cmd_template:
                vat_cmd = line_tmpl.format(**args)
                ssh.exec_command('echo "{0}" | '
                                 'sudo lxc-attach --name {1} -- '
                                 '/bin/sh -c "/bin/cat >> /tmp/running.exec"'
                                 .format(vat_cmd.replace('\n', ''),
                                         self._container_name))