diff options
author | Rob Crittenden <rcritten@redhat.com> | 2009-04-03 14:11:46 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-04-13 14:54:16 -0400 |
commit | 8821d8cac3140bcaa5193a470b5c0143454a96d4 (patch) | |
tree | 0311330a66fd29c768f7e636e6100aa21a63d91f /ipalib/plugins | |
parent | 44afa977a88bfd376cbd6a212a790b9549c903a5 (diff) | |
download | freeipa-8821d8cac3140bcaa5193a470b5c0143454a96d4.tar.gz freeipa-8821d8cac3140bcaa5193a470b5c0143454a96d4.tar.xz freeipa-8821d8cac3140bcaa5193a470b5c0143454a96d4.zip |
Fill in default values for os and platform
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/host.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 33cc98f4c..13a0254e3 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -24,6 +24,7 @@ Frontend plugins for host/machine Identity. from ipalib import api, crud, errors2, util from ipalib import Object # Plugin base class from ipalib import Str, Flag # Parameter types +import sys, os, platform def get_host(hostname): @@ -53,6 +54,19 @@ def validate_host(ugettext, cn): default_attributes = ['cn','description','localityname','nshostlocation','nshardwareplatform','nsosversion'] +def determine_os(): + (sysname, nodename, release, version, machine) = os.uname() + if sys.platform == "linux2": + # something like fedora 9 Sulpher + return unicode(" ".join(platform.dist())) + else: + # on Solaris this will be: 'SunOS 5.10' + return unicode(sysname + " " + release) + +def determine_platform(): + (sysname, nodename, release, version, machine) = os.uname() + return unicode(machine) + class host(Object): """ Host object. @@ -77,10 +91,14 @@ class host(Object): Str('nshardwareplatform?', cli_name='platform', doc='Hardware platform of this host (e.g. Lenovo T61)', + default=determine_platform(), + autofill=True, ), Str('nsosversion?', cli_name='os', doc='Operating System and version on this host (e.g. Fedora 9)', + default=determine_os(), + autofill=True, ), Str('userpassword?', cli_name='password', |