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()
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.
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 |
Retrieve a mapping of bitnumber to category name.
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.
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.
str
) - Message recorded in the commit log. Ignored in v12.1 and earlier.
Retrieve a mapping of bitnumber to flag name.
Get information about a specific config option.
This method is equivalent to list()[key]
dict
str
) - Name of configuration option. The available options can be seen by the list method.Get the value of a specific config option.
This method is equivalent to list()[key]['value']
str
) - Name of configuration option.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}]
list
of dict
Send a command to server to test if it is up.
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.
tuple
of (str
, int
)
int
, str
or a ProtocolObject
Item) - Name or number of an IP protocol
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).
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.
dict
of str
:int
and
int
:str
Reboot PacketLogic.
This will reboot the PacketLogic hardware.
str
) - Message describing the reason for the reload.Reload configuration.
This will reload the PacketLogic configuration, and will cause the API to get disconnected.
str
) - Message describing the reason for the reload.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.
Send services to pldbd
Sets stringtable for services and properties. Do NOT use this unless you know exactly what you are doing.
list
of str
) - List of services
list
of str
) - List of service properties
Set configuration value
>>> x.set("PACKET_POOL_SIZE", 500000) >>> x.set("DRDL_ENABLED", True) >>> x.set("BGP_SERVER", "192.168.0.47")
str
) - Name of configuration option. The available options can be seen by the list method.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 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.
List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects.
list
of str
The CommitID associated with this session. (14.0 or newer only)