Go to main content

Remote Administration Daemon Developer's Guide

Exit Print View

Updated: April 2020

Exported Python Interfaces Used by RAD

This section describes the APIs that are available for Python language.

The exported Python interfaces are as follows:

  • rad.server – RAD Server module.

  • RADInstance – RAD instance base class. All the generated interfaces inherit from the RADInstance class. Thus, the interfaces inherit a set of useful behaviours. All the inherited attributes are prepended with _rad to both prevent name collisions and clearly indicate that these attributes are protected.

  • RADContainer – Container base class. Represents a container into which the RAD instances are inserted.

  • RADException – RAD exception base class. Represents an exception, which will be propagated back to the client as a CE_OBJECT exception. If an invocation fails, the error is declared in the ADR. See Example 54, Using RADException.

The following functions must be provided by an implementation module:

  • rad_reg()

  • rad_init()

  • rad_fini()

rad.server Python Module

The following tables provide information about the server module functions and attributes.

Table 1  RAD Server Module Functions
Provides log information.
Provides the locale information.
Frees the locale.
Parses the locale.
Table 2  RAD Server Module Attributes
Variable pointing to the RAD container that the module must be using.

RADInstance Python Class

The following tables provide information about the methods and properties for the RAD instance base class, RADInstance.

Table 3  RADInstance Methods
_rad_notify(self, event, payload)
Sends an event event with payload payload to subscribed clients.
_rad_insert_singleton(cls, ctr)
Table 4  RADInstance Properties
The RAD name of given instance.

RADContainer Python Class

The following table provides information about the methods for RADContainer.

Table 5  RADContainer Methods
insert(self, inst)
Adds instance into the container. This API is rarely used directly and typically called by Subclass-of-RADInstace.__init__(self, name, user, freef, dynamic) when name is not None and dynamic == False.
insert_singleton(self, cls)
Creates a new RADInstance subclass instance and insert it to container under name name.
remove(self, inst)
Removes instance inst from the container.
supercede(self, inst)
register(self, listf, lookupf)
Registers RADInstance subclass klass for dynamic listing and looking up.
find_by_name(self, name)
find_by_id(self, id)
list(self, pat)

RADException Python Class

This section provides an example that shows how to use RADException.

Example 54  Using RADException

The ADR type definition is as follows:

<struct name="pair" stability="private">
   <field name="first" type="integer"/>
   <field name="second" type="integer"/>

The ADR method definition is as follows:

<method name="raiseError" stability="private">
  Raise an exception to test exception handling.
  <error typeref="pair"/>

In the method definition, you are specifying that an exception must be raised when the initialization of the struct "pair" fails.

The implementation is as follows:

def raiseError(self):
    raise radser.RADException(snake_iface.pair(3, 6))

In this example, you are raising a RADException and providing a payload that matches the definition in the ADR document.

The exceptions that occur as a consequence of "other" errors such as divide by zero are propagated back to the client as a CE_SYSTEM error representing the general RAD failure code for systemic failure.