Merge "Consolidate default port numbers into utils.py"
This commit is contained in:
commit
d205737aa0
@ -13,8 +13,11 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from designate.utils import DEFAULT_AGENT_PORT
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='service:agent', title="Configuration for the Agent Service"
|
||||
))
|
||||
@ -33,7 +36,7 @@ OPTS = [
|
||||
deprecated_reason="Replaced by 'listen' option",
|
||||
help='Agent Port Number'),
|
||||
cfg.ListOpt('listen',
|
||||
default=['0.0.0.0:5358'],
|
||||
default=['0.0.0.0:%d' % DEFAULT_AGENT_PORT],
|
||||
help='Agent host:port pairs to listen on'),
|
||||
cfg.IntOpt('tcp-backlog', default=100,
|
||||
help='The Agent TCP Backlog'),
|
||||
|
@ -31,13 +31,14 @@ from designate import dnsutils
|
||||
from designate import service
|
||||
from designate.agent import handler
|
||||
from designate.backend import agent_backend
|
||||
from designate.utils import DEFAULT_AGENT_PORT
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class Service(service.DNSService, service.Service):
|
||||
_dns_default_port = 5358
|
||||
_dns_default_port = DEFAULT_AGENT_PORT
|
||||
|
||||
def __init__(self, threads=None):
|
||||
super(Service, self).__init__(threads=threads)
|
||||
|
@ -41,6 +41,7 @@ from designate.i18n import _LW
|
||||
from designate.backend import base
|
||||
from designate import exceptions
|
||||
from designate.mdns import rpcapi as mdns_api
|
||||
from designate.utils import DEFAULT_AGENT_PORT
|
||||
import designate.backend.private_codes as pcodes
|
||||
|
||||
dns_query = eventlet.import_patched('dns.query')
|
||||
@ -57,8 +58,7 @@ class AgentPoolBackend(base.Backend):
|
||||
def __init__(self, target):
|
||||
super(AgentPoolBackend, self).__init__(target)
|
||||
self.host = self.options.get('host', '127.0.0.1')
|
||||
# TODO(Federico): move all port defaults into a defaults module
|
||||
self.port = int(self.options.get('port', 5358))
|
||||
self.port = int(self.options.get('port', DEFAULT_AGENT_PORT))
|
||||
self.timeout = CONF['service:pool_manager'].poll_timeout
|
||||
self.retry_interval = CONF['service:pool_manager'].poll_retry_interval
|
||||
self.max_retries = CONF['service:pool_manager'].poll_max_retries
|
||||
|
@ -27,10 +27,11 @@ from oslo_utils import strutils
|
||||
from designate import exceptions
|
||||
from designate import utils
|
||||
from designate.backend import base
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
DEFAULT_MASTER_PORT = 5354
|
||||
DEFAULT_MASTER_PORT = DEFAULT_MDNS_PORT
|
||||
|
||||
|
||||
class Bind9Backend(base.Backend):
|
||||
|
@ -13,9 +13,11 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from designate import dnsutils
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
@ -36,7 +38,7 @@ OPTS = [
|
||||
deprecated_reason="Replaced by 'listen' option",
|
||||
help='mDNS Port Number'),
|
||||
cfg.ListOpt('listen',
|
||||
default=['0.0.0.0:5354'],
|
||||
default=['0.0.0.0:%d' % DEFAULT_MDNS_PORT],
|
||||
help='mDNS host:port pairs to listen on'),
|
||||
cfg.IntOpt('tcp-backlog', default=100,
|
||||
help='mDNS TCP Backlog'),
|
||||
|
@ -23,13 +23,14 @@ from designate import dnsutils
|
||||
from designate.mdns import handler
|
||||
from designate.mdns import notify
|
||||
from designate.mdns import xfr
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class Service(service.DNSService, service.RPCService, service.Service):
|
||||
_dns_default_port = 5354
|
||||
_dns_default_port = DEFAULT_MDNS_PORT
|
||||
|
||||
@property
|
||||
def storage(self):
|
||||
|
@ -13,7 +13,9 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from designate.tests import TestCase
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
POOL_DICT = {
|
||||
'id': u'794ccc2c-d751-44fe-b57f-8894c9f5c842',
|
||||
@ -25,7 +27,7 @@ POOL_DICT = {
|
||||
'masters': [
|
||||
{
|
||||
'host': '127.0.0.1',
|
||||
'port': 5354
|
||||
'port': DEFAULT_MDNS_PORT
|
||||
}
|
||||
],
|
||||
'options': {}
|
||||
@ -36,7 +38,7 @@ POOL_DICT = {
|
||||
'masters': [
|
||||
{
|
||||
'host': '127.0.0.1',
|
||||
'port': 5354
|
||||
'port': DEFAULT_MDNS_PORT
|
||||
}
|
||||
],
|
||||
'options': {}
|
||||
|
@ -24,6 +24,7 @@ from oslo_log import log as logging
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
from designate.storage.base import Storage as StorageBase
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -1913,7 +1914,8 @@ class StorageTestCase(object):
|
||||
'targets': [{
|
||||
'type': "fake",
|
||||
'description': u"FooBar",
|
||||
'masters': [{'host': "192.0.2.2", 'port': 5354}],
|
||||
'masters': [{'host': "192.0.2.2",
|
||||
'port': DEFAULT_MDNS_PORT}],
|
||||
'options': [{'key': 'fake_option', 'value': 'fake_value'}],
|
||||
}],
|
||||
'also_notifies': [{'host': "192.0.2.3", 'port': 53}]
|
||||
@ -2069,7 +2071,8 @@ class StorageTestCase(object):
|
||||
'targets': [{
|
||||
'type': "fake",
|
||||
'description': u"FooBar",
|
||||
'masters': [{'host': "192.0.2.2", 'port': 5354}],
|
||||
'masters': [{'host': "192.0.2.2",
|
||||
'port': DEFAULT_MDNS_PORT}],
|
||||
'options': [{'key': 'fake_option', 'value': 'fake_value'}],
|
||||
}],
|
||||
'also_notifies': [{'host': "192.0.2.3", 'port': 53}]
|
||||
@ -2093,7 +2096,8 @@ class StorageTestCase(object):
|
||||
'targets': [{
|
||||
'type': "fake",
|
||||
'description': u"NewFooBar",
|
||||
'masters': [{'host': "192.0.2.2", 'port': 5354}],
|
||||
'masters': [{'host': "192.0.2.2",
|
||||
'port': DEFAULT_MDNS_PORT}],
|
||||
'options': [{'key': 'fake_option', 'value': 'fake_value'}],
|
||||
}, {
|
||||
'type': "fake",
|
||||
|
@ -22,6 +22,7 @@ import oslotest.base
|
||||
from designate import objects
|
||||
from designate.objects import adapters
|
||||
from designate.tests import resources
|
||||
from designate.utils import DEFAULT_MDNS_PORT
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -68,7 +69,8 @@ class DesignateYAMLAdapterTest(oslotest.base.BaseTestCase):
|
||||
'PowerDNS Database Cluster', r_pool.targets[0].description)
|
||||
self.assertEqual(1, len(r_pool.targets[0].masters))
|
||||
self.assertEqual('192.0.2.1', r_pool.targets[0].masters[0].host)
|
||||
self.assertEqual(5354, r_pool.targets[0].masters[0].port)
|
||||
self.assertEqual(DEFAULT_MDNS_PORT,
|
||||
r_pool.targets[0].masters[0].port)
|
||||
self.assertEqual(1, len(r_pool.targets[0].options))
|
||||
self.assertEqual('connection', r_pool.targets[0].options[0].key)
|
||||
self.assertEqual(
|
||||
@ -127,7 +129,7 @@ class DesignateYAMLAdapterTest(oslotest.base.BaseTestCase):
|
||||
{
|
||||
'host': u'192.0.2.1',
|
||||
'pool_target_id': u'd567d569-2d69-41d5-828d-f7054bb10b5c', # noqa
|
||||
'port': 5354,
|
||||
'port': DEFAULT_MDNS_PORT,
|
||||
}
|
||||
],
|
||||
'options': [
|
||||
|
@ -61,6 +61,11 @@ proxy_opts = [
|
||||
|
||||
cfg.CONF.register_opts(proxy_opts, group='proxy')
|
||||
|
||||
# Default TCP/UDP ports
|
||||
|
||||
DEFAULT_AGENT_PORT = 5358
|
||||
DEFAULT_MDNS_PORT = 5354
|
||||
|
||||
|
||||
def find_config(config_path):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user