Add also-notifies support to Pool Manager
Change-Id: I2bf72390fde1fc0296df684074260cfe5ff1d883
This commit is contained in:
parent
3386d9539c
commit
15a81095c5
@ -24,6 +24,7 @@ from designate.objects.domain_attribute import DomainAttribute, DomainAttributeL
|
||||
from designate.objects.floating_ip import FloatingIP, FloatingIPList # noqa
|
||||
from designate.objects.pool_manager_status import PoolManagerStatus, PoolManagerStatusList # noqa
|
||||
from designate.objects.pool import Pool, PoolList # noqa
|
||||
from designate.objects.pool_also_notifies import PoolAlsoNotifies, PoolAlsoNotifiesList # noqa
|
||||
from designate.objects.pool_attribute import PoolAttribute, PoolAttributeList # noqa
|
||||
from designate.objects.pool_ns_record import PoolNsRecord, PoolNsRecordList # noqa
|
||||
from designate.objects.pool_nameserver import PoolNameserver, PoolNameserverList # noqa
|
||||
|
@ -68,6 +68,10 @@ class Pool(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
'relation': True,
|
||||
'relation_cls': 'PoolTargetList'
|
||||
},
|
||||
'also_notifies': {
|
||||
'relation': True,
|
||||
'relation_cls': 'PoolAlsoNotifiesList'
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@ -76,6 +80,7 @@ class Pool(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
|
||||
pool_target_ids = CONF['pool:%s' % pool_id].targets
|
||||
pool_nameserver_ids = CONF['pool:%s' % pool_id].nameservers
|
||||
pool_also_notifies = CONF['pool:%s' % pool_id].also_notifies
|
||||
|
||||
# Build Base Pool
|
||||
pool = {
|
||||
@ -83,8 +88,17 @@ class Pool(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
'description': 'Pool built from configuration on %s' % CONF.host,
|
||||
'targets': [],
|
||||
'nameservers': [],
|
||||
'also_notifies': [],
|
||||
}
|
||||
|
||||
# Build Pool Also Notifies
|
||||
for pool_also_notify in pool_also_notifies:
|
||||
host, port = utils.split_host_port(pool_also_notify)
|
||||
pool['also_notifies'].append({
|
||||
'host': host,
|
||||
'port': port,
|
||||
})
|
||||
|
||||
# Build Pool Targets
|
||||
for pool_target_id in pool_target_ids:
|
||||
pool_target_group = 'pool_target:%s' % pool_target_id
|
||||
|
28
designate/objects/pool_also_notifies.py
Normal file
28
designate/objects/pool_also_notifies.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2014 Rackspace Hosting
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# 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.objects import base
|
||||
|
||||
|
||||
class PoolAlsoNotifies(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
base.DesignateObject):
|
||||
FIELDS = {
|
||||
'pool_id': {},
|
||||
'host': {},
|
||||
'port': {},
|
||||
}
|
||||
|
||||
|
||||
class PoolAlsoNotifiesList(base.ListObjectMixin, base.DesignateObject):
|
||||
LIST_ITEM_TYPE = PoolAlsoNotifies
|
@ -71,6 +71,7 @@ def register_dynamic_pool_options():
|
||||
pool_opts = [
|
||||
cfg.ListOpt('targets', default=[]),
|
||||
cfg.ListOpt('nameservers', default=[]),
|
||||
cfg.ListOpt('also_notifies', default=[]),
|
||||
]
|
||||
|
||||
CONF.register_group(pool_group)
|
||||
|
@ -251,6 +251,10 @@ class Service(service.RPCService, service.Service):
|
||||
|
||||
return
|
||||
|
||||
# Send a NOTIFY to each also-notifies
|
||||
for also_notify in self.pool.also_notifies:
|
||||
self._update_domain_on_also_notify(context, also_notify, domain)
|
||||
|
||||
# Send a NOTIFY to each nameserver
|
||||
for nameserver in self.pool.nameservers:
|
||||
create_status = self._build_status_object(
|
||||
@ -308,6 +312,10 @@ class Service(service.RPCService, service.Service):
|
||||
|
||||
return
|
||||
|
||||
# Send a NOTIFY to each also-notifies
|
||||
for also_notify in self.pool.also_notifies:
|
||||
self._update_domain_on_also_notify(context, also_notify, domain)
|
||||
|
||||
# Send a NOTIFY to each nameserver
|
||||
for nameserver in self.pool.nameservers:
|
||||
# See if there is already another update in progress
|
||||
@ -342,6 +350,15 @@ class Service(service.RPCService, service.Service):
|
||||
{'domain': domain.name, 'target': target.id})
|
||||
return False
|
||||
|
||||
def _update_domain_on_also_notify(self, context, also_notify, domain):
|
||||
LOG.info(_LI('Updating domain %(domain)s on also_notify %(server)s.') %
|
||||
{'domain': domain.name,
|
||||
'server': self._get_destination(also_notify)})
|
||||
|
||||
self.mdns_api.notify_zone_changed(
|
||||
context, domain, also_notify, self.timeout, self.retry_interval,
|
||||
self.max_retries, 0)
|
||||
|
||||
def _update_domain_on_nameserver(self, context, nameserver, domain):
|
||||
LOG.info(_LI('Updating domain %(domain)s on nameserver %(server)s.') %
|
||||
{'domain': domain.name,
|
||||
|
@ -55,6 +55,7 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase):
|
||||
'c5d64303-4cba-425a-9f3c-5d708584dde4',
|
||||
'c67cdc95-9a9e-4d2a-98ed-dc78cbd85234',
|
||||
]),
|
||||
cfg.ListOpt('also_notifies', default=[]),
|
||||
]
|
||||
cfg.CONF.register_group(cfg.OptGroup(name=section_name))
|
||||
cfg.CONF.register_opts(section_opts, group=section_name)
|
||||
|
@ -252,6 +252,7 @@ debug = False
|
||||
#[pool:794ccc2c-d751-44fe-b57f-8894c9f5c842]
|
||||
#nameservers = 0f66b842-96c2-4189-93fc-1dc95a08b012
|
||||
#targets = f26e0b32-736f-4f0a-831b-039a415c481e
|
||||
#also_notifies = 192.0.2.1:53, 192.0.2.2:53
|
||||
|
||||
#[pool_nameserver:0f66b842-96c2-4189-93fc-1dc95a08b012]
|
||||
#port = 53
|
||||
|
Loading…
Reference in New Issue
Block a user