Documentation for PythonAPI
22.40.00py2

packetlogic2.pldb.config

This module contains functionality for managing system configuration on PacketLogic system.

Do NOT import this module directly. The PLConnection object should be used, e.g:

>>> import packetlogic2
>>> pl = packetlogic2.connect("192.168.1.25", "admin", "password")
>>> c = pl.Config()

Classes defined here:

  • Config - This is the resource for manipulating configuration

Config

This is the resource for manipulating configuration.

All configuration options are returned as a string representing their value. When changing a value you should use the actual corresponding python type though. The Config.TYPE_ constants are mapped to the number returned in the 'type' item by the list method. Their name and the below help tells you which python type and which format that configuration option uses.

Inherits from: Resource
Methods:
Config dict get(self, key)
Get information about a specific config option
list of dict list(self)
List configvalues
set(self, key, value)
Set configuration value
Misc reboot(self, message)
Reboot PacketLogic
reload(self, message)
Reload configuration
Ungrouped categories(self)
Retrieve a mapping of bitnumber to category name
flags(self)
Retrieve a mapping of bitnumber to flag name
getvalue(self, key)
Get the value of a specific config option
Inherited from Resource close(self)
Immediately disconnects the resource
commit(self, message='PythonAPI commit')
Store the current transaction to the database
ping(self, string='')
Send a command to server to test if it is up
tuple of (str, int) protocol(self, protocol, strict=False)
Translate protocol name OR number to tuple with name AND number
dict of str:int and int:str protocols_dict(self)
Returns a dictionary with name:nr and nr:name items for IP protocols
rollback(self)
Abort the current transaction and discard the data
services_cmd(self, services=[], props=[])
Send services to pldbd
list of str services_list(self)
List all services
list of str services_prop_list(self)
List all properties
wait_for_commit(self, pinginterval=60)
Wait for new data to be committed on resource
list of str xfb_flags_list(self)
List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects
Class Variables:
TYPE_INVISIBLE Can't be set.
TYPE_STRING str
TYPE_INTEGER int
TYPE_IPADDRESS IP address as str
TYPE_FLOAT float
TYPE_BOOLEAN bool
Properties:
commitid The CommitID associated with this session

categories(self)

Retrieve a mapping of bitnumber to category name.

close(self)

Immediately disconnects the resource.

After this method has been called this object becomes useless.

It may be used to force a disconnect when the garbage collector can't be trusted to do a timely disconnect.

commit(self, message='PythonAPI commit')

Store the current transaction to the database.

When you do this PacketLogic will reload the ruleset. This will take a lot of CPU resources from the system, try to do this in batches.

Observe that if you don't commit the changes you've made, no other resource (including the client) will see your changes.

Parameters:
  • message (str) - Message recorded in the commit log. Ignored in v12.1 and earlier.
  • message parameter is ignored in v12.1 firmware and earlier.

flags(self)

Retrieve a mapping of bitnumber to flag name.

get(self, key)

Get information about a specific config option.

This method is equivalent to list()[key]

Returns:
  • A dict describing a config option
  • dict
Parameters:
  • key (str ) - Name of configuration option. The available options can be seen by the list method.

getvalue(self, key)

Get the value of a specific config option.

This method is equivalent to list()[key]['value']

Returns:
  • The value of the requested config option.
Parameters:
  • key (str ) - Name of configuration option.

list(self)

List configvalues. The values are always represented by a string, but the actual value is different for different configuration options. The 'type' item in conjunction with the Config.TYPE_* constants can be used to decide the type.

>>> x.list()[:2]
[{'defvalue': '',
  'description': 'Lowlevel accept filter',
  'key': 'ACCEPT_FILTERS',
  'maxvalue': '',
  'minvalue': '',
  'type': 1,
  'value': '',
  'visible': True},
 {'defvalue': '',
  'description': 'Lowlevel deny filter',
  'key': 'DENY_FILTERS',
  'maxvalue': '',
  'minvalue': '',
  'type': 1,
  'value': '',
  'visible': True}]
Returns:
  • a list of configvalues
  • list of dict

ping(self, string='')

Send a command to server to test if it is up.

protocol(self, protocol, strict=False)

Translate protocol name OR number to tuple with name AND number. Can be used to e.g translate numerical protocol in connlog.search() result to protocol name.

An unknown protocol will be translated to e.g '#7' or -1, unless strict is set to True, in which case ValueError is raised for unknown protocols.

Returns:
  • Tuple with name and nr of specified protocol.
  • tuple of (str, int)
Parameters:
  • protocol (int, str or a ProtocolObject Item) - Name or number of an IP protocol
  • strict (bool) - If True, ValueError is raised for an unknown protocol, if False (default), an unknown protocol translates to number -1 or name '#7' (where 7 is the supplied unknown protocol number).

protocols_dict(self)

Returns a dictionary with name:nr and nr:name items for IP protocols. Can be used to e.g translate numerical protocol in connlog.search() result to protocol name.

Returns:
  • Dict with name:nr and nr:name items for IP protocols.
  • dict of str:int and int:str

reboot(self, message)

Reboot PacketLogic.

This will reboot the PacketLogic hardware.

Parameters:
  • message (str ) - Message describing the reason for the reload.

reload(self, message)

Reload configuration.

This will reload the PacketLogic configuration, and will cause the API to get disconnected.

Parameters:
  • message (str ) - Message describing the reason for the reload.

rollback(self)

Abort the current transaction and discard the data.

This will also automatically happen if your connection drops or that you exit the program without commit.

Exceptions raised:
  • resource.PLDBError - If the rollback command failed.

services_cmd(self, services=[], props=[])

Send services to pldbd

Sets stringtable for services and properties. Do NOT use this unless you know exactly what you are doing.

Parameters:
  • services (list of str) - List of services
  • props (list of str) - List of service properties

services_list(self)

List all services

Returns:
  • List of services
  • list of str

services_prop_list(self)

List all properties.

Returns:
  • List of service properties
  • list of str

set(self, key, value)

Set configuration value

>>> x.set("PACKET_POOL_SIZE", 500000)
>>> x.set("DRDL_ENABLED", True)
>>> x.set("BGP_SERVER", "192.168.0.47")
Parameters:
  • key (str ) - Name of configuration option. The available options can be seen by the list method.
  • value (str, int, float or bool. ) - New value for the configuration option. The type depends on the variable. Use the 'type' item in the dict returned by the list method in conjunction with the Config.TYPE_* constants to decide type and format of each configuration option.

wait_for_commit(self, pinginterval=60)

Wait for new data to be committed on resource.

This method returns as soon as the server signals that another client has committed new data to the resource. It also periodically tests the connection to the server. If connection is broken (or any other error happens) an exception is raised.

Parameters:
  • pinginterval (int) - Interval used to check if connection still is alive.

xfb_flags_list(self)

List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects.

Returns:
  • List of XFB flags
  • list of str

commitid

The CommitID associated with this session. (14.0 or newer only)