diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-12-09 09:09:53 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-12-10 08:29:15 -0700 |
commit | b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7 (patch) | |
tree | 7e5329a51af169ce34a7d275a1bbd63c1e31c026 /ipalib/plugins/host.py | |
parent | d08b8858ddc3bf6265f6ea8acae6661b9fff5112 (diff) | |
download | freeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.tar.gz freeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.tar.xz freeipa-b6e4972e7f6aa08e0392a2cf441b60ab0e7d88b7.zip |
Take 2: Extensible return values and validation; steps toward a single output_for_cli(); enable more webUI stuff
Diffstat (limited to 'ipalib/plugins/host.py')
-rw-r--r-- | ipalib/plugins/host.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 8859b5873..dd19362bd 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -29,6 +29,7 @@ from ipalib import api, errors, util from ipalib import Str, Flag from ipalib.plugins.baseldap import * from ipalib.plugins.service import split_principal +from ipalib import _, ngettext def validate_host(ugettext, fqdn): @@ -72,32 +73,38 @@ class host(LDAPObject): takes_params = ( Str('fqdn', validate_host, cli_name='hostname', - doc='Hostname', + label='Hostname', primary_key=True, normalizer=lambda value: value.lower(), ), Str('description?', cli_name='desc', + label='Description', doc='Description of the host', ), Str('localityname?', cli_name='locality', + label='Locality', doc='Locality of the host (Baltimore, MD)', ), Str('nshostlocation?', cli_name='location', + label='Location', doc='Location of the host (e.g. Lab 2)', ), Str('nshardwareplatform?', cli_name='platform', + label='Platform', doc='Hardware platform of the host (e.g. Lenovo T61)', ), Str('nsosversion?', cli_name='os', + label='Operating system', doc='Operating System and version of the host (e.g. Fedora 9)', ), Str('userpassword?', cli_name='password', + label='User password', doc='Password used in bulk enrollment', ), ) @@ -125,6 +132,9 @@ class host_add(LDAPCreate): """ Create new host. """ + + msg_summary = _('Added host "%(value)s"') + def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): entry_attrs['cn'] = keys[-1] entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0] @@ -147,16 +157,21 @@ class host_del(LDAPDelete): """ Delete host. """ + + msg_summary = _('Deleted host "%(value)s"') + def pre_callback(self, ldap, dn, *keys, **options): # Remove all service records for this host truncated = True while truncated: try: - (services, truncated) = api.Command['service_find'](keys[-1]) + ret = api.Command['service_find'](keys[-1]) + truncated = ret['truncated'] + services = ret['result'] except errors.NotFound: break else: - for (dn_, entry_attrs) in services: + for entry_attrs in services: principal = entry_attrs['krbprincipalname'][0] (service, hostname, realm) = split_principal(principal) if hostname.lower() == keys[-1]: @@ -170,6 +185,9 @@ class host_mod(LDAPUpdate): """ Modify host. """ + + msg_summary = _('Modified host "%(value)s"') + takes_options = LDAPUpdate.takes_options + ( Str('krbprincipalname?', cli_name='principalname', @@ -201,6 +219,10 @@ class host_find(LDAPSearch): Search for hosts. """ + msg_summary = ngettext( + '%(count)d host matched', '%(count)d hosts matched' + ) + api.register(host_find) @@ -210,4 +232,3 @@ class host_show(LDAPRetrieve): """ api.register(host_show) - |