Sophisticated RAD Searches in Python

You can search for a zone by its name or ID or a set of zones by pattern matching. You can extend the basic definition of a name provided by a proxy. For example, if zones are uniquely identified by the key name, then you can find a zone with the name test-0 as shown in the following example. The example uses glob patterns to find a zone.

Example 2-36 Python Language – Using Glob Patterns

>>> import rad.bindings.com.oracle.solaris.rad.zonemgr as zonemgr
>>> import rad.client as radc
>>> import rad.connect as radcon
>>> with radcon.connect_unix() as rc:
... zonelist = rc.list_objects(zonemgr.Zone(), radc.ADRGlobPattern({"name" : "test-0"}))
... print zonelist
... 
[Name: com.oracle.solaris.rad.zonemgr:type=Zone,name=test-0,id=-1 Version: (1.0)]
>>> 

In this example, the ADRGlobPattern class (imported from the rad.client module) is used to refine the search. The list_objects() method from the RADConnection class is used, but the search is refined by extending the name definition. The ADRGlobPattern class takes a key:value dictionary and extends the name used for the search.