summaryrefslogtreecommitdiffstats
path: root/src/realmd/doc/examples/realmd-cim
diff options
context:
space:
mode:
Diffstat (limited to 'src/realmd/doc/examples/realmd-cim')
-rwxr-xr-x[-rw-r--r--]src/realmd/doc/examples/realmd-cim92
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