Exemplo n.º 1
0
 def test_save_config(self):
     with contextlib.nested(
         mock.patch("neutron_lbaas.services.loadbalancer." "drivers.haproxy.jinja_cfg.render_loadbalancer_obj"),
         mock.patch("neutron.agent.linux.utils.replace_file"),
     ) as (r_t, replace):
         r_t.return_value = "fake_rendered_template"
         lb = mock.Mock()
         jinja_cfg.save_config("test_conf_path", lb, "test_sock_path", "nogroup", "fake_state_path")
         r_t.assert_called_once_with(lb, "nogroup", "test_sock_path", "fake_state_path")
         replace.assert_called_once_with("test_conf_path", "fake_rendered_template")
Exemplo n.º 2
0
 def test_save_config(self):
     with mock.patch('neutron_lbaas.services.loadbalancer.drivers.haproxy.'
                     'jinja_cfg.render_loadbalancer_obj') as r_t, \
             mock.patch('neutron.common.utils.replace_file') as replace:
         r_t.return_value = 'fake_rendered_template'
         lb = mock.Mock()
         jinja_cfg.save_config('test_conf_path', lb, 'test_sock_path',
                               'nogroup', 'fake_state_path')
         r_t.assert_called_once_with(lb, 'nogroup', 'test_sock_path',
                                     'fake_state_path')
         replace.assert_called_once_with('test_conf_path',
                                         'fake_rendered_template')
Exemplo n.º 3
0
 def test_save_config(self):
     with contextlib.nested(
             mock.patch(
                 'neutron_lbaas.services.loadbalancer.'
                 'drivers.haproxy.jinja_cfg.render_loadbalancer_obj'),
             mock.patch('neutron.agent.linux.utils.replace_file')) as (
                 r_t, replace):
         r_t.return_value = 'fake_rendered_template'
         lb = mock.Mock()
         jinja_cfg.save_config('test_conf_path', lb, 'test_sock_path',
                               'nogroup', 'fake_state_path')
         r_t.assert_called_once_with(lb, 'nogroup', 'test_sock_path',
                                     'fake_state_path')
         replace.assert_called_once_with('test_conf_path',
                                         'fake_rendered_template')
Exemplo n.º 4
0
 def test_save_config(self):
     with mock.patch('neutron_lbaas.services.loadbalancer.drivers.haproxy.'
                     'jinja_cfg.render_loadbalancer_obj') as r_t, \
             mock.patch('neutron.common.utils.replace_file') as replace:
         r_t.return_value = 'fake_rendered_template'
         lb = mock.Mock()
         jinja_cfg.save_config('test_conf_path', lb, 'test_sock_path',
                               'nogroup',
                               'fake_state_path')
         r_t.assert_called_once_with(lb,
                                     'nogroup',
                                     'test_sock_path',
                                     'fake_state_path')
         replace.assert_called_once_with('test_conf_path',
                                         'fake_rendered_template')
Exemplo n.º 5
0
    def _spawn(self, loadbalancer, extra_cmd_args=()):
        namespace = get_ns_name(loadbalancer.id)
        conf_path = self._get_state_file_path(loadbalancer.id, "haproxy.conf")
        pid_path = self._get_state_file_path(loadbalancer.id, "haproxy.pid")
        sock_path = self._get_state_file_path(loadbalancer.id, "haproxy_stats.sock")
        user_group = self.conf.haproxy.user_group
        haproxy_base_dir = self._get_state_file_path(loadbalancer.id, "")
        jinja_cfg.save_config(conf_path, loadbalancer, sock_path, user_group, haproxy_base_dir)
        cmd = ["haproxy", "-f", conf_path, "-p", pid_path]
        cmd.extend(extra_cmd_args)

        ns = ip_lib.IPWrapper(namespace=namespace)
        ns.netns.execute(cmd)

        # remember deployed loadbalancer id
        self.deployed_loadbalancers[loadbalancer.id] = loadbalancer
Exemplo n.º 6
0
 def test_save_config(self):
     with contextlib.nested(
         mock.patch('neutron_lbaas.services.loadbalancer.'
                    'drivers.haproxy.jinja_cfg.render_loadbalancer_obj'),
         mock.patch('neutron.agent.linux.utils.replace_file')
     ) as (r_t, replace):
         r_t.return_value = 'fake_rendered_template'
         lb = mock.Mock()
         jinja_cfg.save_config('test_conf_path', lb, 'test_sock_path',
                               'nogroup',
                               'fake_state_path')
         r_t.assert_called_once_with(lb,
                                     'nogroup',
                                     'test_sock_path',
                                     'fake_state_path')
         replace.assert_called_once_with('test_conf_path',
                                         'fake_rendered_template')
Exemplo n.º 7
0
    def _spawn(self, loadbalancer, extra_cmd_args=()):
        namespace = get_ns_name(loadbalancer.id)
        conf_path = self._get_state_file_path(loadbalancer.id, 'haproxy.conf')
        pid_path = self._get_state_file_path(loadbalancer.id, 'haproxy.pid')
        sock_path = self._get_state_file_path(loadbalancer.id,
                                              'haproxy_stats.sock')
        user_group = self.conf.haproxy.user_group
        haproxy_base_dir = self._get_state_file_path(loadbalancer.id, '')
        jinja_cfg.save_config(conf_path, loadbalancer, sock_path, user_group,
                              haproxy_base_dir)
        cmd = ['haproxy', '-f', conf_path, '-p', pid_path]
        cmd.extend(extra_cmd_args)

        ns = ip_lib.IPWrapper(namespace=namespace)
        ns.netns.execute(cmd)

        # remember deployed loadbalancer id
        self.deployed_loadbalancers[loadbalancer.id] = loadbalancer
    def _spawn(self, loadbalancer, extra_cmd_args=()):
        namespace = get_ns_name(loadbalancer.id)
        conf_path = self._get_state_file_path(loadbalancer.id, 'haproxy.conf')
        pid_path = self._get_state_file_path(loadbalancer.id,
                                             'haproxy.pid')
        sock_path = self._get_state_file_path(loadbalancer.id,
                                              'haproxy_stats.sock')
        user_group = self.conf.haproxy.user_group
        state_path = self._get_state_file_path(loadbalancer.id, '')

        jinja_cfg.save_config(conf_path, loadbalancer, sock_path, user_group,
                              state_path)
        cmd = ['haproxy', '-f', conf_path, '-p', pid_path]
        cmd.extend(extra_cmd_args)

        ns = ip_lib.IPWrapper(namespace=namespace)
        ns.netns.execute(cmd)

        # remember deployed loadbalancer id
        self.deployed_loadbalancer_ids.add(loadbalancer.id)