diff options
author | Stef Walter <stefw@redhat.com> | 2013-05-14 14:34:20 +0200 |
---|---|---|
committer | Jan Safranek <jsafrane@redhat.com> | 2013-05-17 13:39:22 +0200 |
commit | d3a45b5da98a22b6b94c73cd69f25a3ec7f9d8fa (patch) | |
tree | 5a9413f8d60a8324f0b616e9eff28552db82fb34 /src/realmd/doc/examples/realmd-cim | |
parent | 028b8f02d9b204efebdbb97d765b2c18ca33c0a8 (diff) | |
download | openlmi-providers-d3a45b5da98a22b6b94c73cd69f25a3ec7f9d8fa.tar.gz openlmi-providers-d3a45b5da98a22b6b94c73cd69f25a3ec7f9d8fa.tar.xz openlmi-providers-d3a45b5da98a22b6b94c73cd69f25a3ec7f9d8fa.zip |
Remove the complex API dbus-style API from realmd provider
As discussed, we want to expose a simple API for starters here
with just a few methods and properties. If we need to grow from
there it should be in the future when we have more experience
modeling an appropriate CIM model which integrates well with the
patterns and style of other CIM models.
Diffstat (limited to 'src/realmd/doc/examples/realmd-cim')
-rwxr-xr-x[-rw-r--r--] | src/realmd/doc/examples/realmd-cim | 92 |
1 files changed, 11 insertions, 81 deletions
diff --git a/src/realmd/doc/examples/realmd-cim b/src/realmd/doc/examples/realmd-cim index 90ae9d5..eb3f9be 100644..100755 --- a/src/realmd/doc/examples/realmd-cim +++ b/src/realmd/doc/examples/realmd-cim @@ -8,43 +8,16 @@ import pywbem #---------------------------------------------------------------------- -def do_list(conn, options, args): - realms = conn.EnumerateInstances('LMI_RealmdKerberosRealm') - - print "%d realms" % (len(realms)) - - for realm in realms: - if options.verbose > 1: - # Very verbose, dump all properties - property_names = sorted(realm.keys()) - for name in property_names: - value = realm[name] - print " %s: %s" % (name, value) - - print realm['RealmName'] - print " type: kerberos" - print " realm-name: %s" % realm['RealmName'] - print " domain-name: %s" % realm['DomainName'] - - is_configured = True - configured = realm['Configured'] - if not configured: - configured = "no" - is_configured = False - elif configured == "KerberosMembership": - configured = "kerberos-member" - - print " configured: %s" % configured - - for detail in zip(realm['DetailNames'], realm['DetailValues']): - print " %s: %s" % (detail[0], detail[1]) - - if is_configured: - print " login-formats: %s" % ", ".join(realm['LoginFormats']) - print " login-policy: %s" % realm['LoginPolicy'] - print " permitted-logins: %s" % ", ".join(realm['PermittedLogins']) +def do_status(conn, options, args): + try: + realmd_service = conn.EnumerateInstances('LMI_RealmdService')[0] + except Exception, e: + raise ValueError("could not obtain realmd service") - print + if realmd_service["Domain"]: + print "Joined to the domain: %s" % realmd_service["Domain"] + else: + print "Not joined to a domain" def do_join(conn, options, args): # Validate arguments @@ -94,53 +67,11 @@ def do_leave(conn, options, args): except Exception, e: raise ValueError("Leave failed (%s)" % (e)) - - -def do_discover(conn, options, args): - # Validate arguments - if len(args) != 1: - raise ValueError("You must supply exactly 1 domain.") - - domain = args[0] - - if (options.verbose): - print "Discovering domain: %s" % domain - - try: - realmd_service_instance_name = conn.EnumerateInstanceNames('LMI_RealmdService')[0] - except Exception, e: - raise ValueError("could not obtain realmd service") - - try: - retval, outparams = conn.InvokeMethod("Discover", realmd_service_instance_name, - Target=domain) - except Exception, e: - raise ValueError("Join failed (%s)" % (e)) - - realm_refs = outparams['DiscoveredRealms'] - - print "%d Discovered" % len(realm_refs) - for realm_ref in realm_refs: - #print realm_ref - realm = conn.GetInstance(realm_ref) - print realm['RealmName'] - print " Name: %s" % realm['RealmName'] - print " Configured: %s" % realm['Configured'] - print " Supported Interfaces: %s" % ", ".join(realm['SupportedInterfaces']) - for detail in zip(realm['DetailNames'], realm['DetailValues']): - print " %s: %s" % (detail[0], detail[1]) - print " login-formats: %s" % ", ".join(realm['LoginFormats']) - print " login-policy: %s" % realm['LoginPolicy'] - print " permitted-logins: %s" % ", ".join(realm['PermittedLogins']) - - - #---------------------------------------------------------------------- def main(): - actions = {'list': do_list, - 'discover': do_discover, + actions = {'status': do_status, 'join': do_join, 'leave': do_leave, } @@ -148,8 +79,7 @@ def main(): usage =''' %%prog [options] <action> <arg> ... - %%prog [options] list - %%prog [options] discover domain + %%prog [options] status %%prog [options] join user password domain %%prog [options] leave user password domain |