fix: apply_cell_name regex now matches zone files with TTL field

_generate_zone_content writes records as "name TTL IN A value" but the
regex only matched "name IN A value" (no TTL), so renaming the cell
never updated the DNS hostname record. Updated regex to make TTL optional.
Also fixed the unit test zone fixture to use the actual generated format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 09:32:51 -04:00
parent 10eac1fda1
commit 2455fe189e
2 changed files with 15 additions and 9 deletions
+2 -1
View File
@@ -520,8 +520,9 @@ class NetworkManager(BaseServiceManager):
zone_file = os.path.join(dns_data, fname)
with open(zone_file) as f:
content = f.read()
# Match name with optional TTL: "name [ttl] IN A value"
content = re.sub(
rf'^{re.escape(old_name)}(\s+IN\s+A\s+)',
rf'^{re.escape(old_name)}(\s+(?:\d+\s+)?IN\s+A\s+)',
f'{new_name}\\1',
content, flags=re.MULTILINE
)