Browse Source

Merge "Move fingergw config to fingergw"

changes/49/801749/2
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
cdcb895323
  1. 10
      tests/unit/test_component_registry.py
  2. 10
      tests/unit/test_streaming.py
  3. 12
      zuul/cmd/fingergw.py
  4. 31
      zuul/lib/fingergw.py

10
tests/unit/test_component_registry.py

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

10
tests/unit/test_streaming.py

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

12
zuul/cmd/fingergw.py

@ -59,24 +59,12 @@ class FingerGatewayApp(zuul.cmd.ZuulDaemonApp):
self.setup_logging('fingergw', 'log_config')
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(
self.config, 'fingergw', 'command_socket',
'/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.config,
(gear_server, gear_port, ssl_key, ssl_cert, ssl_ca),
(host, port),
user,
cmdsock,
self.getPidFile(),
)

31
zuul/lib/fingergw.py

@ -17,14 +17,16 @@ import logging
import socket
import threading
from configparser import ConfigParser
from typing import Optional, Tuple
from typing import Optional
import zuul.rpcclient
from zuul.lib import streamer_utils
from zuul.lib.commandsocket import CommandSocket
from zuul.lib.config import get_default
from zuul.zk import ZooKeeperClient
from zuul.zk.components import FingerGatewayComponent
COMMANDS = ['stop']
@ -106,9 +108,6 @@ class FingerGateway(object):
def __init__(
self,
config: ConfigParser,
gearman: Tuple,
address: Tuple,
user: Optional[str],
command_socket: 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 pid_file: Path to the daemon PID file.
'''
self.gear_server = gearman[0]
self.gear_port = gearman[1]
self.gear_ssl_key = gearman[2]
self.gear_ssl_cert = gearman[3]
self.gear_ssl_ca = gearman[4]
self.address = address
gear_server = get_default(config, 'gearman', 'server')
gear_port = get_default(config, 'gearman', 'port', 4730)
gear_ssl_key = get_default(config, 'gearman', 'ssl_key')
gear_ssl_cert = get_default(config, 'gearman', 'ssl_cert')
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.pid_file = pid_file

Loading…
Cancel
Save