Documentation for PythonAPI
12.1-2

packetlogic2.pldb.ruleset

This module contains functionality for managing the ruleset on the 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", "pldemo00")
>>> r = pl.Ruleset()

Classes defined here:

  • Ruleset - The Ruleset resource is used for reading and manipulating objects and rules

Ruleset

The Ruleset resource is used for reading and manipulating objects and rules in the PacketLogic ruleset.

See also NetObjects, PortObjects, ProtocolObjects, ServiceObjects, TimeObjects, VlanObjects, PropertyObjects, RewriteObjects, FlagObjects and SystemObjects, MPLSObjects, DSCPObjects, ChannelObjects, ShapingObjects, StatisticsObjects, as well as FwRules and ShapingRules. StatisticsRules.

Inherits from: Resource
Methods:
Deprecated int add(self, path)
Add a Object to the object-tree
remove(self, path)
Removes an Object and all its children
unlink(self, path)
Removes an Object for all firewall and shapingrules
Firewall rules FwRule fwrule_add(self, name, action, quick=False, log=False, rewrite_object=0, monitor_iface=0, inject_data='', divert_iface=0)
Create a new firewall rule
FwRule fwrule_find(self, name, systemid=None)
Find a firewallrule by name
FwRule fwrule_find_id(self, rule_id, systemid=None)
Find a firewallrule by id
list of FwRule fwrule_list(self)
Return a list of all firewall rules
fwrule_remove(self, rule)
Remove firewall rule
Objects plobject.PLObject object_add(self, path)
Add an Object to the object-tree
plobject.PLObject object_find(self, path, systemid=None)
This method finds an object by type and name
plobject.PLObject object_find_id(self, path, object_id, systemid=None)
This method finds a object by type and id number
plobject.PLObject object_get(self, path, systemid=None)
This method gets an object by type and name
list of plobject.PLObject object_list(self, path='/', recursive=True, systemid=None)
Lists all the Objects that match the path
object_remove(self, object)
Removes an Object and all its children
object_unlink(self, path)
Removes an Object for all firewall and shapingrules
Services 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
Shaping objects ShapingObject shapingobject_add(self, name, inbound=[(0, 0, 0)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=0, vbs_hours=0, max_connections=0, flags=[])
Create a new ShapingObject in pldb
ShapingObject shapingobject_find(self, name, systemid=None)
Find a shaping object by its name
ShapingObject shapingobject_find_id(self, object_id, systemid=None)
Find a shaping object by its id
list of ShapingObject shapingobject_list(self)
Return a list of all shaping objects
shapingobject_remove(self, object)
Remove shaping object
Shaping rules ShapingRule shapingrule_add(self, name, priority=5, max_connections=None)
Create a new shapingrule in pldb
ShapingRule shapingrule_find(self, name, systemid=None)
Find a shapingrule by name
ShapingRule shapingrule_find_id(self, rule_id, systemid=None)
Find a shapingrule by id
list of ShapingRule shapingrule_list(self)
Return a list of all shaping rules
shapingrule_remove(self, rule)
Remove shaping rule
Statistics objects StatisticsObject statisticsobject_add(self, name, total_fields, graph_fields, split, no_root=0, so_root=0, graph_freq=300, min_bytes_in=102400, min_bytes_out=102400)
Create a new StatisticsObject in pldb
StatisticsObject statisticsobject_find(self, name, systemid=None)
Find a statistics object by its name
StatisticsObject statisticsobject_find_id(self, object_id, systemid=None)
Find a statistics object by its id
list of StatisticsObject statisticsobject_list(self)
Return a list of all statistics objects
statisticsobject_remove(self, object)
Remove statistics object
Statistics rules StatisticsRule statisticsrule_add(self, name)
Create a new statisticsrule in pldb
StatisticsRule statisticsrule_find(self, name, systemid=None)
Find a statisticsrule by name
StatisticsRule statisticsrule_find_id(self, rule_id, systemid=None)
Find a statisticsrule by id
list of StatisticsRule statisticsrule_list(self)
Return a list of all statistics rules
statisticsrule_remove(self, rule)
Remove statistics rule
Ungrouped __init__(self, host, user, password, port=42000, timeout=None)
read-only list of DivertIface divert_iface_list(self)
Return a list of all divert interfaces
object features_get(self)
Returns a simple object with boolean attributes showing enabled features
read-only list of MonitorIface monitor_iface_list(self)
Return a list of all monitor interfaces
bool refresh(self, force=False, timeout=1.0)
Check for any pending "New data was committed" signals, and invalidate
Inherited from Resource close(self)
Immediately disconnects the resource
commit(self, message='PythonAPI commit')
Store the current transaction to the database
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
list of str xfb_flags_list(self)
List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects
Class Variables:
CONDITION_NETOBJECT_CLIENT Client NetObjects
CONDITION_NETOBJECT_SERVER Server NetObjects
CONDITION_NETOBJECT_HOST Host NetObjects
CONDITION_NETOBJECT_LOCAL Local NetObjects
CONDITION_PORTOBJECT_CLIENT Client PortObjects
CONDITION_PORTOBJECT_SERVER Server PortObjects
CONDITION_SERVICEOBJECT ServiceObjects
CONDITION_VLANOBJECT VLANObjects
CONDITION_VLANOBJECT_IN Inbound VLANObjects
CONDITION_VLANOBJECT_OUT Outbound VLANObjects
CONDITION_PROTOCOLOBJECT ProtocolObjects
CONDITION_TIMEOBJECT TimeObjects
CONDITION_ASPATHOBJECT ASPathObjects
CONDITION_PROPERTYOBJECT PropertyObjects
CONDITION_SYSTEMOBJECT SystemObjects
CONDITION_FLAGOBJECT FlagObjects
CONDITION_MPLSOBJECT MPLSObjects
CONDITION_MPLSOBJECT_IN Inbound MPLSObjects
CONDITION_MPLSOBJECT_OUT Outbound MPLSObjects
CONDITION_DSCPOBJECT DSCPObjects
CONDITION_DSCPOBJECT_IN Inbound DSCPObjects
CONDITION_DSCPOBJECT_OUT Outbound DSCPObjects
CONDITION_CHANNELOBJECT CHANNELObjects
CONDITION_CHANNELOBJECT_IN Inbound CHANNELObjects
CONDITION_CHANNELOBJECT_OUT Outbound CHANNELObjects
CONDITION_OP_EQ Condition equals
CONDITION_OP_NE Condition does not equal
FWRULE_ACTION_ACCEPT Accept connection
FWRULE_ACTION_REJECT Reject connection
FWRULE_ACTION_DROP Drop connection
FWRULE_ACTION_REWRITE Rewrite connection
FWRULE_ACTION_DIVERT Divert connection
FWRULE_ACTION_INJECT Inject data into connection
SPLIT_NONE Split by none
SPLIT_LOCALHOST Split by localhost
SPLIT_HOST_NETOBJECT Split by host netobject
SPLIT_LOCAL_NETOBJECT Split by local netobject
SPLIT_SERVER_NETOBJECT Split by server netobject
SPLIT_CLIENT_NETOBJECT Split by client netobject
SPLIT_CONNECTION Split by connection
SPLIT_SUBSCRIBER Split by subscriber

__init__(self, host, user, password, port=42000, timeout=None)

Undocumented!
Parameters:
  • host (str ) -
  • password (str ) -
  • user (str ) -

add(self, path)

Add a Object to the object-tree. The type and name of the Object is determined by the path.

Returns:
  • id of the newly created object
  • int
Parameters:
  • path (str ) - The path is the new Object to be created. if we want to create a NetObject called Anders under with the NetObject Work as parent you use the path /NetObjects/Work/Anders.
add is deprecated: Port your code to object_add which differs slightly in return value.

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.

divert_iface_list(self)

Return a list of all divert interfaces.

>>> r.monitor_iface_list()
[]
Returns:
  • A list of divert interfaces.
  • read-only list of DivertIface
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.2 firmware or newer.

features_get(self)

Returns a simple object with boolean attributes showing enabled features. The members of the object, that can be True or False, are: bgp, fw, shaping, statistics, connlog (and its alias connsearch), enterprise, monitor, divert and vbs

Returns:
  • Object with a boolean attribute for each feature.
  • object

fwrule_add(self, name, action, quick=False, log=False, rewrite_object=0, monitor_iface=0, inject_data='', divert_iface=0)

Create a new firewall rule.

>>> r.fwrule_add('Test', r.FWRULE_ACTION_ACCEPT, quick=True)
<PacketLogic Rule 'Test'>
>>> rewrite_object_id = r.object_get('/RewriteObjects/Netaccess server').id
>>> r.fwrule_add('Test', r.FWRULE_ACTION_REWRITE, quick=True, rewrite_object=rewrite_object_id)
<PacketLogic Rule 'Test'>
>>> rewrite_object = r.object_get('/RewriteObjects/Netaccess server')
>>> r.fwrule_add('Test', r.FWRULE_ACTION_REWRITE, quick=True, rewrite_object=rewrite_object)
<PacketLogic Rule 'Test'>
Returns:
  • Created firewall rule.
  • FwRule
Parameters:
  • name (str) - The name of the new firewall rule, a rule with this name must not already exist.
  • monitor_iface (int) - If non zero, packets matching this rule will also be sent to the specified interface id. See monitor_iface_list.
  • quick (boolean) - Give this rule the quick property.
  • action (int) - Action when the rule matches, one of: FWRULE_ACTION_ACCEPT FWRULE_ACTION_REJECT, FWRULE_ACTION_DROP, FWRULE_ACTION_REWRITE, FWRULE_ACTION_DIVERT, FWRULE_ACTION_INJECT.
  • divert_iface (int) - Interface to divert packets to when using FWRULE_ACTION_DIVERT. See divert_iface_list.
  • inject_data (str) - The content that shall be injected for FWRULE_ACTION_INJECT rules. The content is usually a HTTP 307 redirect response.
  • log (boolean) - Log hits of this rule.
Exceptions raised:
  • PLDBUnsupportedInFirmware - If inject_data/divert_iface arguments are used and firmware doesn't support them.
  • inject_data parameter requires v12.1 firmware or newer.
  • divert_iface parameter requires v12.2 firmware or newer.

fwrule_find(self, name, systemid=None)

Find a firewallrule by name

>>> r.fwrule_find("allow all")
<PacketLogic Rule 'allow all'>
Returns:
  • Firewall rule or None if not found.
  • FwRule
Parameters:
  • name (str) - The name of the firewall rule.

fwrule_find_id(self, rule_id, systemid=None)

Find a firewallrule by id

>>> r.fwrule_find_id(14)
<PacketLogic Rule 'allow all'>
Returns:
  • Firewall rule or None if not found.
  • FwRule
Parameters:
  • rule_id (int) - The id of the firewall rule.

fwrule_list(self)

Return a list of all firewall rules.

>>> r.fwrule_list()
[<PacketLogic Rule '<PacketLogic Rule 'allow all'>, <PacketLogic Rule 'nxs_accept'>, <PacketLogic Rule 'Allow all DHCP'>, <PacketLogic Rule 'Netaccess redirect'>, <PacketLogic Rule 'Netaccess DHCP'>, <PacketLogic Rule 'Netaccess'>]
Returns:
  • A list of firewall rules.
  • list of FwRule

fwrule_remove(self, rule)

Remove firewall rule

>>> r.fwrule_add('Example', r.FWRULE_ACTION_ACCEPT, quick=True)
<PacketLogic Rule 'Example'>
>>> r.fwrule_remove('Example')
>>> rule = r.fwrule_add('Example', r.FWRULE_ACTION_ACCEPT, quick=True)
>>> r.fwrule_remove(rule)
Parameters:
  • rule (str or plrule.FwRule ) - The name or actual rule to be removed.
Exceptions raised:
  • ValueError - If firewall rule is not found

monitor_iface_list(self)

Return a list of all monitor interfaces.

>>> r.monitor_iface_list()
[<PacketLogic Monitor Interface 'PCAP Writer'>, <PacketLogic Monitor Interface 'DHCP Snooper'>, <PacketLogic Monitor Interface 'RADIUS Snooper'>, <PacketLogic Monitor Interface 'PCAP-2 Writer'>]
Returns:
  • A list of monitor interfaces.
  • read-only list of MonitorIface

object_add(self, path)

Add an Object to the object-tree. The type and name of the Object is determined by the path.

Returns:
  • A plobject.PLObject subclass.
  • plobject.PLObject
Parameters:
  • path (str ) - The path is the new Object to be created. if we want to create a NetObject called Anders under with the NetObject Work as parent you use the path /NetObjects/Work/Anders.
Exceptions raised:
  • RuntimeError - "Unknown object item type": for invalid type of object. Should never happen unless e.g two api-versions are mixed up.

object_find(self, path, systemid=None)

This method finds an object by type and name.

>>> r.object_find('/NetObjects/TestObject')
<PacketLogic NetObject 'TestObject' '/NetObjects'>
>>> print r.object_find('/NetObjects/DoesNotExist')
None

It is a synonym for object_get, that soon will be deprecated.

Returns:
  • Object if found, else None
  • plobject.PLObject
Parameters:
  • path (str) - a path string (i.e. /NetObjects/Corporate)
  • systemid (str ) - Get object with specified systemid if specified, otherwise default to local object.
Exceptions raised:
  • RuntimeError - "Unknown object item type": for invalid type of object. Should never happen unless e.g two api-versions are mixed up.

object_find_id(self, path, object_id, systemid=None)

This method finds a object by type and id number.

>>> r.object_find_id('/NetObjects', 31573)
<PacketLogic NetObject 'TestObject' '/NetObjects'>
>>> print r.object_find_id('/NetObjects', 7777777)
None
Returns:
  • A plobject.PLObject subclass.
  • plobject.PLObject
Parameters:
  • path (str) - a path string (i.e. /NetObjects)
  • systemid (str ) - Get object with specified systemid if specified, otherwise default to local object.
  • object_id (int) - ID number of the Object. Could be found by examining the id property of any plobject.PLObject implementation.
Exceptions raised:
  • RuntimeError - "Unknown object item type": for invalid type of object. Should never happen unless e.g two api-versions are mixed up.

object_get(self, path, systemid=None)

This method gets an object by type and name.

>>> r.object_get('/NetObjects/TestObject')
<PacketLogic NetObject 'TestObject' '/NetObjects'>
>>> r.object_get('/NetObjects/TestObject')
<PacketLogic NetObject 'TestObject' '/NetObjects'>

It will soon be deprecated in favour for the synonym object_find.

Returns:
  • Object if found, else None
  • plobject.PLObject
Parameters:
  • path (str) - a path string (i.e. /NetObjects/Corporate)
  • systemid (str ) - Get object with specified systemid if specified, otherwise default to local object.
Exceptions raised:
  • RuntimeError - "Unknown object item type": for invalid type of object. Should never happen unless e.g two api-versions are mixed up.

object_list(self, path='/', recursive=True, systemid=None)

Lists all the Objects that match the path.

>>> r.object_list('/NetObjects')
[<PacketLogic NetObject 'Netaccess Kunder' '/NetObjects'>, <PacketLogic NetObject 'Netaccess allowed servers' '/NetObjects'>,
<PacketLogic NetObject 'nxs' '/NetObjects'>, <PacketLogic NetObject 'DummyPlaceholder' '/NetObjects'>,
<PacketLogic NetObject 'nxs_Bandbredd 2000' '/NetObjects/nxs'>, <PacketLogic NetObject 'TestObject' '/NetObjects'>,
<PacketLogic NetObject 'TestNetobject' '/NetObjects'>, <PacketLogic NetObject 'TestNetobject-Deuxe' '/NetObjects'>,
<PacketLogic NetObject 'NetintactTest' '/NetObjects'>, <PacketLogic NetObject 'Kruken' '/NetObjects/nxs'>,
<PacketLogic NetObject 'nxs_1M [3]' '/NetObjects/nxs'>, <PacketLogic NetObject 'nxs_4Mbit [2]' '/NetObjects/nxs'>,
<PacketLogic NetObject 'nxs_256kbit [1]' '/NetObjects/nxs'>]
Returns:
  • A list of plobject.PLObject subclassed objects.
  • list of plobject.PLObject
Parameters:
  • path (str ) - The path of Objects you want to list. I.e. you want to list all the NetObjects set the path to /NetObjects. This will recursively list all NetObjects (if you don't touch the recursive parameter). You can also specify the path deeper into the tree, i.e. /NetObjects/work will list all NetObjects with the object work as parent.
  • systemid (str ) - If specified limits the list to only include objects with the specified systemid.
  • recursive (boolean ) - This specifies if the list should be recursively done. When set to False it will only list the items on the current level of path.
Exceptions raised:
  • RuntimeError - "Unknown object item type": for invalid type of object. Should never happen unless e.g two api-versions are mixed up.

object_remove(self, object)

Removes an Object and all its children.

Note that object_unlink only unlinks the current object, while object_remove also removes children. To both unlink and remove and object, you will need to call unlink for all children too.

>>> r.object_add("/NetObjects/Example")
>>> r.object_remove("/NetObjects/Example")
>>> obj = r.object_add("/NetObjects/Example")
>>> r.object_remove(obj)
Parameters:
  • object (str or plobject.PLObject ) - The Object to be removed or the full path.

object_unlink(self, path)

Removes an Object for all firewall and shapingrules.

Note that object_unlink only unlinks the current object, while object_remove also removes children. To both unlink and remove and object, you will need to call unlink for all children too.

This method replaces unlink that will soon be deprecated.

Parameters:
  • path (str) - The Object to be removed.

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:
  • 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).
  • protocol (int, str or a ProtocolObject Item) - Name or number of an IP protocol

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

refresh(self, force=False, timeout=1.0)

Check for any pending "New data was committed" signals, and invalidate cached objects and rules if it occurs, or force them to be invalidated with force=True. Returns True if such an exception occured (and was trapped), otherwise false. Any other exception than the PLDBError "New data comitted" or timeout will not be trapped.

>>> rs.refresh(); rs.object_add('/NetObjects/TestObject'); rs.commit()
True
<PacketLogic NetObject 'TestObject' '/NetObjects'>
Returns:
  • True if a "New data was committed" signal was seen, otherwise False.
  • bool
Parameters:
  • force (bool) - If set to True the cache in the API of rules and objects will be marked dirty, forcing them to be reread from the PacketLogic system upon the next query, even if no "New data was comitted" signal occured.
  • timeout (float) - Seconds to wait for any data to arrive from the PacketLogic. Since we typically check for "New data was commited" that already are pending, this can be short, and default is one second. Zero is not allowed, and will silently be changed to 0.1

remove(self, path)

Removes an Object and all its children.

Parameters:
  • path (str ) - The Object to be removed.
remove is deprecated: Renamed to object_remove Using this method issues a deprecation warning after 11.0beta5.

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

shapingobject_add(self, name, inbound=[(0, 0, 0)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=0, vbs_hours=0, max_connections=0, flags=[])

Create a new ShapingObject in pldb

>>> r.shapingobject_add('Test Shaping',
...     inbound=[(0, 0, 1024)], # 1024 kbyte/s inbound
...     outbound=[(0, 0, 512)], # 512 kbyte/s outbound
...     bidir=[(0, 0, 0)])
<PacketLogic ShapingObject ('Test Shaping', inbound=[(0, 0, 1024)], outbound=[(0, 0, 512)], bidir=[(0, 0, 0)], split=0, vbs_hours=0)>
>>> r.shapingobject_add('Test VBS', inbound=[
...             (128, 0, 1024),  # 128 MiB at 1024 kbyte/s
...             (256, 0,  512),  # 256 MiB at 512 kbyte/s
...             (512, 0,  128),  # 512 MiB at 128 kbyte/s
...             (  0, 0,   64)], # Unlimited at 64 kbyte/s
...     outbound=[(0, 0, 0)],
...     bidir=[(0, 0, 0)],
...     vbs_hours=720) # 30 days (30*24 hours)
<PacketLogic ShapingObject ('Test VBS', inbound=[(128, 0, 1024), (256, 0, 512), (512, 0, 128), (0, 0, 64)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=0, vbs_hours=720)>
Returns:
Parameters:
  • bidir (list of tuple) - same as inbound but for both directions
  • outbound (list of tuple) - same as inbound but for outgoing traffic
  • name (str) - Name of the new object
  • inbound (list of tuple) - list of limits for incoming traffic, where each limit is (max_transfer, max_packets, max_speed) max_transfer must be 0 (unlimited) on the last entry in the list.
  • vbs_hours (int) - Duration in hours if this is a VBS (Volume Based Shaping) object. Value 0 means that VBS is not used on this object. Value 1 means that no sliding window is used, and you will need to reset volume manually with Realtime.vbs_reset.
  • flags (list of str) - List of the flags to set, if any. Flags can be any combination of: 'brown', 'host_fairness'
  • split (int) - Type of split, one of: SPLIT_NONE, SPLIT_LOCALHOST, SPLIT_HOST_NETOBJECT, SPLIT_LOCAL_NETOBJECT, SPLIT_SERVER_NETOBJECT, SPLIT_CLIENT_NETOBJECT, SPLIT_CONNECTION, SPLIT_SUBSCRIBER
  • max_connections (int) - Limit number of connections, or 0 for unlimited.

shapingobject_find(self, name, systemid=None)

Find a shaping object by its name

>>> r.shapingobject_find('Test Shaping')
<PacketLogic ShapingObject ('Test Shaping', inbound=[(0, 0, 1024)], outbound=[(0, 0, 512)], bidir=[(0, 0, 0)], split=0, vbs_hours=0)>
Returns:
Parameters:
  • name (str) - Name of shaping object to find

shapingobject_find_id(self, object_id, systemid=None)

Find a shaping object by its id

>>> r.shapingobject_find_id(83)
<PacketLogic ShapingObject ('Test Shaping', inbound=[(0, 0, 1024)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=1, vbs_hours=0)>
Returns:
Parameters:
  • object_id (int) - Id of shaping object to find

shapingobject_list(self)

Return a list of all shaping objects.

>>> r.shapingobject_list()
[<PacketLogic ShapingObject ('Test VBS', inbound=[(128, 0, 1024), (256, 0, 512), (512, 0, 128), (0, 0, 64)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=0, vbs_hours=720)>,
 <PacketLogic ShapingObject ('Test Shaping', inbound=[(0, 0, 1024)], outbound=[(0, 0, 512)], bidir=[(0, 0, 0)], split=0, vbs_hours=0)>]
Returns:

shapingobject_remove(self, object)

Remove shaping object

>>> r.shapingobject_add("Example")
<PacketLogic ShapingObject ('Example', inbound=[(0, 0, 0)], outbound=[(0, 0, 0)], bidir=[(0, 0, 0)], split=0, vbs_hours=0)>
>>> r.shapingobject_remove("Example")
>>> object = r.shapingobject_add("Example")
>>> r.shapingobject_remove(object)
Parameters:
  • object (str or plrule.FwRule ) - The name or actual rule to be removed.
Exceptions raised:
  • ValueError - If shaping object is not found

shapingrule_add(self, name, priority=5, max_connections=None)

Create a new shapingrule in pldb

>>> r.shapingrule_add('Example')
<PacketLogic Rule 'Example'>
>>> r.shapingrule_add('Example2', priority=20)
<PacketLogic Rule 'Example2'>
Returns:
Parameters:
  • priority (int) - Priority of packets matching this rule
  • name (str) - Name of the new rule
shapingrule_add is deprecated: The max_connections argument is not supported since version 11.x Supplying it as 0 will generate a deprecation warning, a nonzero value will raise an exception. Use max_connections argument on shapingobject_add() instead.

shapingrule_find(self, name, systemid=None)

Find a shapingrule by name

>>> r.shapingrule_find('Example')
<PacketLogic Rule 'Example'>
Returns:
Parameters:
  • name (str) - Name of shaping rule to find

shapingrule_find_id(self, rule_id, systemid=None)

Find a shapingrule by id

>>> r.shapingrule_find(27)
<PacketLogic Rule 'Example'>
Returns:
Parameters:
  • rule_id (int) - Id of shaping rule to find

shapingrule_list(self)

Return a list of all shaping rules.

>>> r.shapingrule_list()
[<PacketLogic Rule 'Example'>, <PacketLogic Rule 'Example2'>]
Returns:

shapingrule_remove(self, rule)

Remove shaping rule

>>> r.shapingrule_add('Example')
<PacketLogic Rule 'Example'>
>>> r.shapingrule_remove('Example')
>>> rule = r.shapingrule_add('Example')
>>> r.shapingrule_remove(rule)
Parameters:
Exceptions raised:
  • ValueError - If shaping rule is not found

statisticsobject_add(self, name, total_fields, graph_fields, split, no_root=0, so_root=0, graph_freq=300, min_bytes_in=102400, min_bytes_out=102400)

Create a new StatisticsObject in pldb

>>> r.statisticsobject_add('Test Statistics',
Returns:
Parameters:
  • name (str) - Name of the new object
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsobject_find(self, name, systemid=None)

Find a statistics object by its name

>>> r.statisticsobject_find('Test Statistics')
<PacketLogic StatisticsObject>
Returns:
Parameters:
  • name (str) - Name of statistics object to find
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsobject_find_id(self, object_id, systemid=None)

Find a statistics object by its id

>>> r.statisticsobject_find_id(83)
<PacketLogic StatisticsObject>
Returns:
Parameters:
  • object_id (int) - Id of statistics object to find
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsobject_list(self)

Return a list of all statistics objects.

>>> r.statisticsobject_list()
[<PacketLogic StatisticsObject>,
 <PacketLogic StatisticsObject>]
Returns:
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsobject_remove(self, object)

Remove statistics object

>>> r.statisticsobject_add("Example")
<PacketLogic StatisticsObject ('Example')>
>>> r.statisticsobject_remove("Example")
>>> object = r.statisticsobject_add("Example")
>>> r.statisticsobject_remove(object)
Parameters:
  • object (str or statisticsobject.StatisticObject ) - The name or actual rule to be removed.
Exceptions raised:
  • ValueError - If statistics object is not found
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsrule_add(self, name)

Create a new statisticsrule in pldb

>>> r.statisticsrule_add('Example')
<PacketLogic Rule 'Example'>
>>> r.statisticsrule_add('Example2', priority=20)
<PacketLogic Rule 'Example2'>
Returns:
Parameters:
  • name (str) - Name of the new rule
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsrule_find(self, name, systemid=None)

Find a statisticsrule by name

>>> r.statisticsrule_find('Example')
<PacketLogic Rule 'Example'>
Returns:
Parameters:
  • name (str) - Name of statistics rule to find
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsrule_find_id(self, rule_id, systemid=None)

Find a statisticsrule by id

>>> r.statisticsrule_find(27)
<PacketLogic Rule 'Example'>
Returns:
Parameters:
  • rule_id (int) - Id of statistics rule to find
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsrule_list(self)

Return a list of all statistics rules.

>>> r.statisticsrule_list()
[<PacketLogic Rule 'Example'>, <PacketLogic Rule 'Example2'>]
Returns:
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

statisticsrule_remove(self, rule)

Remove statistics rule

>>> r.statisticsrule_add('Example')
<PacketLogic Rule 'Example'>
>>> r.statisticsrule_remove('Example')
>>> rule = r.statisticsrule_add('Example')
>>> r.statisticsrule_remove(rule)
Parameters:
Exceptions raised:
  • ValueError - If statistics rule is not found
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

unlink(self, path)

Removes an Object for all firewall and shapingrules.

This method will soon be deprecated. Use synonym object_unlink instead.

Parameters:
  • path (str) - The Object to be removed.

xfb_flags_list(self)

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

Returns:
  • List of XFB flags
  • list of str