app/lib/actions/katello/environment/destroy.rb in katello-4.7.6 vs app/lib/actions/katello/environment/destroy.rb in katello-4.8.0.rc1
- old
+ new
@@ -22,15 +22,21 @@
plan_action(ContentView::Remove, cve.content_view, :content_view_environments => [cve], :skip_repo_destroy => skip_repo_destroy, :organization_destroy => organization_destroy)
end
end
if organization_destroy
- env.hostgroups.clear
- env.hosts.clear
+ delete_host_and_hostgroup_associations(environment: env)
end
plan_self
end
+ end
+
+ def delete_host_and_hostgroup_associations(environment:)
+ environment.hostgroups.delete_all
+ host_ids = environment.hosts.ids
+ ::Katello::Host::ContentFacet.where(:host_id => host_ids).delete_all
+ ::Katello::Host::SubscriptionFacet.where(:host_id => host_ids).delete_all
end
def humanized_name
_("Delete Lifecycle Environment")
end