Validate MX records during recordset create or update
If invalid MX record is provided during recordset create command or valid record is updated to invalid record using recordset set command, causes recordset creation/updation failure. This leads to zone enter in ERROR state and all further recordset creation calls fail. Validate the records within recordset during create or update call. Closes-Bug: #1927304 Change-Id: I0ace4d6c4ad6a6ee236e3af23805b01345d60a42
This commit is contained in:
parent
63563a5098
commit
536315e38c
@ -35,6 +35,9 @@ class MX(Record):
|
||||
if repr(int(priority)) != priority:
|
||||
raise ValueError('Value is not an integer')
|
||||
|
||||
if not exchange.endswith('.'):
|
||||
raise ValueError('Domain %s does not end with a dot' % exchange)
|
||||
|
||||
self.priority = int(priority)
|
||||
self.exchange = exchange
|
||||
|
||||
|
@ -34,7 +34,18 @@ class RRDataMXTest(oslotest.base.BaseTestCase):
|
||||
record_set = objects.RecordSet(
|
||||
name='www.example.org.', type='MX',
|
||||
records=objects.RecordList(objects=[
|
||||
objects.Record(data='-0 mail.example.org.',
|
||||
objects.Record(data='-0 mail.example.test.',
|
||||
status='ACTIVE'),
|
||||
])
|
||||
)
|
||||
|
||||
self.assertRaises(InvalidObject, record_set.validate)
|
||||
|
||||
def test_validate_mx_not_fqdn(self):
|
||||
record_set = objects.RecordSet(
|
||||
name='www.example.org.', type='MX',
|
||||
records=objects.RecordList(objects=[
|
||||
objects.Record(data='10 mail.example.test',
|
||||
status='ACTIVE'),
|
||||
])
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user