Move fingergw config to fingergw
We currently read the config in the fingergw app and put the config into the fingergw object. This gets ugly when adding more config options so move evaluation of the config file into the FingerGateway class. This is a preparation for adding ssl support to the FingerGateway which will need more config options. Depends-On: https://review.opendev.org/663413 Change-Id: I83f3863586b85f8befd84eb8f6079fa35ee3a8cb
This commit is contained in:
parent
bd1a669cc8
commit
46d0ed8e8f
|
@ -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,
|
||||
|
@ -98,11 +99,14 @@ class TestComponentRegistry(ZuulTestCase):
|
|||
self.assertComponentStopped("merger")
|
||||
|
||||
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
|
||||
)
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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(),
|
||||
)
|
||||
|
|
|
@ -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…
Reference in New Issue