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
Function
Description
rad_log
Provides log information.
_rad_locale_get()
Provides the locale information.
_rad_locale_free()
Frees the locale.
_rad_locale_parse()
Parses the locale.
Table 2  RAD Server Module Attributes
Attribute
Description
rad_container
Variable pointing to the RAD container that the module must be using.
rad_log_lvl
DEBUG, NOTE, WARN, ERROR, CONFIG, FATAL, PANIC.

RADInstance Python Class

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

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

RADContainer Python Class

The following table provides information about the methods for RADContainer.

Table 5  RADContainer Methods
Method
Description
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"/>
</struct>

The ADR method definition is as follows:

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

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.