Remove deprecated cfg in notification and add format-v6 test
- Remove 'format' cfg in nova and neutron notification - Modify related tests with 'format' cfg - Add formatv6 test-case for nova - Add releasenotes for these change. Change-Id: I5bcc7c59f23d8d66252ca6809fc78803c0bbdab7
This commit is contained in:
parent
bc24df1ee2
commit
5bab49582c
@ -117,14 +117,12 @@ class BaseAddressHandler(NotificationHandler):
|
||||
def _get_formatv4(self):
|
||||
return (
|
||||
cfg.CONF[self.name].get('formatv4') or
|
||||
cfg.CONF[self.name].get('format') or
|
||||
self.default_formatv4
|
||||
)
|
||||
|
||||
def _get_formatv6(self):
|
||||
return (
|
||||
cfg.CONF[self.name].get('formatv6') or
|
||||
cfg.CONF[self.name].get('format') or
|
||||
self.default_formatv6
|
||||
)
|
||||
|
||||
|
@ -135,5 +135,46 @@
|
||||
"architecture": null,
|
||||
"os_type": null
|
||||
},
|
||||
"payload_v6": {
|
||||
"state_description": "",
|
||||
"availability_zone": null,
|
||||
"ramdisk_id": "",
|
||||
"instance_type_id": 2,
|
||||
"deleted_at": "",
|
||||
"fixed_ips": [{
|
||||
"floating_ips": [],
|
||||
"label": "private",
|
||||
"version": 6,
|
||||
"meta": {},
|
||||
"address": "172.16.0.14",
|
||||
"type": "fixed"
|
||||
}],
|
||||
"memory_mb": 512,
|
||||
"user_id": "953f8394fa044302b7d42f47228e427d",
|
||||
"reservation_id": "r-1ekblkfw",
|
||||
"state": "active",
|
||||
"launched_at": "2012-11-03 17:54:48.514631",
|
||||
"metadata": [],
|
||||
"ephemeral_gb": 0,
|
||||
"access_ip_v6": null,
|
||||
"disk_gb": 0,
|
||||
"access_ip_v4": null,
|
||||
"kernel_id": "",
|
||||
"image_name": "ubuntu-precise",
|
||||
"host": "stack01",
|
||||
"display_name": "TestInstance",
|
||||
"image_ref_url": "http://192.0.2.98:9292/images/e52f1321-fb9e-40fb-8057-555a850462e8",
|
||||
"root_gb": 0,
|
||||
"tenant_id": "33a88272e06a49c1a0f653abc374b56b",
|
||||
"created_at": "2012-11-03 17:54:27",
|
||||
"instance_id": "3e301a55-fbbe-478d-92d0-eefabf135c38",
|
||||
"instance_type": "m1.tiny",
|
||||
"vcpus": 1,
|
||||
"image_meta": {
|
||||
"base_image_ref": "e52f1321-fb9e-40fb-8057-555a850462e8"
|
||||
},
|
||||
"architecture": null,
|
||||
"os_type": null
|
||||
},
|
||||
"priority": "INFO"
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
self.config(zone_id=zone['id'], group='handler:neutron_floatingip')
|
||||
formats = ['%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s',
|
||||
'%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.X.%(zone)s']
|
||||
self.config(format=formats, group='handler:neutron_floatingip')
|
||||
self.config(formatv4=formats, group='handler:neutron_floatingip')
|
||||
|
||||
self.plugin = NeutronFloatingHandler()
|
||||
|
||||
|
@ -32,8 +32,10 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
zone = self.create_zone()
|
||||
self.zone_id = zone['id']
|
||||
self.config(zone_id=zone['id'], group='handler:nova_fixed')
|
||||
self.config(format=['%(host)s.%(zone)s',
|
||||
'%(host)s.foo.%(zone)s'],
|
||||
self.config(formatv4=['%(host)s.%(zone)s',
|
||||
'%(host)s.foo.%(zone)s'],
|
||||
formatv6=['%(host)s.%(zone)s',
|
||||
'%(host)s.foo.%(zone)s'],
|
||||
group='handler:nova_fixed')
|
||||
|
||||
self.plugin = NovaFixedHandler()
|
||||
@ -62,7 +64,8 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
self.assertEqual(4, len(records))
|
||||
|
||||
def test_instance_create_end_utf8(self):
|
||||
self.config(format=['%(display_name)s.%(zone)s'],
|
||||
self.config(formatv4=['%(display_name)s.%(zone)s'],
|
||||
formatv6=['%(display_name)s.%(zone)s'],
|
||||
group='handler:nova_fixed')
|
||||
|
||||
event_type = 'compute.instance.create.end'
|
||||
@ -137,9 +140,10 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
|
||||
self.assertEqual(2, len(records))
|
||||
|
||||
def test_label_in_format(self):
|
||||
def test_label_in_format_v4_v6(self):
|
||||
event_type = 'compute.instance.create.end'
|
||||
self.config(format=['%(label)s.example.com'],
|
||||
self.config(formatv4=['%(label)s.example.com.'],
|
||||
formatv6=['%(label)s.example.com.'],
|
||||
group='handler:nova_fixed')
|
||||
fixture = self.get_notification_fixture('nova', event_type)
|
||||
with mock.patch.object(self.plugin, '_find_or_create_recordset')\
|
||||
@ -152,11 +156,11 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
event_type, fixture['payload'])
|
||||
finder.assert_called_once_with(
|
||||
mock.ANY, type='A', zone_id=self.zone_id,
|
||||
name='private.example.com')
|
||||
name='private.example.com.')
|
||||
|
||||
def test_formatv4_or_format(self):
|
||||
def test_formatv4(self):
|
||||
event_type = 'compute.instance.create.end'
|
||||
self.config(formatv4=['%(label)s-v4.example.com'],
|
||||
self.config(formatv4=['%(label)s-v4.example.com.'],
|
||||
group='handler:nova_fixed')
|
||||
fixture = self.get_notification_fixture('nova', event_type)
|
||||
with mock.patch.object(self.plugin, '_find_or_create_recordset')\
|
||||
@ -169,13 +173,11 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
event_type, fixture['payload'])
|
||||
finder.assert_called_once_with(
|
||||
mock.ANY, type='A', zone_id=self.zone_id,
|
||||
name='private-v4.example.com')
|
||||
name='private-v4.example.com.')
|
||||
|
||||
def test_formatv4_and_format(self):
|
||||
def test_formatv6(self):
|
||||
event_type = 'compute.instance.create.end'
|
||||
self.config(format=['%(label)s.example.com'],
|
||||
group='handler:nova_fixed')
|
||||
self.config(formatv4=['%(label)s-v4.example.com'],
|
||||
self.config(formatv6=['%(label)s-v6.example.com.'],
|
||||
group='handler:nova_fixed')
|
||||
fixture = self.get_notification_fixture('nova', event_type)
|
||||
with mock.patch.object(self.plugin, '_find_or_create_recordset')\
|
||||
@ -185,7 +187,7 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin):
|
||||
finder.return_value = {'id': 'fakeid'}
|
||||
self.plugin.process_notification(
|
||||
self.admin_context.to_dict(),
|
||||
event_type, fixture['payload'])
|
||||
event_type, fixture['payload_v6'])
|
||||
finder.assert_called_once_with(
|
||||
mock.ANY, type='A', zone_id=self.zone_id,
|
||||
name='private-v4.example.com')
|
||||
mock.ANY, type='AAAA', zone_id=self.zone_id,
|
||||
name='private-v6.example.com.')
|
||||
|
14
releasenotes/notes/cfg-notification-remove.yaml
Normal file
14
releasenotes/notes/cfg-notification-remove.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
critical:
|
||||
- The `format` cfg in nova and neutron notification both will remove in the Pike.
|
||||
Please set ``formatv4`` and ``formatv6`` in the ``[handler:nova_fixed]``
|
||||
and ``[handler:neutron_floatingip]`` your designate config file.
|
||||
|
||||
``formatv4 = '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s'``
|
||||
``formatv4 = '%(hostname)s.%(project)s.%(zone)s'``
|
||||
``formatv4 = '%(hostname)s.%(zone)s'``
|
||||
``formatv6 = '%(hostname)s.%(project)s.%(zone)s'``
|
||||
``formatv6 = '%(hostname)s.%(zone)s'``
|
||||
|
||||
- The above config which you need to put or uncomment them into/in
|
||||
designate config file.
|
Loading…
Reference in New Issue
Block a user