Updated hostgroup plugins module to where it can at least be imported

This commit is contained in:
Jason Gerard DeRose
2009-01-14 22:10:09 -07:00
parent ec14fbfbc5
commit 64c072b7b3
2 changed files with 33 additions and 18 deletions
+17
View File
@@ -54,6 +54,19 @@ CRUD base classes:
* The Retrieve method should add in the common Flag('all') option for
retrieving all attributes.
* We probably need some LDAP centric crud method base classes, like
LDAPCreate, etc. Or other options it to have an LDAPObject base class and
have the crud Method plugins rely more on their corresponding Object plugin.
Existing plugins:
* Many existing plugins that are doing crud-type operations aren't using the
Object + Method way of defining their parameters, and are therefore defining
the exact same parameter several times in a module. This should be fixed
one way or another... if there are deficiencies in the crud base classes,
they need to be improved.
Command Line interface:
@@ -61,6 +74,10 @@ Command Line interface:
* Make possible Enum values self-documenting
* All "comma-separated list of..." parameters should really be changed to
multivalue and have a flag that tells the CLI whether a multivalue should
be parsed as comma-separated.
Improve ease of plugin writting
- make "from ipalib import *" import everything a plugin writter will need
+16 -18
View File
@@ -21,12 +21,10 @@
Frontend plugins for groups of hosts
"""
from ipalib import frontend
from ipalib import crud
from ipalib.frontend import Param
from ipalib import api
from ipalib import errors
from ipalib import ipa_types
from ipalib import api, crud, errors
from ipalib import Object, Command # Plugin base classes
from ipalib import Str # Parameter types
hostgroup_filter = "groupofnames)(!(objectclass=posixGroup)"
@@ -43,18 +41,18 @@ def get_members(members):
return members
class hostgroup(frontend.Object):
class hostgroup(Object):
"""
Host Group object.
"""
takes_params = (
Param('description',
Str('description',
doc='A description of this group',
),
Param('cn',
Str('cn',
cli_name='name',
primary_key=True,
normalize=lambda value: value.lower(),
normalizer=lambda value: value.lower(),
)
)
api.register(hostgroup)
@@ -220,14 +218,14 @@ class hostgroup_show(crud.Get):
api.register(hostgroup_show)
class hostgroup_add_member(frontend.Command):
class hostgroup_add_member(Command):
'Add a member to a group.'
takes_args = (
Param('group', primary_key=True),
Str('group', primary_key=True),
)
takes_options = (
Param('groups?', doc='comma-separated list of host groups to add'),
Param('hosts?', doc='comma-separated list of hosts to add'),
Str('groups?', doc='comma-separated list of host groups to add'),
Str('hosts?', doc='comma-separated list of hosts to add'),
)
def execute(self, cn, **kw):
"""
@@ -288,14 +286,14 @@ class hostgroup_add_member(frontend.Command):
api.register(hostgroup_add_member)
class hostgroup_remove_member(frontend.Command):
class hostgroup_remove_member(Command):
'Remove a member from a group.'
takes_args = (
Param('group', primary_key=True),
Str('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'),
Str('hosts?', doc='comma-separated list of hosts to add'),
Str('groups?', doc='comma-separated list of groups to remove'),
)
def execute(self, cn, **kw):
"""