Package onep :: Package element :: Module NetworkElement :: Class NetworkElement
[frames] | no frames]

Class NetworkElement


The NetworkElement class represents the hardware that hosts the network OS.

It provides network services to a oneP application. The class provides access to the network services offered by network element through a session The session is managed by the class. Each application can have one and only one session to a network element, however an application may connect to as many network elements as it can maintain connections to.

Instance Methods
 
__init__(self, host_address='127.0.0.1', appname='noname')
Constructor of NetworkElement
 
__enter__(self)
 
license(self)
Licensing of Network Element - [PID of the license identifiers : Version ID : Serial number]
 
__exit__(self, type, val, tb)
 
add_logical_interface(self, if_id, type, parent_intf=None)
Add a logical interface to network element.
 
remove_logical_interface(self, if_obj)
Remove a logical interface to network element.
 
is_connected(self)
Returns true if a connected session exists between the network element and the application.
 
set_connection_listener(self, listener, clientData=None)
Sets a connection listener.
 
add_interface_state_listener(self, interfaceStateListener, ifFilter, stateEventType, clientData)
Adds an Interface up/down state listener to the NetworkElement object.
 
remove_interface_state_listener(self, eventHandle)
Removes the interface event listener.
 
add_syslog_listener(self, syslogListener, syslogFilter, clientData)
Adds a syslog listener to the NetworkElement object.
 
remove_syslog_listener(self, eventHandle)
Removes the Syslog event listener
 
add_oir_listener(self, OIRListener, OIRFilter, clientData)
Adds an Online Insertion and Removal(OIR) listener
 
remove_oir_listener(self, eventHandle)
Removes the Online Insertion and Removal(OIR) event listener.
 
add_cli_listener(self, CLIListener, CLIFilter, clientData)
Adds a CLI listener to the NetworkElement object
 
remove_cli_listener(self, eventHandle)
Removes the CLI event listener.
 
add_cdp_listener(self, cdpListener, ifFilter, cdpFilter, clientData)
Adds a (Cisco Discovery Protocol) CDP listener
 
remove_cdp_listener(self, eventHandle)
Removes the CDP event listener.
 
add_interface_address_change_listener(self, listener, ac_filter, client_data)
Adds an Interface Address Change listener
 
remove_interface_address_change_listener(self, eventHandle)
Removes the Interface Address Change event listener.
 
add_interface_create_delete_listener(self, listener, if_filter, client_data)
Adds an Interface Create/Delete event listener
 
remove_interface_create_delete_listener(self, event_handle)
Removes the Interface Create/Delete event listener
 
add_mtu_listener(self, listener, filter, client_data)
Adds a MTU change listener to the network interface.
 
remove_mtu_listener(self, event_handle)
Removes the MTU event listener.
 
add_bandwidth_listener(self, listener, filter, client_data)
Adds a Bandwidth change listener to the network interface.
 
remove_bandwidth_listener(self, event_handle)
Removes the Bandwidth event listener.
 
add_vrf_listener(self, listener, filter, client_data)
Adds a VRF change listener to the network interface.
 
add_appl_listener(self, applListener, AppFilter, clientData)
Adds an application listener to the NetworkElement object
 
remove_appl_listener(self, eventHandle)
Removes the application event listener
 
publish_appl_event(self, pubEvent)
Publishes an application event to the abstraction layer
 
reconnect(self, username, password, session_id, session_config)
Reconnects to the disconnected session.
 
connect(self, username, password, session_config=None)
Connects to the network element using default session configuration.
 
connect_1(self, username, password, session_config)
Connects to the network element with the specified session configuration.
 
disconnect(self, msg="")
Disonnect from a network element
 
get_interface_dict(self, if_filter)
Gets the interfaces collection in dictionary form
 
get_interface_list(self, if_filter)
Gets the list of interfaces
 
get_interface_by_name(self, ifName)
Gets the NetworkInterface instance by the giving display name.
 
get_process_list(self)
Returns a list of ProcessIDL class.
 
get_total_system_memory(self)
Gets the total system memory in bytes.
 
total_system_memory(self)
Gets the total system memory in bytes.
 
get_free_system_memory(self)
Gets the free system memory in bytes.
 
free_system_memory(self)
Gets the free system memory in bytes.
 
get_system_cpu_utilization(self)
Gets the total CPU utilization in percentage.
 
