Unable to delete host tied back to activation key
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1122736
Description of problem:
I tried to delete a host and received a trace. Afterwards I could not view the host details though I could see it in the host list
Version-Release number of selected component (if applicable):
Uncertain, but based on the additional info, probably always
Steps to Reproduce:
1. Create an Activation Key
2. Create a Host and include the activation key
Can't delete the host without error
Host should delete as expected
I had to do the following:
delete from hosts where id = 7;
ERROR: update or delete on table "hosts" violates foreign key constraint "katello_systems_host_id" on table "katello_systems"
DETAIL: Key (id)=(7) is still referenced from table "katello_systems".
delete from katello_systems where id = 11;
ERROR: update or delete on table "katello_systems" violates foreign key constraint "system_activation_keys_system_id_fk" on table "katello_system_activation_keys"
DETAIL: Key (id)=(11) is still referenced from table "katello_system_activation_keys".
foreman=# delete from katello_system_activation_keys where id = 11;
foreman=# delete from katello_systems where id = 11;
foreman=# delete from hosts where id = 7;
fixes #7005 / BZ 1122736 - content host - change registration behavior with foreman host
This commit alters the behavior of registering a content host
(with or without an activation key) that is to be associated
with a foreman host to do the following:
1. identify the foreman host that this content host will be
associated with by both name and mac address (previously
it was only by name)
2. if the foreman host identified is already associated with a
content host, delete it and then create/associate a new one.
(This will avoid there becoming duplicate content hosts with
the same name.)