When adding a hostgroup check for current existence of hostgroup and
netgroup
The netgroup gets added automatically so we need to check in advance for
it. But we also need to look for the hostgroup otherwise the error
message is confusing (netgroup already exists).
Also convert to using existing already_exists handler.
rob
>From 775285f21016f792c374f5ef5cc8452ac7f6a098 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <[email protected]>
Date: Fri, 14 Oct 2011 15:33:57 -0400
Subject: [PATCH] When adding a hostgroup check for current existence of
hostgroup and netgroup
The netgroup gets added automatically so we need to check in advance for it.
But we also need to look for the hostgroup otherwise the error message
is confusing (netgroup already exists).
https://fedorahosted.org/freeipa/ticket/1914
---
ipalib/plugins/hostgroup.py | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py
index 0560bd7..d1d144a 100644
--- a/ipalib/plugins/hostgroup.py
+++ b/ipalib/plugins/hostgroup.py
@@ -117,10 +117,16 @@ class hostgroup_add(LDAPCreate):
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
try:
+ hostgroup = api.Command['hostgroup_show'](keys[-1])
+ self.obj.handle_duplicate_entry(keys[-1])
+ except errors.NotFound:
+ pass
+ try:
netgroup = api.Command['netgroup_show'](keys[-1])
- raise errors.DuplicateEntry(message=unicode(_(\
- u'netgroup with name "%s" already exists' % keys[-1]\
- )))
+ raise errors.DuplicateEntry(message=self.obj.already_exists_msg % {
+ 'pkey': keys[-1], 'oname': self.api.Object['netgroup'].object_name,
+ }
+ )
except errors.NotFound:
pass
--
1.7.6
_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel