コード例 #1
0
 def __init__(self, name, props):
     self.workdir = props['server_workdir']
     pidname = self.workdir + "/nginx_" + name + ".pid"
     props.update({'pid': pidname})
     self.config = fill_template(props['config'], props)
     self.config_name = 'nginx_%s.cfg' % name
     self.pidfile_name = pidname
コード例 #2
0
 def get_config_without_js(self):
     """Recreate config without js_challenge directive. """
     desc = self.tempesta.copy()
     populate_properties(desc)
     new_cfg = fill_template(desc['config'], desc)
     new_cfg = re.sub(r'js_challenge[\s\w\d_/=\.\n]+;', '', new_cfg, re.M)
     return new_cfg
コード例 #3
0
 def __create_client_deproxy(self, client, ssl, bind_addr):
     addr = fill_template(client['addr'], client)
     port = int(fill_template(client['port'], client))
     clt = deproxy_client.DeproxyClient(addr=addr,
                                        port=port,
                                        ssl=ssl,
                                        bind_addr=bind_addr)
     if ssl and 'ssl_hostname' in client:
         # Don't set SNI by default, do this only if it was specified in
         # the client configuration.
         server_hostname = fill_template(client['ssl_hostname'], client)
         clt.set_server_hostname(server_hostname)
     clt.segment_size = int(client.get('segment_size', 0))
     clt.segment_gap = int(client.get('segment_gap', 0))
     clt.keep_original_data = bool(client.get('keep_original_data', None))
     return clt
コード例 #4
0
 def __create_client_external(self, client_descr):
     cmd_args = fill_template(client_descr['cmd_args'], client_descr)
     ext_client = external_client.ExternalTester(
         binary=client_descr['binary'],
         cmd_args=cmd_args,
         server_addr=None,
         uri=None)
     return ext_client
コード例 #5
0
    def __create_backend(self, server):
        srv = None
        checks = []
        sid = server['id']
        populate_properties(server)
        if 'check_ports' in server:
            for check in server['check_ports']:
                ip = fill_template(check['ip'], server)
                port = fill_template(check['port'], server)
                checks.append((ip, port))

        stype = server['type']
        try:
            factory = backend_defs[stype]
        except Exception as e:
            tf_cfg.dbg(1, "Unsupported backend %s" % stype)
            tf_cfg.dbg(1, "Supported backends: %s" % backend_defs)
            raise e
        srv = factory(server, sid, self)
        srv.port_checks = checks
        self.__servers[sid] = srv
コード例 #6
0
def build_deproxy_echo(server, name, tester):
    port = server['port']
    if port == 'default':
        port = tempesta.upstream_port_start_from()
    else:
        port = int(port)
    srv = None
    rtype = server['response']
    if rtype == 'static':
        content = fill_template(server['response_content'], server)
        srv = DeproxyEchoServer(port=port, response=content)
    else:
        raise Exception("Invalid response type: %s" % str(rtype))
    tester.deproxy_manager.add_server(srv)
    return srv
コード例 #7
0
    def __init__(self, name, props):
        self.node = remote.server
        self.workdir = tf_cfg.cfg.get('Server', 'workdir')
        self.config = self.Config(name, props)

        # Configure number of connections used by TempestaFW.
        self.conns_n = tempesta.server_conns_default()
        self.err_msg = "Can't %s Nginx on %s"
        self.active_conns = 0
        self.requests = 0
        self.name = name
        self.status_uri = fill_template(props['status_uri'], props)
        self.stop_procedures = [self.stop_nginx, self.remove_config]
        self.weight = int(props['weight']) if 'weight' in props else None

        self.clear_stats()
コード例 #8
0
 def __create_tempesta(self):
     desc = self.tempesta.copy()
     populate_properties(desc)
     custom_cert = False
     if 'custom_cert' in desc:
         custom_cert = self.tempesta['custom_cert']
     config = ""
     if 'config' in desc:
         config = desc['config']
     if 'type' in desc:
         factory = tempesta_defs[desc['type']]
         self.__tempesta = factory(desc)
     else:
         self.__tempesta = default_tempesta_factory(desc)
     self.__tempesta.config.set_defconfig(fill_template(config, desc),
                                          custom_cert)
コード例 #9
0
 def __create_client_wrk(self, client, ssl):
     addr = fill_template(client['addr'], client)
     wrk = wrk_client.Wrk(server_addr=addr, ssl=ssl)
     wrk.set_script(client['id'] + "_script", content="")
     return wrk