diff --git management/univention-directory-manager-modules/univention-dnsedit management/univention-directory-manager-modules/univention-dnsedit index fa1759c..caff6b4 100755 --- management/univention-directory-manager-modules/univention-dnsedit +++ management/univention-directory-manager-modules/univention-dnsedit @@ -285,6 +285,28 @@ def add_a_record(name, *adresses): record.create() +def remove_a_record(name, *adresses): + """Remove DNS IPv4 address records.""" + filt = univention.admin.filter.expression('name', name) + records = host_record.lookup(co, lo, filt, scope='domain', base=position.getDomain(), superordinate=zone, unique=True) + if records: + record = records[0] + else: + print("No record found", file=sys.stderr) + return + + tmp = record['a'] + for addr in adresses: + if addr in tmp: + tmp.remove(addr) + record['a'] = tmp + + if record['a']: + record.modify() + else: + record.remove() + + def add_cname_record(name, cname): """Add DNS canonical name record.""" filt = univention.admin.filter.expression('name', name) @@ -440,6 +462,8 @@ def main(): remove_srv_record(*args) elif typ == 'ns': remove_ns_record(*args) + elif typ == 'a': + remove_a_record(*args) else: parser.error('Unknown type "%s"' % (typ,)) except univention.admin.uexceptions.objectExists as ex: