Merge "Move fingergw config to fingergw"

This commit is contained in:
Zuul 2021-07-24 12:54:01 +00:00 committed by Gerrit Code Review
commit cdcb895323
4 changed files with 35 additions and 28 deletions

View File

@ -25,6 +25,7 @@ class TestComponentRegistry(ZuulTestCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.host = '::'
self.zk_client = ZooKeeperClient( self.zk_client = ZooKeeperClient(
self.zk_chroot_fixture.zk_hosts, self.zk_chroot_fixture.zk_hosts,
tls_cert=self.zk_chroot_fixture.zookeeper_cert, tls_cert=self.zk_chroot_fixture.zookeeper_cert,
@ -108,11 +109,14 @@ class TestComponentRegistry(ZuulTestCase):
raise raise
def test_fingergw_component(self): def test_fingergw_component(self):
self.config.read_dict({
'fingergw': {
'listen_address': self.host,
'port': '0',
}
})
gateway = FingerGateway( gateway = FingerGateway(
self.config, self.config,
("127.0.0.1", self.gearman_server.port, None, None, None),
("127.0.0.1", 0),
user=None,
command_socket=None, command_socket=None,
pid_file=None pid_file=None
) )

View File

@ -522,11 +522,15 @@ class TestStreaming(tests.base.AnsibleZuulTestCase):
self.addCleanup(logfile.close) self.addCleanup(logfile.close)
# Start the finger gateway daemon # Start the finger gateway daemon
self.config.read_dict({
'fingergw': {
'listen_address': self.host,
'port': '0',
}
})
gateway = FingerGateway( gateway = FingerGateway(
self.config, self.config,
('127.0.0.1', self.gearman_server.port, None, None, None),
(self.host, 0),
user=None,
command_socket=None, command_socket=None,
pid_file=None pid_file=None
) )

View File

@ -59,24 +59,12 @@ class FingerGatewayApp(zuul.cmd.ZuulDaemonApp):
self.setup_logging('fingergw', 'log_config') self.setup_logging('fingergw', 'log_config')
self.log = logging.getLogger('zuul.fingergw') self.log = logging.getLogger('zuul.fingergw')
# Get values from configuration file
host = get_default(self.config, 'fingergw', 'listen_address', '::')
port = int(get_default(self.config, 'fingergw', 'port', 79))
user = get_default(self.config, 'fingergw', 'user', None)
cmdsock = get_default( cmdsock = get_default(
self.config, 'fingergw', 'command_socket', self.config, 'fingergw', 'command_socket',
'/var/lib/zuul/%s.socket' % self.app_name) '/var/lib/zuul/%s.socket' % self.app_name)
gear_server = get_default(self.config, 'gearman', 'server')
gear_port = get_default(self.config, 'gearman', 'port', 4730)
ssl_key = get_default(self.config, 'gearman', 'ssl_key')
ssl_cert = get_default(self.config, 'gearman', 'ssl_cert')
ssl_ca = get_default(self.config, 'gearman', 'ssl_ca')
self.gateway = FingerGateway( self.gateway = FingerGateway(
self.config, self.config,
(gear_server, gear_port, ssl_key, ssl_cert, ssl_ca),
(host, port),
user,
cmdsock, cmdsock,
self.getPidFile(), self.getPidFile(),
) )

View File

@ -17,14 +17,16 @@ import logging
import socket import socket
import threading import threading
from configparser import ConfigParser from configparser import ConfigParser
from typing import Optional, Tuple from typing import Optional
import zuul.rpcclient import zuul.rpcclient
from zuul.lib import streamer_utils from zuul.lib import streamer_utils
from zuul.lib.commandsocket import CommandSocket from zuul.lib.commandsocket import CommandSocket
from zuul.lib.config import get_default
from zuul.zk import ZooKeeperClient from zuul.zk import ZooKeeperClient
from zuul.zk.components import FingerGatewayComponent from zuul.zk.components import FingerGatewayComponent
COMMANDS = ['stop'] COMMANDS = ['stop']
@ -106,9 +108,6 @@ class FingerGateway(object):
def __init__( def __init__(
self, self,
config: ConfigParser, config: ConfigParser,
gearman: Tuple,
address: Tuple,
user: Optional[str],
command_socket: Optional[str], command_socket: Optional[str],
pid_file: Optional[str], pid_file: Optional[str],
): ):
@ -124,12 +123,24 @@ class FingerGateway(object):
:param str command_socket: Path to the daemon command socket. :param str command_socket: Path to the daemon command socket.
:param str pid_file: Path to the daemon PID file. :param str pid_file: Path to the daemon PID file.
''' '''
self.gear_server = gearman[0]
self.gear_port = gearman[1] gear_server = get_default(config, 'gearman', 'server')
self.gear_ssl_key = gearman[2] gear_port = get_default(config, 'gearman', 'port', 4730)
self.gear_ssl_cert = gearman[3] gear_ssl_key = get_default(config, 'gearman', 'ssl_key')
self.gear_ssl_ca = gearman[4] gear_ssl_cert = get_default(config, 'gearman', 'ssl_cert')
self.address = address gear_ssl_ca = get_default(config, 'gearman', 'ssl_ca')
self.gear_server = gear_server
self.gear_port = gear_port
self.gear_ssl_key = gear_ssl_key
self.gear_ssl_cert = gear_ssl_cert
self.gear_ssl_ca = gear_ssl_ca
host = get_default(config, 'fingergw', 'listen_address', '::')
port = int(get_default(config, 'fingergw', 'port', 79))
user = get_default(config, 'fingergw', 'user', None)
self.address = (host, port)
self.user = user self.user = user
self.pid_file = pid_file self.pid_file = pid_file