Developing Router Initialization Scripts for Network Devices and Juniper Networks Routers
When the SAE establishes a connection with a router or network device, it can run an initialization script to customize the setup of the connection. These initialization scripts are run when the connection between a router or network device and the SAE is established and again when the connection is dropped.
We provide the IorPublisher script in the /opt/UMC/sae/lib folder. The IorPublisher script publishes the interoperable object reference (IOR) of the SAE in the directory so that a NIC can associate a router with an SAE.
For JunosE VRs that supply IP addresses from a local pool, a router initialization script is provided that identifies which VR supplies each IP pool and writes the information to the configuration. The SAE runs the script only when a COPS connection is established to the JunosE router. Consequently, if you modify information about IP pools on a VR after the COPS connection is established, the SAE will not automatically register the changes, and you must update the configuration.
For Junos (only junos-ise device) virtual routers that supply IP addresses from a local pool, a router initialization script is provided to get the IP pool information from Junos router and update it in LDAP.
Table 1 describes the router initialization scripts that we provide with the SRC software in the /opt/UMC/sae/lib folder.
Table 1: Router Initialization Scripts
When to Use Script
Publishes the IOR of the SAE into an internal part of the shared configuration so that a NIC can associate a router with an SAE.
Use with JunosE routers that do not supply IP addresses from local pools, and with devices running Junos OS.
Use with all devices running Junos OS.
Use with third-party network devices.
Publishes the IOR of the SAE and local IP address pools in the directory so that a NIC can associate a router with an SAE and resolve the IP-to-SAE mapping.
Use with JunosE virtual routers that supply IP addresses from local pools.
Publishes the local IP address pools in the directory so that a NIC can associate a router with an SAE and resolve the IP-to-SAE mapping.
Use with Junos (only junos-ise device) virtual routers that supply IP addresses from local pools.
Interface Object Fields
Router initialization scripts are written in the Python programming language (www.python.org) and executed in the Jython environment (www.jython.org).
Router initialization scripts interact with the SAE through an interface object called Ssp. The SAE exports a number of fields through the interface object to the script and expects the script to provide the entry point to the SAE.
Table 2 describes the fields that the SAE exports.
Table 2: Exported Fields
System properties object (class: java.util.Properties)—The properties should be treated as read-only by the script.
Error logger—Use the SsperrorLog.printIn (message) to send error messages to the log.
Info logger—Use the Ssp.infoLog.printIn (message) to send informational messages to the log.
Debug logger—Use the Ssp.debugLog.printIn (message) to send debug messages to the log.
The router initialization script must set the field Ssp.routerInit to a factory function that instantiates a router initialization object:
<VRName>—Name of the virtual router in which the COPS client has been configured, format: virtualRouterName@RouterName
<virtualIp>—Virtual IP address of the SAE (string, dotted decimal; for example: 192.168.254.1)
<realIp>—Real IP address of the SAE (string, dotted decimal; for example, 192.168.1.20)
<VRIp>—IP address of the virtual router (string, dotted decimal)
<transportVR>—Name of the virtual router used for routing the COPS connection, or None, if the COPS client is directly connected
The factory function must implement the following interface:
The factory function returns an interface object that is used to set up and tear down a connection for a given COPS server. A common case of a factory function is the constructor of a class.
The factory function is called directly after a COPS server connection is established. In case of problems, an exception should be raised that leads to the termination of the COPS connection.
Instances of the interface object must implement the following methods:
setup()—Is called when the COPS server connection is established and is operational. In case of problems, an exception should be raised that leads to the termination of the COPS connection.
shutdown()—Is called when the COPS server connection to the virtual router is terminated. This method should not raise any exceptions in case of problems.
Example: Router Initialization Script
The following script defines a router initialization class named SillyRouterInit. The interface class does not implement any useful functionality. The interface class just writes messages to the infoLog when the router connection is created or terminated.
class SillyRouterInit: def __init__(self, vrName, virtualIp, realIp, vrIp, transportVr): """ initialize router initialization object """ self.vrName = vrName Ssp.infoLog.printin("SillyRouterInit created")
def setup(self): """ initialize connection to router """ Ssp.infoLog.printin("Setup connection to VR %(vrName)s" % vars(self))
def shutdown(self): """ shutdown connection to router """ Ssp.infoLog.printin("Shutdown connection to VR %(vrName)s" % vars(self))
# # publish interface object to Ssp core # Ssp.routerInit = SillyRouterInit