From 5e3cdb96432d820fcfcb0f951f9670736c1e5c6c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 8 May 2009 17:42:54 -0400 Subject: Remove all services when a host is removed Revoke certificate (if any) when a service is removed --- ipalib/plugins/host.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ipalib/plugins/host.py') diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index a7a590b6..c136ccab 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -140,7 +140,7 @@ class host_add(crud.Add): current = util.get_current_principal() if not current: - raise errors.NotFound('Unable to determine current user') + raise errors.NotFound(reason='Unable to determine current user') kw['enrolledby'] = ldap.find_entry_dn("krbPrincipalName", current, "posixAccount") # Get our configuration @@ -186,6 +186,17 @@ class host_del(crud.Del): """ ldap = self.api.Backend.ldap dn = get_host(hostname) + + # Remove all service records for this host + services=api.Command['service_find'](hostname, **{}) + + counter = services[0] + services = services[1:] + if counter > 0: + for s in services: + principal = s.get('krbprincipalname').decode('UTF-8') + api.Command['service_del'](principal, **{}) + return ldap.delete(dn) def output_for_cli(self, textui, result, *args, **options): """ -- cgit