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

Class SessionConfig


SessionConfig contains the configuration that will be used for connecting to the network element.

SessionConfig provides a means to configure session attributes prior to connecting to a NetworkElement. The SessionConfig data is used at the NetworkElement.connect() time. On successful connection, the session attributes for that particular session can no longer be modified. However, the SessionConfig object can be modified as needed, and reused to NetworkElement.connect() to other network elements. To modify the session attributes for an active session, call NetworkElement.disconnect() and NetworkElement.connect() again passing in the modified attributes set in the SessionConfig object. If needed, the session attributes for an active session can be retrieved using the SessionHandle returned by NetworkElement.connect(). The SessionHandle holds the session attributes for an active session. The session attributes from the provided SessionConfig are copied to a SessionProperty as static property of the session.

The SessionConfig object is required only if the defaults need to be overridden. Passing a null for the SessionConfig in the connect() call will result in a TLS connection between the application and the network element using default values. See specific setter APIs for the defaults for each attribute.

Instance Methods
 
__init__(self, transport)
Constructor
 
set_tls_pinning(self, pinning_file, handler)
Sets the parameters for TLS pinning.

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

Class Variables
  SessionTransportMode = enum('SOCKET', 'TLS', 'TIPC')
  OnepEventDropMode = enum('ONEP_EVENT_DROP_NEW', 'ONEP_EVENT_DR...
  DEFAULT_TRANSPORT_MODE = 1
  DEFAULT_PORT = 15002
  DEFAULT_RECONNECT_TIMER = 0
  DEFAULT_EVENT_QUEUE_SIZE = 200
  DEFAULT_THREADPOOL_SIZE = 10
  DEFAULT_EVENT_DROP_MODE = 0
  DEFAULT_KEEPALIVE_IDLE_TIME = 60
  MIN_KEEPALIVE_IDLE_TIME = 60
  DEFAULT_KEEPALIVE_INTERVAL = 30
  DEFAULT_KEEPALIVE_RETRY_COUNT = 2
  MIN_STACK_SIZE = 32768
Instance Variables
str ca_certs
The Certification Authority certificates file location.
str certfile
The client certificate file location.
str keyfile
The client key file location.
int read_write_timeout
Timeout of response to read or write request.
string vm_credential_file
Virtual Machine credentials allowing for internal container connection.
Properties
  transportMode
Transport type to be used for the session.
  reconnectTimer
Reconnect timeout for the session.
  port
Port number for the session.
  eventQueueSize
The size of the local event queue in the range of 1 - 1000.
  eventThreadPool
Specifies the number of dispatcher threads.
  eventDropMode
Event drop mode type to be used for the session.
  keepAliveIdleTime
The idle time in seconds.
  keepAliveInterval
The interval between each retry in the unit of seconds.
  keepAliveRetryCount
The retry count number of keepalive.
  thread_stack_size
The thread stack size.
  tls_pinning_file
The path of the pinning file to use.
  tls_unverified_element_handler
The handler to use.

Inherited from object: __class__

Method Details

__init__(self, transport)
(Constructor)

 

Constructor

Keyword argument:
transport
    Transport type to be used for the session. If the value is
    null, the default transport type will be used. The default
    transport is SessionTransportMode.TLS.

Overrides: object.__init__

set_tls_pinning(self, pinning_file, handler)

 

Sets the parameters for TLS pinning.

Pinning is the process by which certain hosts can be whitelisted for TLS verification. If the presented certificate matches the known certificate for that host in the pinning file, that connection proceeds even if the certificate fails the customary TLS verification. Using a handler for unverified TLS hosts, an application may present a fingerprint of the unknown host to a user for manual verification.

Parameters:
  • pinning_file (str) - The path to the pinning file to use. If None, no pinning file will be used. By default, no pinning file is used.
  • handler (TLSUnverifiedElementHandler) - The handler to use. If None, the default action is taken which is to terminate the connection that is not verified.

Class Variable Details

OnepEventDropMode

Value:
enum('ONEP_EVENT_DROP_NEW', 'ONEP_EVENT_DROP_OLD')

Instance Variable Details

read_write_timeout

Timeout of response to read or write request. Default is 180 seconds
Type:
int

vm_credential_file

Virtual Machine credentials allowing for internal container connection. Credentials created from local file in container or constructed by container service set. Default "/cisco/onep/info.data"
Type:
string

Property Details

transportMode

Transport type to be used for the session. If the value is None, the default transport type will be used. The default transport is SessionConfig.SessionTransportMode.TLS

Get Method:
_get_transport_mode(self)
Set Method:
_set_transport_mode(self, transportMode)

reconnectTimer

Reconnect timeout for the session. If the value is less than or equal to 0, there will be no timeout for reconnect.

Get Method:
_get_reconnect_timer(self)
Set Method:
_set_reconnect_timer(self, reconnectTimer)

port

Port number for the session. If the value is equal to or less than 0, the default port will be used which is OnepConstants.ONEP_TLS_PORT

Get Method:
_get_port(self)
Set Method:
_set_port(self, port)

eventQueueSize

The size of the local event queue in the range of 1 - 1000. If the value is out of range, the default value 200 is used.

Get Method:
_get_event_queue_size(self)
Set Method:
_set_event_queue_size(self, eventQueueSize)

eventThreadPool


Specifies the number of dispatcher threads. Any positive integer is allowed for the thread count. 
If the value equals or less than 0, the default value 10 is used.
The upper bound for the thread pool depends on the following factors:
1. Available memory on the system where the application runs
2. The expected number of network elements that the application connects to.
   A separate thread pool is created for every connected NetworkElement object.
3. The expected rate of incoming events and the event queue size that the threads will service.

Get Method:
_get_event_thread_pool(self)
Set Method:
_set_event_thread_pool(self, eventThreadPool)

eventDropMode

Event drop mode type to be used for the session. If the value is null, the default will be SessionConfig.OnepEventDropMode.ONEP_EVENT_DROP_NEW. When the event queue is full, new event will be dropped by default. But if this value is set to ONEP_EVENT_DROP_OLD, oldest event in the queue is dropped to allow new event to be queued.

Get Method:
_get_event_drop_mode(self)
Set Method:
_set_event_drop_mode(self, eventDropMode)

keepAliveIdleTime

The idle time in seconds. Any value between SessionConfig.MIN_KEEPALIVE_IDLE_TIME and Integer.MAX_VALUE is allowed. If the value is out of this range, default value will be assigned. Default value is SessionConfig.DEFAULT_KEEPALIVE_IDLE_TIME seconds.

Get Method:
_get_keep_alive_idle_time(self)
Set Method:
_set_keep_alive_idle_time(self, keepAliveIdleTime)

keepAliveInterval

The interval between each retry in the unit of seconds. Any value between 0 and Integer.MAX_VALUE is allowed. If the value is out of this range, default value will be assigned. Default is SessionConfig.DEFAULT_KEEPALIVE_INTERVAL seconds.

Get Method:
_get_keep_alive_interval(self)
Set Method:
_set_keep_alive_interval(self, keepAliveInterval)

keepAliveRetryCount

The retry count number of keepalive. Any value between 0 and Integer.MAX_VALUE is allowed. If the value is out of this range, default value SessionConfig.DEFAULT_KEEPALIVE_RETRY_COUNT will be assigned.

Get Method:
_get_keep_alive_retry_count(self)
Set Method:
_set_keep_alive_retry_count(self, keepAliveRetryCount)

thread_stack_size

The thread stack size. Must be set before conneting. If set to 0, the value will be the OS default stack size. The minimum value is SessionConfig.MIN_STACK_SIZE

Get Method:
_get_thread_stack_size(self)
Set Method:
_set_thread_stack_size(self, size)

tls_pinning_file

The path of the pinning file to use. If null, no pinning file will be used. By default, no pinning file is used.

Get Method:
_get_tls_pinning_file(self)
Set Method:
_set_tls_pinning_file(self, pinning_file)

tls_unverified_element_handler

The handler to use. If null, the default action is taken which is to terminate the connection that is not verified.

Get Method:
_get_tls_unverified_element_handler(self)
Set Method:
_set_tls_unverified_element_handler(self, handler)