system_cpu_utilization(self)
Gets the total CPU utilization in percentage.
 
discover_service_set_list(self)
Discovers services available on the root network element and also on its neighbors that support onePK services.
 
add_discovery_listener(self, discoveryListener, discoveryFilter, clientData)
Adds a Service Set Discovery listener to the NetworkElement object.
 
remove_discovery_listener(self, eventHandle)
Removes the given discovery listener.
 
__str__(self)
Gets a string representation of the NetworkElement.
 
get_location(self)
Gets a Location object associated with the network element.
 
set_location(self, loc)
Sets location information for the network element.
 
get_fru_list(self)
Returns the collection of the Field Replaceable Unit (FRU)
 
create_syslog_message(self, severity, message)
Creates a syslog message on the network element
 
delete_all_policies(self)
 
install_cli_ext(self, xsd_contents, config_domain, overwrite)
This method installs an Application Management Data XSD (ClI extension) on the network element.
 
uninstall_cli_ext(self, app_name, app_version, config_domain)
This method uninstalls a ClI extension on the specified network element.
 
is_xsd_installed(self, app_name, app_version, config_domain)
This method queries for a ClI extension on the specified network element.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  cpu_sampling_interval = property(_get_cpu_sampling_interval, _...
  OnepSessionState = enum('ONEP_STATE_DISCONNECTED', 'ONEP_STATE...
  OnepSyslogSeverity = enum('ONEP_SYSLOG_EMERGENCY', 'ONEP_SYSLO...
  log = None
Instance Variables
  parent
The NetworkApplication instance that created this class.
  appl_managed_data
The application managed data.
str appname
Name of the oneP application.
float connect_time
The time when connection established to the Network Element.
str disconnect_msg
The message sent to Network Element while disconnecting.
float disconnect_time
The time when disconnected from the Network Element.
str host_address
The host IP address.
dict interfaces
All the network interfaces in dictionary form.
str password
Password used for the session authentication.
int port
The port to connect to.
ElementProperty properties
Provides the static properties of the NetworkElement.
SessionHandle session_handle
A numeric ID associated with the session.
OnepSessionState state
The current state of the session.
str username
Username used for the session authentication.
Properties

Inherited from object: __class__

Method Details

__init__(self, host_address='127.0.0.1', appname='noname')
(Constructor)

 

Constructor of NetworkElement

Parameters:
  • host_address - The host IP address
  • appname - The application name
Overrides: object.__init__

license(self)

 

Licensing of Network Element - [PID of the license identifiers : Version ID : Serial number]

Decorators:
  • @property

add_logical_interface(self, if_id, type, parent_intf=None)

 

Add a logical interface to network element. Raises OnepInterfaceException

  • interface already exists
  • logical interface type not supported

Keyword argument: if_id -- int - Logical interface number, subintf_id if it is subinterface type -- enum - NetworkInterface.InterfaceTypes parent_intf --NetworkInterface-- base interface

remove_logical_interface(self, if_obj)

 

Remove a logical interface to network element. Raises OnepInterfaceException

  • Removal of interface type not supported
  • Interface not configured

Keyword argument: if_obj - interface class

set_connection_listener(self, listener, clientData=None)

 

Sets a connection listener.

Registers a connection state change listener callback for the connect/disconnect state change event.

Parameters:
  • listener - The listener to be registered for connection, that is, the listener that will be invoked when the event is triggered. To deregister, the listener passes None listener. Any setting of the connection listener overrides the previous setting.
  • clientData - The client data associated with the listener. This client data is part of the input parameters when the handleEvent method in the listener is invoked.

add_interface_state_listener(self, interfaceStateListener, ifFilter, stateEventType, clientData)

 

Adds an Interface up/down state listener to the NetworkElement object.

Parameters:
  • interfaceStateListener - Class that implements the event handler.
  • ifFilter - InterfaceFilter class to specify match criteria for interfaces to monitor.
  • stateEventType - InterfaceStatus.InterfaceStateEventType class to specify the type of event that is interesting--up/down/both.
  • clientData - The client data associated with the listener. This client data is part of the input parameters used when the handleEvent method in the listener is invoked.
Returns:
The eventHandle
Raises:

remove_interface_state_listener(self, eventHandle)

 

Removes the interface event listener.

This method removes the listener associated with the specified eventHandle and also removes the corresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Raises:

add_syslog_listener(self, syslogListener, syslogFilter, clientData)

 

Adds a syslog listener to the NetworkElement object.

Multiple listeners can be associated with an instance of NetworkElement.

Parameters:
  • syslogListener - The SyslogListener object that handles the events.
  • syslogFilter - The SyslogFilter to specify criteria of interested syslog events.
  • clientData - The client data associated with the listener. This client data is part of the input parameters when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeSyslogListener method. If registration fails, -1 is returned.
Raises:

remove_syslog_listener(self, eventHandle)

 

Removes the Syslog event listener

This method removes the listener associated with the specified eventHandle and also removes the corresponding registered event on the NetworkElement

Parameters:
  • eventHandle - Registered event identifier
Raises:

add_oir_listener(self, OIRListener, OIRFilter, clientData)

 

Adds an Online Insertion and Removal(OIR) listener

Multiple listeners can be associated with an instance of NetworkElement.

Parameters:
  • OIRListener - The OIRListener object that handles the events.
  • OIRFilter - The OIRFilter to specify criteria of interested OIR events.
  • clientData - The client data associated with the listener. This client data is part of the input parameters used when the handleEvent method in the listener is invoked.
  • syslogListener - The SyslogListener object that handles the events.
  • syslogFilter - The SyslogFilter to specify criteria of interested syslog events.
  • clientData - The client data associated with the listener. This client data is part of the input parameters when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeOIRListener method. If registration fails, -1 is returned.
Raises:

remove_oir_listener(self, eventHandle)

 

Removes the Online Insertion and Removal(OIR) event listener.

This method removes the listener associated with the specified eventHandle and also removes the corresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Raises:

add_cli_listener(self, CLIListener, CLIFilter, clientData)

 

Adds a CLI listener to the NetworkElement object

Multiple listeners can be associated with an instance of NetworkElement

Parameters:
  • CLIListener - The CLIListener object that handles the events.
  • filter - The CLIFilter to specify criteria of interested CLI events.
  • clientData - The client data associated with the listener. This client data is part of the input parameters used when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the remove listener method. If registration fails, -1 is returned.
Raises:

remove_cli_listener(self, eventHandle)

 

Removes the CLI event listener.

This method will remove the listener associated with the specified eventHandle and also remove thecorresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Raises:

add_cdp_listener(self, cdpListener, ifFilter, cdpFilter, clientData)

 

Adds a (Cisco Discovery Protocol) CDP listener

Multiple listeners can be associated with an instance of NetworkElement. The event is generated when changes in the CDP table match specified filter criteria on the network element.

Parameters:
  • cdpListener - The CDPListener object that handles the events.
  • ifFilter - The InterfaceFilter to specify interface list subset.
  • cdpFilter - The CDPFilter to specify criteria of interested CDP events.
  • clientData - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the remove listener method. If registration fails, -1 is returned.
Raises:

remove_cdp_listener(self, eventHandle)

 

Removes the CDP event listener.

This method will remove the listener associated with the specified event_handle and also remove the corresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Raises:

add_interface_address_change_listener(self, listener, ac_filter, client_data)

 

Adds an Interface Address Change listener

Multiple listeners can be associated with an instance of NetworkElement.

Parameters:
  • listener - The InterfaceAddressChangeListener object that handles the events.
  • acFilter - The InterfaceAddressChangeFilter to specify criteria of interested InterfaceAddressChange events.
  • clientData - The client data associated with the listener. This client data will be part of input parameters used when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeInterfaceAddressChangeListener method. If registration fails, -1 is returned.
Raises:

remove_interface_address_change_listener(self, eventHandle)

 

Removes the Interface Address Change event listener.

This method removes the listener associated with the specified eventHandle and also removes the corresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Returns:
EventHandle, a numeric ID associated with this event registration.
Raises:

add_interface_create_delete_listener(self, listener, if_filter, client_data)

 

Adds an Interface Create/Delete event listener

Multiple listeners can be associated with an instance of NetworkElement.

Parameters:
  • listener - The InterfaceCreateDeleteListener object that handles the events.
  • if_filter - The InterfaceCreateDeleteFilter to specify interface list subset.
  • clientData - The client data associated with the listener. This client data is part of the input parameters used when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeInterfaceCreateDeleteListener method. If registration fails, -1 is returned.
Raises:

remove_interface_create_delete_listener(self, event_handle)

 

Removes the Interface Create/Delete event listener

This method removes the listener associated with the specified event_handle and also removes the corresponding registered event on the NetworkElement.

Parameters:
  • event_handle - Registered event identifier.
Raises:

add_mtu_listener(self, listener, filter, client_data)

 

Adds a MTU change listener to the network interface.

Parameters:
  • listener (InterfaceMtuListener) - The InterfaceMtuListener object that handles the events.
  • filter (InterfaceMtuFilter) - The InterfaceMtuFilter to specify criteria of the interested Interface. events.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Raises:

remove_mtu_listener(self, event_handle)

 

Removes the MTU event listener. This method will remove the listener associated with the given event_handle.

Parameters:
  • event_handle (int) - Registered event identifier.
Raises:

add_bandwidth_listener(self, listener, filter, client_data)

 

Adds a Bandwidth change listener to the network interface.

Parameters:
  • listener (InterfaceBandwidthListener) - The InterfaceBandwidthListener object that handles the events.
  • filter (InterfaceFilter) - The InterfaceFilter to specify criteria of the interested Interface events.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Raises:

remove_bandwidth_listener(self, event_handle)

 

Removes the Bandwidth event listener. This method will remove the listener associated with the given event_handle.

Parameters:
  • event_handle (int) - Registered event identifier.
Raises:

add_vrf_listener(self, listener, filter, client_data)

 

Adds a VRF change listener to the network interface.

Parameters:
  • listener (InterfaceVrfListener) - The InterfaceVrfListener object that handles the events.
  • filter (InterfaceVrfFilter) - The InterfaceVrfFilter to specify criteria of the interested VRF events.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Raises:

add_appl_listener(self, applListener, AppFilter, clientData)

 

Adds an application listener to the NetworkElement object

Multiple listeners can be associated with an instance of NetworkElement. The application-specific event allows applications to publish application-specific events. If an application is registered for the event type, it receives a callback notification when the specified event is published and also matches the specified filter.

Parameters:
  • applListener - The ApplListener object that handles the events.
  • AppFilter - The ApplFilter used to specify criteria of interested application events.
  • clientData - The client data associated with the listener. This client data is part of the input parameters when the handleEvent method in the listener is invoked.
Returns:
EventHandle, a numeric ID associated with this event registration. The eventHandle is used to unregister the listener using the removeSyslogListener method. If registration fails, -1 is returned.
Raises:

remove_appl_listener(self, eventHandle)

 

Removes the application event listener

This method removes the listener associated with the specified eventHandle and also removes the corresponding registered event on the NetworkElement.

Parameters:
  • eventHandle - Registered event identifier.
Returns:
EventHandle, a numeric ID associated with this event registration.
Raises:

publish_appl_event(self, pubEvent)

 

Publishes an application event to the abstraction layer

This method publishes an application event to the abstraction layer.

Parameters:
  • pubEvent - The event to publish.
Raises:

reconnect(self, username, password, session_id, session_config)

 

Reconnects to the disconnected session.

Provides the ability to reconnect back to the network element after the session is disconnected by the application via the disconnect method, or abnormally due to connection failure. If the application has specified the reconnect timer during the connect attempt to the network element, it can reconnect to the original session if reconnection is made within the reconnect timeout window, if the sessionId is the same as the original session, and if the reauthentication is successful. With successful reconnection, the same SessionHandle is returned.

If any failure occurs during the reconnection attempt, NULL SessionHandle is returned along with the exception detailing the reason. If the reconnect timer expires and no reconnection attempt is successfully made to the network element, the session resource in the network element is released.

null SessionHandle is returned in the following cases:

  • If the sessionId argument passed does not match the unique ID of the disconnected session on the network element.
  • If the disconnected session does not have a reconnect timer specified during the connect() attempt.
  • If reauthentication using username and password has failed.
  • If any failure occurred during the reconnect attempt.
Parameters:
  • username (str) - Mandatory username used for the session authentication. It should not be greater than OnepConstants.MAX_USERNAME_LEN characters in length.
  • password (str) - Mandatory password used for the session authentication. It should not be greater than OnepConstants.MAX_PASSWORD_LEN characters in length.
  • session_id (int) - The unique ID of the disconnected SessionHandle.
  • session_config (SessionConfig) - session_config contains attributes for reconnecting to network element.
Returns:
A SessionHandle, if authenticated session is successfully established. null, if reconnect or reauthentication attempt failed.
Raises:

connect(self, username, password, session_config=None)

 

Connects to the network element using default session configuration.

This method provides the ability to connect to the network element, if it is not currently connected. With successful connection and authentication to the network element, a SessionHandle is returned. If any failure occurs during the connection attempt, an exception detailing the reason will be raised. The default SessionConfig is used during establishment of the connection.

Authentication is required in order to access the NetworkElement. Password authentication is used. The username and password needs to be configured in the network element and to be authenticated using network element configured authentication mechanism (that is, locally, RADIUS, and TACACS+)

Note: Each network element has a configurable session limit that allows the rate limit on accessing the network element. This limit is configurable via CLI (session maximum) in the network element. The range is 1 to100. Default maximum session is 10.

Parameters:
  • username (str) - Mandatory username used for the session authentication. It should not be greater than OnepConstants.MAX_USERNAME_LEN characters in length.
  • password (str) - Mandatory password used for the session authentication. It should not be greater than OnepConstants.MAX_PASSWORD_LEN characters in length.
  • session_config (SessionConfig) - session_config contains attributes for connecting to network element. Default: None
Returns:
A SessionHandle, if the authenticated session is successfully established.
Raises:

connect_1(self, username, password, session_config)

 

Connects to the network element with the specified session configuration.

This method is deprecated and replaced by connect

This method provides the ability to connect to the network element, if it is not currently connected. With successful connection and authentication to the network element, a SessionHandle is returned. If any failure occurs during the connecting attempt, NULL SessionHandle is returned along with the exception detailing the reason. The default SessionConfig is used during connection establishment.

Authentication is required in order to access the NetworkElement. Password authentication is used. The username and password needs to be configured in the network element and to be authenticated using network element configured authentication mechanism (i.e. locally, RADIUS, and TACACS+)

Note. Optionally, application can set a reconnect timer in seconds via SessionConfig class. The timer is used in the network element side to keep the session information intact upon detection of application is unreachable (that is link is down or disconnected).

If application is able to reconnect to the network element within the timeout window, the existing session context will be restored and used. If no reconnect timer is specified, the existing session information on the network element is released upon detection of unreachable of application.

If application uses connect method to network element where the exited session still have reconnect timer running, the timer will be canceled. A new session establishment will be attempted.

Parameters:
  • username - Mandatory username used for the session authentication. It should not be greater than OnepConstants.MAX_USERNAME_LEN characters in length.
  • password - Mandatory password used for the session authentication. It should not be greater than OnepConstants.MAX_PASSWORD_LEN characters in length.
  • sessionConfig - sessionConfig contains attributes for connecting to network element.
Returns:
A SessionHandle, if authenticated session is successfully established. Otherwise, null is returned.
Raises:

disconnect(self, msg="")

 

Disonnect from a network element

This method provides the ability to disconnect from the network element if the application is currently connected. When the application finishes the session, the session can be disconnected. This allows the network element resources to be freed on the network element, if no optional reconnect timer has been specified during the connect.

Parameters:
  • msg
Raises:

get_interface_dict(self, if_filter)

 

Gets the interfaces collection in dictionary form

Parameters:
  • if_filter - Specifications for selecting subset of interfaces.
Returns:
All the network interfaces. The network interfaces includes both physical and logical ones.
Raises:

get_interface_list(self, if_filter)

 

Gets the list of interfaces

Parameters:
  • if_filter - Specifications for selecting subset of interfaces.
Returns:
A list of all the network interfaces. The network interfaces includes both physical and logical ones.
Raises:

get_interface_by_name(self, ifName)

 

Gets the NetworkInterface instance by the giving display name. This method returns a NetworkInterface instance on the specified NetworkElement by the giving display name. The name should be in the long display name format, for example, "Ethernet0/1".

Parameters:
  • ifName - Name of the network interface.
Returns:
The NetworkInterface instance whose name matches the specified name.
Raises:

get_process_list(self)

 

Returns a list of ProcessIDL class.

Gets the list of active processes in the NetworkElement and their respective CPU utilization and memory usage.

The application can specify the time period for which it wants to retrieve the CPU utilization by setting the sampling interval. If the application does not set the sampling interval, the getProcessList() method retrieves CPU utilization for the most recent time period. However, if the application does set the sampling interval but the interval does not match any of the time period values supported by the platform, then the CPU utilization is retrieved for the most recent time period which is closest to the sampling interval. For example, if the Network Element supports CPU utilization for time periods 5 seconds, 60 seconds and 300 seconds, and the application sets the sampling interval as 100seconds, then the CPU utilization returned will be for the most recent time period closest to 100 seconds, which is 60 seconds.

If there is an error in receiving the cpu usage value, it will be set to -1.

Returns:
The list of ElementProcess objects or a list of size 0 if there is an error or no process information can be retrieved.
Raises:

get_total_system_memory(self)

 

Gets the total system memory in bytes.

Returns:
The total system memory in bytes.
Raises:

total_system_memory(self)

 

Gets the total system memory in bytes.

Returns:
The total system memory in bytes.
Raises:

get_free_system_memory(self)

 

Gets the free system memory in bytes.

Returns:
The system memory, that is, the amount of free memory in bytes.
Raises:

free_system_memory(self)

 

Gets the free system memory in bytes.

Returns:
The system memory, that is, the amount of free memory in bytes.
Raises:

get_system_cpu_utilization(self)

 

Gets the total CPU utilization in percentage.

The time period for which the CPU utilization is retrieved is determined by the sampling interval set through the {@link #setCPUSamplingInterval(int)} method. If no sampling interval is set, the CPU utilization is retrieved for the most recent time period supported by the platform. However, if the application does set the sampling interval, but interval does not match any of the time periods supported by the platform, the CPU utilization returned is for the most recent time period closest to the sampling interval.

Returns:
the CPU usage The CPU utilization in percentage.
Raises:
  • OnepConnectionException - The exception is thrown when the connection to a network element has failed.
  • OnepRemoteProcedureException - The exception is thrown when an error has occurred in the remote procedure call made to a network element.
  • OnepException - The exception is thrown when the server returns an invalid CPU sampling interval value.

system_cpu_utilization(self)

 

Gets the total CPU utilization in percentage.

The time period for which the CPU utilization is retrieved is determined by the sampling interval set through the {@link #setCPUSamplingInterval(int)} method. If no sampling interval is set, the CPU utilization is retrieved for the most recent time period supported by the platform. However, if the application does set the sampling interval, but interval does not match any of the time periods supported by the platform, the CPU utilization returned is for the most recent time period closest to the sampling interval.

Returns:
the CPU usage The CPU utilization in percentage.
Raises:
  • OnepConnectionException - The exception is thrown when the connection to a network element has failed.
  • OnepRemoteProcedureException - The exception is thrown when an error has occurred in the remote procedure call made to a network element.
  • OnepException - The exception is thrown when the server returns an invalid CPU sampling interval value.

discover_service_set_list(self)

 

Discovers services available on the root network element and also on its neighbors that support onePK services.

The application has to be connected to the root network element to initiate service discovery. The discover_service_set_list method returns a list of ServiceSetDescription containing the information on the service set that is available on the root network element and its neighbors. In cases where onePK-supported discovery protocol is not enabled on the root element, the discover_service_set_list API returns service information only for the root element. The onePK application can use the information returned by ServiceSetDescription to identify the network elements that support a given set of services, and initiate connection to those elements and invoke the service set APIs.

The following sample code shows on how to obtain information on the services supported by the root NetworkElement and its neighbors:

>>> sdList = elem.discover_service_set_list()
>>> for sd in sdList:
        #get network element
        ne = sd.network_element
        #get the services available on this Network Element
        #Service Set name is the key, value is the string
        #containing the enabled Service set version
        services = sd.service_set_list
        #Connect to the Neighboring 1P network element, which supports
        #1.0 version of ONEP_BASE_SERVICE_SET
Returns:
list of ServiceSetDescription
Raises:
  • OnepRemoteProcedureException - The exception is thrown when an error has occurred in the remote procedure call made to a network element.
  • OnepConnectionException - The exception is thrown when an error has occurred in the remote procedure call made to a network element.
  • OnepException - The exception is thrown when an internal error occurs.

add_discovery_listener(self, discoveryListener, discoveryFilter, clientData)

 

Adds a Service Set Discovery listener to the NetworkElement object.

The application can add a Service Discovery listener to receive service set state change notifications from the Network Element to which it is directly connected (the root Network Element) and its neighbors. The application can also define filter criteria based on Network Element, service set name, and service set state.

The application can use the notification received to either invoke the APIs of the enabled service sets, or cleanup the resources for the disabled service sets. Multiple listeners can be associated with an instance of NetworkElement.

Note: The application will not receive notifications for Base service set changes for Local discovery type. If the Base service set is disabled on the root network element, the application will receive connection notification if the application has registered for connection notification. For remote discovery, the application will receive notification on Base Service set state changes provided the application has registered for these change notifications.

Parameters:
  • clientData - The client data associated with the listener. This client data is part of the input parameters used when the handle_event method in the listener is invoked.
  • discoveryListener (DiscoveryListener) - The DiscoveryListener object that handles the events.
  • discoveryFilter (DiscoveryFilter) - The DiscoveryFilter to specify criteria of interested the root Network Element and its ONEP neighbors.
Raises:

remove_discovery_listener(self, eventHandle)

 

Removes the given discovery listener.

Parameters:
  • eventHandle - ID returned as part of {@link #addDiscoveryListener(DiscoveryListener, DiscoveryFilter, Object)} call.
Raises:

__str__(self)
(Informal representation operator)

 

Gets a string representation of the NetworkElement.

The toString method for the class NetworkElement returns the string representation of the NetworkElement object instance and the element properties.

Returns:
A string representation of the NetworkElement object.
Overrides: object.__str__

get_location(self)

 

Gets a Location object associated with the network element. The Location object can be used to access all types of location information.

Returns:
The Location object for the network element, or null if there is no location information available.
Raises:

set_location(self, loc)

 

Sets location information for the network element.

Sets location information for the network element with the information in the input Location parameter.

Parameters:
  • loc (Location) - The location information to be associated with the network element.
Raises:

get_fru_list(self)

 

Returns the collection of the Field Replaceable Unit (FRU)

Returns:
A collection of FRU on the network element, if it is available. Otherwise, NULL is returned.
Raises:

create_syslog_message(self, severity, message)

 

Creates a syslog message on the network element

Creates a syslog message on the network element of specified:

  • Severity and message body. The facility is fixed at "onePK".
  • The mnemonic is the application name.
Parameters:
  • severity - The severity of the message.
  • message - The body of the message.
Raises:

install_cli_ext(self, xsd_contents, config_domain, overwrite)

 

This method installs an Application Management Data XSD (ClI extension) on the network element.

Parameters:
  • xsd_contents (str) - The string-value containing the contents of the XSD to be installed.
  • config_domain (str) - The configuration domain associated with the installation. If the application is in a container, this parameter is ignored, and the container name is used.
  • overwrite (boolean) - If TRUE the existing XSD is overwritten and old data is migrated. If FALSE, this XSD is maintained as a separate version.
Raises:

uninstall_cli_ext(self, app_name, app_version, config_domain)

 

This method uninstalls a ClI extension on the specified network element.

Parameters:
  • app_name (str) - The string-value of the application name to be uninstalled.
  • app_version (str) - The string-value of the application version to be uninstalled.
  • config_domain (str) - The string-value of the configuration domain to be uninstalled.
Raises:

is_xsd_installed(self, app_name, app_version, config_domain)

 

This method queries for a ClI extension on the specified network element.

Parameters:
  • app_name (str) - The string-value of the application name to be queried.
  • app_version (str) - The string-value of the application version to be queried.
  • config_domain (str) - The string-value of the configuration domain to be queried.
Raises:

Class Variable Details

cpu_sampling_interval

Value:
property(_get_cpu_sampling_interval, _set_cpu_sampling_interval)

OnepSessionState

Value:
enum('ONEP_STATE_DISCONNECTED', 'ONEP_STATE_CONNECTING', 'ONEP_STATE_C\
ONNECTED', 'ONEP_STATE_RECONNECTING')

OnepSyslogSeverity

Value:
enum('ONEP_SYSLOG_EMERGENCY', 'ONEP_SYSLOG_ALERT', 'ONEP_SYSLOG_CRITIC\
AL', 'ONEP_SYSLOG_ERROR', 'ONEP_SYSLOG_WARNING', 'ONEP_SYSLOG_NOTICE',\
 'ONEP_SYSLOG_INFO', 'ONEP_SYSLOG_DEBUG')

Instance Variable Details

parent

The NetworkApplication instance that created this class.

If the class was created using the constructor of this class, not the NetworkApplication class, this variable will be set to None.