Skip Navigation Links | |
Exit Print View | |
Remote Administration Daemon Developer Guide Oracle Solaris 11.1 Information Library |
The rad Python implementation provides the modules described in this section to facilitate client implementation.
Provides classes and methods which fully implement the rad protocol in Python.
Provides an Authentication class and utility methods for connecting a Python client to rad.
rad.util RadAuth
A class which fetches and caches a handle to an authentication object along with some convenience methods for manipulating it.
The following methods can be used to connect to a rad instance using variety of transports.
RadConnection connect_unix (string path , string locale);
RadConnection connect_private (string list modules , boolean debug , string map env , string root , string list auxargs , string locale); RadConnection connect_tls (string host , integer port , string locale); RadConnection connect_zone(RadConnection rc , string zone , string user , string locale);
The resulting RadConnection can be used to:
Locate objects
Invoke object methods
Read or write object properties
Subscribe or unsubscribe to object events
Example 5-6 Method Invocation
import rad.util # Connect to a local rad instance. with rad.util.connect_unix() as rc: # Obtain a remote reference to the desired target. obj= rc.get_object_s("com.example", [("type", "GrabBag")]) # Invoke a method on the target. res = obj.parseString("a test string") # Print the result. print "length: " + str(res.length)
Example 5-7 Attribute Access
import rad.util # Connect to a local rad instance. with rad.util.connect_unix() as rc: # Obtain a remote reference to the desired target. obj= rc.get_object_s("com.example", [("type", "GrabBag")]) # Print the object attribute. print "Mood: " + str(obj.mood)
Example 5-8 Event Subscription
import rad.util with rad.util.connect_unix() as rc: # Obtain a remote reference to the desired target. obj= rc.get_object_s("com.example", [("type", "GrabBag")]) # Subscribe to the "moodswings" event rc.subscribe(obj, "moodswings") while True: # Perform a (blocking) read of an event ev_obj = obj.read_event() print "Received Event:" print "mood: " +str(ev_obj.mood) print "changed: " +str(ev_obj.changed)