Skip to content

host remove prints deletion message for associated records when host deletion fails #437

Description

@pederhan

These messages are added to the output buffer before the host itself is deleted:

# Require force if host has any NAPTR records. Delete the NAPTR records if
# force
naptrs = host.naptrs
if len(naptrs) > 0:
if not forced(Override.NAPTR):
overrides_required.add(Override.NAPTR)
warnings.append(f" {len(naptrs)} NAPTR records")
for naptr in naptrs:
warnings.append(f" - {naptr.replacement}")
else:
for naptr in naptrs:
OutputManager().add_ok(
"deleted NAPTR record {} when removing {}".format(
naptr.replacement,
host.name,
)
)
# Require force if host has any SRV records. Delete the SRV records if force
srvs = host.srvs
if len(srvs) > 0:
if not forced(Override.SRV):
overrides_required.add(Override.SRV)
warnings.append(f" {len(srvs)} SRV records")
for srv in srvs:
warnings.append(f" - {srv.name}")
else:
for srv in srvs:
OutputManager().add_ok(
"deleted SRV record {} when removing {}".format(
srv.name,
host.name,
)
)
# Require force if host has any PTR records. Delete the PTR records if force
if len(host.ptr_overrides) > 0:
if not forced(Override.PTR):
overrides_required.add(Override.PTR)
warnings.append(f" {len(host.ptr_overrides)} PTR records")
for ptr in host.ptr_overrides:
warnings.append(f" - {ptr.ipaddress}")
else:
for ptr in host.ptr_overrides:
OutputManager().add_ok(
"deleted PTR record {} when removing {}".format(
ptr.ipaddress,
host.name,
)
)

If the host deletion fails, these messages will still be printed, even though no such deletions took place. We should only add these messages to the output buffer after the actual API delete call goes through.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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