summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-11-04 14:03:43 -0500
committerRob Crittenden <rcritten@redhat.com>2008-11-04 14:03:43 -0500
commite825bc7ccbc787e65efa7171e9f19793bcd88615 (patch)
tree2285491e5407a46d1ab7239280622bcbfd3085cf /ipalib
parent49670023591f8eb88dd5860fffc3f8e99764e5a8 (diff)
downloadfreeipa-e825bc7ccbc787e65efa7171e9f19793bcd88615.tar.gz
freeipa-e825bc7ccbc787e65efa7171e9f19793bcd88615.tar.xz
freeipa-e825bc7ccbc787e65efa7171e9f19793bcd88615.zip
Revive the hostgroup_container and include add/remove hosts in hostgroups plugin
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/constants.py1
-rw-r--r--ipalib/plugins/f_hostgroup.py28
2 files changed, 27 insertions, 2 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py
index 99b0ea719..9bd82a1bf 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -69,6 +69,7 @@ DEFAULT_CONFIG = (
('container_group', 'cn=groups,cn=accounts'),
('container_service', 'cn=services,cn=accounts'),
('container_host', 'cn=computers,cn=accounts'),
+ ('container_hostgroup', 'cn=hostgroups,cn=accounts'),
# Ports, hosts, and URIs:
('lite_xmlrpc_port', 8888),
diff --git a/ipalib/plugins/f_hostgroup.py b/ipalib/plugins/f_hostgroup.py
index 27aea00c6..8e4c37407 100644
--- a/ipalib/plugins/f_hostgroup.py
+++ b/ipalib/plugins/f_hostgroup.py
@@ -222,7 +222,8 @@ class hostgroup_add_member(frontend.Command):
Param('group', primary_key=True),
)
takes_options = (
- Param('groups?', doc='comma-separated list of groups to add'),
+ Param('groups?', doc='comma-separated list of host groups to add'),
+ Param('hosts?', doc='comma-separated list of hosts to add'),
)
def execute(self, cn, **kw):
"""
@@ -231,7 +232,8 @@ class hostgroup_add_member(frontend.Command):
Returns the updated group entry
:param cn: The group name to add new members to.
- :param kw: groups is a comma-separated list of groups to add
+ :param kw: groups is a comma-separated list of host groups to add
+ :param kw: hosts is a comma-separated list of hosts to add
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("cn", cn, hostgroup_filter)
@@ -249,6 +251,16 @@ class hostgroup_add_member(frontend.Command):
add_failed.append(m)
continue
+ members = kw.get('hosts', '').split(',')
+ for m in members:
+ if not m: continue
+ try:
+ member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
+ to_add.append(member_dn)
+ except errors.NotFound:
+ add_failed.append(m)
+ continue
+
for member_dn in to_add:
try:
ldap.add_member_to_group(member_dn, dn)
@@ -278,6 +290,7 @@ class hostgroup_remove_member(frontend.Command):
Param('group', primary_key=True),
)
takes_options = (
+ Param('hosts?', doc='comma-separated list of hosts to add'),
Param('groups?', doc='comma-separated list of groups to remove'),
)
def execute(self, cn, **kw):
@@ -288,6 +301,7 @@ class hostgroup_remove_member(frontend.Command):
:param cn: The group name to add new members to.
:param kw: groups is a comma-separated list of groups to remove
+ :param kw: hosts is a comma-separated list of hosts to add
"""
ldap = self.api.Backend.ldap
dn = ldap.find_entry_dn("cn", cn, hostgroup_filter)
@@ -305,6 +319,16 @@ class hostgroup_remove_member(frontend.Command):
remove_failed.append(m)
continue
+ members = kw.get('hosts', '').split(',')
+ for m in members:
+ if not m: continue
+ try:
+ member_dn = ldap.find_entry_dn("cn", m, "ipaHost")
+ to_remove.append(member_dn)
+ except errors.NotFound:
+ remove_failed.append(m)
+ continue
+
for member_dn in to_remove:
try:
ldap.remove_member_from_group(member_dn, dn)