Skip to content

Function change_ip throws error if the zone does not have any A records #136

@bigbigblake

Description

@bigbigblake

If you have a zone that does not actually contain any A records this function will fail.

my_zones = get_all_zones()

oldIP = ['10.1.2.3', '10.1.2.4']
newIP = ['10.1.2.6', '10.1.2.8']

for zone in my_zones:
    if (zone.name != 'problem zone'):
        changedRecords = change_ip(zone, oldIP, newIP, v6=False, publish=True)

The utility fails with this error:

Traceback (most recent call last):
File "C:/Users/blahblah/PycharmProjects/DynReader/DynModifier.py", line 26, in
changedRecords = change_ip(zone, oldIP, newIP, v6=False, publish=True)
File "C:\Users\blahblah\PycharmProjects\DynReader\venv\lib\site-packages\dyn\tm\tools.py", line 30, in change_ip
records = records['aaaa_records'] if v6 else records['a_records']
KeyError: 'a_records'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions