Documentation for PythonAPI
22.40.00py2

packetlogic2.pld.pld

This module contains functionality for accessing the realtime parts of the PacketLogic system, such as system diagnostics, channel statistics and dynamic netobject items.

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")
>>> rt = pl.Realtime()

Classes defined here:

  • Dyn - Operations on dynamic netobject items
  • KeyVault - Operations on the key vault used for encrypted property objects
  • PLD - Class for connecting and communicating with packetlogicd, the realtime part
  • RealtimeConn - Object containing realtime information of a connection
  • RealtimeHost - Object containing realtime information of a host
  • ViewBuilder - Builder for creating views with filters and distributions

Dyn

Operations on dynamic netobject items.

Methods:
Ungrouped add(self, no, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='', properties={})
Add a dynamic netobject item
list of tuple list(self, netobject=None, ip=None, recurse=False, properties=[])
List dynamic netobject items
remove(self, no, ip)
Remove a dynamic netobject item
int remove_orphans(self)
Removes all orphan dynamic netobject items
set(self, baseno, ip, items)
Set multiple dynamic netobject items under a base netobject
set_begin(self, baseno)
Starts a session of following set() operations under a base netobject
int set_end(self, baseno, abort=False)
Ends a session of set() operations, started by set_begin(), under a base
Class Variables:
SUBSCRIBER_NAME Constant for the "subscriber name" key in property lists.
IS_SUBSCRIBER Constant for the "is subscriber" key in property lists.
LINKSPEED_IN Constant for the "inbound linkspeed" key in property lists.
LINKSPEED_OUT Constant for the "outbound linkspeed" key in property lists.
NATCFG Constant for the "nat config" key in property lists.

add(self, no, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='', properties={})

Add a dynamic netobject item

Please note that netobject will not be verified with regard to
performance and flexibility when adding to a uncommitted
netobject.

        >>> rt.dyn.add(31682, '127.0.0.1')

@type id: C{int}
@param id: the id number of the netobject to add the item to.

@type ip: C{str}
@param ip: the IP address to add.

@type subscriber: C{str}
@param subscriber: Subscriber name - or empty string to not create subscriber.

@type is_subscriber: C{bool}
@param is_subscriber: is subscriber property - used for subscriber count in statistics.

@type linkspeed_in: C{int}
@param linkspeed_in: linkspeed_in property - used in statistics.

@type linkspeed_out: C{int}
@param linkspeed_out: linkspeed_out property - used in statistics.

@type natcfg: C{str}
@param natcfg: natcfg property - used to config subscribers NAT. Requires v14.0 firmware or newer.

@type properties: C{dict}
@param properties: Dict of properties. Requires v15.1 firmware of newer.
              properties is a dict which may
              contain zero or more of the keys
              rt.dyn.SUBSCRIBER_NAME,
              rt.dyn.IS_SUBSCRIBER,
              rt.dyn.LINKSPEED_IN,
              rt.dyn.LINKSPEED_OUT,
              rt.dyn.NATCFG,
              rt.dyn.USERDATA{1-8}

@raises PLDPermissionError: If the user lacks permission for requested action
@raises PLDServerError: If server reported an error
@raises ValueError: If an invalid IP address is used

list(self, netobject=None, ip=None, recurse=False, properties=[])

List dynamic netobject items.

>>> rt.dyn.list(netobject=300, recurse=True, properties=[rt.dyn.SUBSCRIBER_NAME])
[('10.0.0.2',
  [(339L, [{1: 'User0001'}]),
   (337L, [{1: 'User0001'}])]),
 ('10.0.0.3',
  [(339L, [{1: 'User0002'}]),
   (335L, [{1: 'User0002'}])])]
Returns:
  • A list of dynitems grouped by ip address, e.g [(IP1, [(NO1, [PROPS..]), (NO2, [PROPS])]), (IP2, [(NO1, [PROPS..]), (NO2, [PROPS])])]
  • list of tuple
Parameters:
  • netobject (int) - Only list items in specified netobject (or any netobject under it if recurse parameter is True)
  • ip (str) - Only list items for specified ip/mask address (or any ip under it if recurse parameter is True)
  • recurse (bool) - Also list items below specified netobject/ip
  • properties (list) - Properties to include in result. Should be a list containing zero or more of SUBSCRIBER_NAME, IS_SUBSCRIBER, LINKSPEED_IN, LINKSPEED_OUT, NATCFG

remove(self, no, ip)

Remove a dynamic netobject item

>>> rt.dyn.remove(31682, '127.0.0.1')
Parameters:
  • no (int) - the id number of the netobject to remove the item from.
  • ip (str) - the ip number to remove.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDServerError - If server reported an error

remove_orphans(self)

Removes all orphan dynamic netobject items. An orphan dynamic netobject item is a dynamic netobject item created in a netobject that no longer exists. For example:

>>> rs=pl.Ruleset()
>>> rt=pl.Realtime()
>>> o=rs.object_add("/NetObjects/example")
>>> rs.commit()
>>> # Wait for plrcd to read up the commit
>>> rt.dyn.add(o.id, '127.0.0.1', "subscriber")
True
>>> rs.object_remove(o)
>>> rs.commit()
>>> # Wait for plrcd to read up the commit
>>> rt.dyn.remove_orphans()
1L

Note that created/removed object will not appear/disappear until the change has been committed. Be warned that the following might remove wanted dynamic netobject items:

>>> rs=pl.Ruleset()
>>> rt=pl.Realtime()
>>> o=rs.object_add("/NetObjects/example2")
>>> rt.dyn.add(o.id, '127.0.0.2', "subscriber2")
True
>>> rt.dyn.remove_orphans()
1L

In this example the newly added dynamic netobject item '127.0.0.2' will be removed by remove_orphan() as the parent netobject was not yet committed.

Returns:
  • Number of removed orphans dynamic netobject items
  • int
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDServerError - If server reported an error

set(self, baseno, ip, items)

Set multiple dynamic netobject items under a base netobject.

        >>> rt.dyn.set(300, "10.0.0.4", [(339, {rt.dyn.SUBSCRIBER_NAME: 'User0003', rt.dyn.IS_SUBSCRIBER: True}),
        ...                              (337, {rt.dyn.SUBSCRIBER_NAME:'User0003', rt.dyn.IS_SUBSCRIBER: True})])
        >>> rt.dyn.set(300, "10.0.0.3", [])

This function replaces all dynamic netobject items
that exists for the specified ip address in the
netobject tree under the specified base netobject id.

@type baseno: C{int}
@param baseno: the id number of the netobject to operate under.

@type ip: C{str}
@param ip: the ip number to set items for.

@type items: C{sequence} of C{tuples}
@param items: the items to add, each item should be a
              tuple of (netobjectid, properties),
              where properties is a dict which may
              contain zero or more of the keys
              rt.dyn.SUBSCRIBER_NAME,
              rt.dyn.IS_SUBSCRIBER,
              rt.dyn.LINKSPEED_IN,
              rt.dyn.LINKSPEED_OUT
              rt.dyn.NATCFG
              rt.dyn.USERDATA{1-8}

@raises PLDPermissionError: If the user lacks permission for requested action
@raises PLDUnsupportedInFirmware: If firmware doesn't support this function.
@raises PLDServerError: If server reported an error

set_begin(self, baseno)

Starts a session of following set() operations under a base netobject.

When zero or more set() have been performed and set_end() is called, all dynamic netobject items under the baseno NetObject that were not set by any set() will be removed.

Performing a series of set() operations between a pair of set_begin() and set_end() will make sure that all dynamic netobject items under the baseno NetObject will be exactly defined by the of set() operations.

Note that a new set_begin() can not be issued until the corresponding closing set_end() has been performed.

Also note that all following set() operations must have the same baseno NetObject id as the one provided in set_begin().

Parameters:
  • baseno (int) - the id number of the netobject to operate under.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • PLDServerError - If server reported an error

set_end(self, baseno, abort=False)

Ends a session of set() operations, started by set_begin(), under a base netobject.

When zero or more set() have been performed and set_end() is called all dynamic netobject items under the baseno NetObject that were not set by any set() operation will be removed.

Performing a series of set() operations between a pair of set_begin() and set_end() will make sure that all dynamic NetObject items under the baseno NetObject will be exactly defined by the series of dyn_set() operations.

Returns:
  • Number of removed dynamic netobject items that were not set by any set().
  • int
Parameters:
  • baseno (int) - Id number of the netobject to operate under.
  • abort (bool) - Set to True to abort the session without removing items belonging to ip addresses that did not receive a call to set() in the session.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • PLDServerError - If server reported an error

KeyVault

Operations on the key vault used for encrypted property objects.

>>> # Set key at index 3
>>> rt.keyvault.set(3, "abc123")
>>> # Add an property object with encryption
>>> obj = rs.object_add("/PropertyObject/Sensitive")
>>> o.attributes['encrypted'] = "3"
Methods:
Ungrouped int index(self, key)
Find index of key
reset(self, index)
Remove a key from the key vault
set(self, index, key)
Set a key in the key vault to the specified string

index(self, key)

Find index of key.

Returns:
  • index of specified key, or -1 if it doesn't exist
  • int
Parameters:
  • key (str) - The encryption key

reset(self, index)

Remove a key from the key vault.

Parameters:
  • index (int) - Index of the key to remove.

set(self, index, key)

Set a key in the key vault to the specified string.

Parameters:
  • index (int) - Index of the key to remove.
  • key (str) - The new encryption key.
  • key must not contain any '' character.

PLD

Class for connecting and communicating with packetlogicd, the realtime part of PacketLogic.

When using the multiversion API you will access this class via the PLConnection.Realtime() method.

All functions that communicate with the PacketLogic Realtime system might raise errors common to all or many of the functions.Here is a list of such errors, that might not be listed on each method:

Methods:
Dynamic NetObject items boolean dyn_add(self, id, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='')
Add a dynamic netobject item
list of tuple dyn_list(self)
List all dynamic netobject items
list of tuple dyn_list_full(self)
List all dynamic netobject items including subscriber names
list of tuple dyn_list_mask(self, ip, mask)
List all dynamic netobject items matching the specified ipaddress and
list of tuple dyn_list_no(self, id)
List dynamic netobject items matching the specified netobject id
boolean dyn_remove(self, id, ip)
Remove a dynamic netobject item
Firewall Log fwlog_clear(self)
Clear the firewall log
tuple of list and dict fwlog_query_offsets(self, first_nr, last_nr, clear=False, no_reverse=False)
Query the firewall log for a list of entries between two offsets
tuple of dict and list fwlog_query_rule(self, id)
Query the firewall log for a list of entries matching a specific firewall
tuple of list and dict fwlog_query_time_range(self, timefr, timeto)
Query the firewall log for a list between two points in time
Internal tuple of list dump_bgptable(self)
Dump the bgp table
inject_packet(self, iface, pkt)
Inject a packet
reload_drdl(self)
Reload drdl signatures
Realtime Data add_channels_callback(self, func)
Add a callback to call with channel statistics data while updating
add_netobj_callback(self, func, under=None, include_hosts=False)
Add a callback to call with realtime NetObject data while updating
add_service_callback(self, func)
Add a callback to call with realtime service data while updating
add_shapingcnt_callback(self, func)
Add a callback for byte counters
add_shapingobject_callback(self, func)
Add a callback to call with realtime shapingobject data while updating
add_sysdiag_callback(self, func)
Add a callback to call with system diagnostics data while updating
add_update_done_callback(self, func)
Add a callback to call after each update is done
dict get_channels_data(self, maxage=5)
Get channel statistics data once
RealtimeNetObjectTree get_netobj_data(self, under=None)
Get Realtime NetObject data once
get_services_data(self)
Get Realtime Services data once
dict get_sysdiag_data(self, maxage=5)
Get system diagnostics data once
shapingcnt_request_all(self)
Requests all shaping counters, regardless if they have changed or not
stop_updating(self)
Stop the updating and clear callback functions
update_forever(self, interval=5)
Start updating
Volume Based Shaping list of tuple vbs_list(self)
List available vbs objects
list of dict vbs_query(self, machine, objid, extra=0)
Query vbs data from a specific vbs object
vbs_reset(self, machine, soid, extra=0)
Reset vbs accounting data for a vbs object
vbs_set(self, invalue, outvalue, machine, soid, extra=0)
Set transfer to the specified value
Ungrouped add_aggr_view_callback(self, viewbuilder, callback)
Add a view reporting aggregated data
add_conn_view_callback(self, viewbuilder, func)
Add a view reporting all connections matching the filter in specified
add_fwrule_callback(self, func)
Add a callback to call with realtime filtering rule data while updating
add_host_callback(self, hostip, func)
Add a callback to be called with realtime connection information for all
break_update_forever(self)
Stop the updating, but keep callback functions
close(self)
Immediately disconnect from packetlogic system
str drdl_revision(self)
Retrieve revision string for currently loaded drdl ARM
list of tuple dyn_list_no_recurse(self, id)
List dynamic netobject items matching the specified netobject id or an
boolean dyn_set(self, baseno, ip, items)
Set multiple dynamic netobject items under a base netobject
str dyn_strerror(self)
Return last error message from dyn_add/dyn_remove/dyn_set
dynrule_clear(self, realm)
Re-enable all rules in given realm
dynrule_disable(self, realm, ruletype, rulename)
Disable a rule
dynrule_enable(self, realm, ruletype, rulename)
Enable a previously disabled rule
force_statistics_write(self)
Force Statistics write to the disk
ViewBuilder get_view_builder(self)
Get a ViewBuilder object for creating views
shapingcnt_subscriber_flush(self, subscriber)
Requests all shaping counters for a specific subscriber, regardless if they
vcrc(self, criteria)
Run virtual connection ruleset checker
boolean wait_for_ruleset(self, commitid, timeout=60)
Waits for a ruleset of 'commitid' to be loaded and compiled by plrcd
Properties:
add_stats_callback Deprecated alias for add_sysdiag_callback
current_ruleset
distversion
dyn Get a handle for dynamic netobject operations
get_stats_data Deprecated alias for get_sysdiag_data
instanceid
keyvault Get a handle for KeyVault operations
systemid

add_aggr_view_callback(self, viewbuilder, callback)

Add a view reporting aggregated data.

Data is aggregated in a tree structure according to the distribution and filter in the specified viewbuilder.

Parameters:
  • viewbuilder (ViewBuilder or str) - ViewBuilder defining the filter or string of name for existing LiveView in PLDB
  • func (callable) - function to call. The function is called with a RealtimeAggrNode as its argument. This is the root of the aggregation tree.
  • This function requires v14.1 firmware or newer.
  • Using a string as viewbuilder requires v16.0 firmware or newer.

add_channels_callback(self, func)

Add a callback to call with channel statistics data while updating.

Parameters:
  • func (callable) - function to call. The function is called with a dict with the channel ids as key and a inner dict as value.

add_conn_view_callback(self, viewbuilder, func)

Add a view reporting all connections matching the filter in specified viewbuilder.

Parameters:
  • viewbuilder (ViewBuilder or str) - ViewBuilder defining the filter or string of name for existing LiveView in PLDB
  • func (callable) - function to call. The function is called with a list of RealtimeConn as its argument.
  • This function requires v14.1 firmware or newer.
  • Using a string as viewbuilder requires v16.0 firmware or newer.

add_fwrule_callback(self, func)

Add a callback to call with realtime filtering rule data while updating.

Parameters:
  • func (callable) - function to call. The function is called with one argument, a dict with filtering rule data. Key is filtering rule id, value is a dict of its properties.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v15.0 firmware or newer.

add_host_callback(self, hostip, func)

Add a callback to be called with realtime connection information for all connections on specified host

Parameters:
  • hostip (str) - IP address of host to retrieve realtime connection information for. Should be an IP address as a string.
  • func (callable) - function to call. The function is called with two arguments, the ipaddress and a list of connections RealtimeConn on that host. The list is None (not to be confused with the empty list) when the host is removed and no more updates will happen.
  • This function requires v13.0 firmware or newer.

add_netobj_callback(self, func, under=None, include_hosts=False)

Add a callback to call with realtime NetObject data while updating.

>>> PATH="/NetObjects/Everyone"
>>> def cb(objs):
...     print "#%d subscribers active under %s" % (len(objs), PATH)
...     # print top10
...     objs.sort(key=lambda no: no.speed[0] + no.speed[1])
...     print "%-40s %9s %9s" % ("# Name", "inkbps", "outkbps")
...     for no in objs[:10]:
...         # convert to kbps
...         inspd = no.speed[0]*8.0/1000
...         outspd = no.speed[1]*8.0/1000
...         print "%-40s %8.2f %8.2f" % (no.name, inspd, outspd)
... 
>>> rt.add_netobj_callback(cb, under=PATH)
>>> rt.update_forever()
Parameters:
  • func (callable) - function to call. The function is called with one argument, an RealtimeNetObjectTree containing the list of RealtimeNetObjects data, which is fetched with that objects methods.
  • under (str) - Request netobject data under a specified path. In v12.0 and newer only toplevel objects are included by default, and this in required to get data for a specific path. Observe that only the objects directly under the specified path is reported, no recursive listing. When 'under' is used the callback is called with a list of RealtimeNetObjects directly, no RealtimeNetObjectTree intermediate layer.
  • include_hosts (bool) - Request information about hosts under the netobject specified with the under parameter. The argument passed to func will have an attribute named "hosts" which is an iterable of RealtimeHost objects.
Exceptions raised:
  • PLDUnsupportedInFirmware - If under argument is used and firmware doesn't support it.
  • under parameter requires v12.1 firmware or newer.
  • When 'under' is used the callback is called with a list of <a href="#module-packetlogic2.pld.pld-RealtimeNetObject">RealtimeNetObject</a>s directly, no <a href="#module-packetlogic2.pld.pld-RealtimeNetObjectTree">RealtimeNetObjectTree</a> intermediate layer.
  • include_hosts parameter requires v12.2 firmware or newer.

add_service_callback(self, func)

Add a callback to call with realtime service data while updating.

Parameters:
  • func (callable) - function to call. The function is called with one argument, a dict of services. Key is servicename, value is a dict of its properties.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.1 firmware or newer.

add_shapingcnt_callback(self, func)

Add a callback for byte counters.

The signature of the callback should be:

cb(idx, oid, sk, flags, _in, _out)

idx is counter index in PL (i.e a number between 0 and MAX_COUNTERS) oidx is shaping object id sk is split key (i.e netobject id on split-by-netobject, ip on split-by-localhost, subscriber name on split-by-subscriber, and 0 on no split) flags is flags bitmask, if (1<<13) is set it means that this is the last update for this counter, and it will be reset to 0. _in and _out are bytecounters.

Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.2 firmware or newer.

add_shapingobject_callback(self, func)

Add a callback to call with realtime shapingobject data while updating.

Parameters:
  • func (callable) - function to call. The function is called with one argument, a dict with shapingobject data. Key is shaping object index, value is a dict of its properties.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.2 firmware or newer.

add_sysdiag_callback(self, func)

Add a callback to call with system diagnostics data while updating.

Parameters:
  • func (callable) - function to call. The function is called with a huge dict containing all system diagnostics data.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This method only works in v13.0 and earlier. In 13.1 and newer use the SysDiag resource instead.

add_update_done_callback(self, func)

Add a callback to call after each update is done.

Parameters:
  • func (callable) - function to call. The function is called without any arguments

break_update_forever(self)

Stop the updating, but keep callback functions.

Like stop_updating but allows resuming updating by calling update_forever again.

close(self)

Immediately disconnect from packetlogic system.

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.

drdl_revision(self)

Retrieve revision string for currently loaded drdl ARM.

Returns:
  • Revision string.
  • str
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.1 firmware or newer.

dump_bgptable(self)

Dump the bgp table.

This function is just for debugging purposes. It will return the BGP table in packetlogicd.

Returns:
  • tuple with all prefix and paths.
  • tuple of list
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedFeatureError - If the 'bgp' feature isn't enabled.
  • This API is for debugging purpose only and might change without notice.
  • The API for this function changed with 14.1 to return both IPv4 and IPv6 prefixes as strings. The return tuple for prefixes contains (depth, prefixstr, path_id, lchildren, rchildren).

dyn_add(self, id, ip, subscriber='', is_subscriber=False, linkspeed_in=0, linkspeed_out=0, natcfg='')

Add a dynamic netobject item

Please note that netobject will not be verified with regard to performance and flexibility when adding to a uncommitted netobject.

>>> rt.dyn_add(31682, '127.0.0.1')
True
Returns:
  • True if add was successful
  • boolean
Parameters:
  • id (int) - the id number of the netobject to add the item to.
  • ip (str) - the IP address to add.
  • subscriber (str) - Subscriber name - or empty string to not create subscriber. Requires v12.0 firmware or newer.
  • is_subscriber (bool) - is subscriber property - used for subscriber count in statistics. Requires v12.4 firmware or newer.
  • linkspeed_in (int) - linkspeed_in property - used in statistics. Requires v12.4 firmware or newer.
  • linkspeed_out (int) - linkspeed_out property - used in statistics. Requires v12.4 firmware or newer.
  • natcfg (str) - natcfg property - used to config subscribers NAT. Requires v14.0 firmware or newer.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If subscriber argument is used and firmware doesn't support it.
  • ValueError - If an invalid IP address is used
  • subscriber parameter requires v12.0 firmware or newer.
  • is_subscriber parameter requires v12.4 firmware or newer.
  • linkspeed_in parameter requires v12.4 firmware or newer.
  • linkspeed_out parameter requires v12.4 firmware or newer.
  • natcfg parameter requires v14.0 firmware or newer.

dyn_list(self)

List all dynamic netobject items

>>> rt.dyn_list()
[(31589, '127.0.0.1'),
 (31576, '192.168.1.1'),
 (31589, '192.168.0.131'),
 (31688, '192.168.0.131'),
 (31577, '192.168.1.1'),
 (31682, '127.0.0.1')]
Returns:
  • a list of tuples containing the netobject id and the item.
  • list of tuple
Exceptions raised:
  • PLDNotAvailable - If data is not ready yet, and you should retry this call later. (This is not an error.)
  • PLDPermissionError - If the user lacks permission for requested action

dyn_list_full(self)

List all dynamic netobject items including subscriber names

>>> rt.dyn_list()
[(31589, '127.0.0.1', 'User 1'),
 (31576, '192.168.1.1', 'User 123'),
 (31589, '192.168.0.131', 'User 124'),
 (31688, '192.168.0.131', 'User 124'),
 (31577, '192.168.1.1', 'User 123'),
 (31682, '127.0.0.1', 'User 1')]
Returns:
  • a list of tuples containing the netobject id, the item and subscriber name.
  • list of tuple
Exceptions raised:
  • PLDNotAvailable - If data is not ready yet, and you should retry this call later. (This is not an error.)
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.0 firmware or newer.

dyn_list_mask(self, ip, mask)

List all dynamic netobject items matching the specified ipaddress and netmask

This command is NOT supported on system with PacketLogic version v11.359 or earlier. Using it will raise a timeout exception after about a minute.

>>> rt.dyn_list_mask('192.168.0.0', '255.255.252.0')
[(31576, '192.168.1.1'),
 (31589, '192.168.0.131'),
 (31688, '192.168.0.131'),
 (31577, '192.168.1.1'),
 (31682, '192.168.2.33'),
 (31697, '192.168.3.142')]
Returns:
  • a list of tuples containing the netobject id and the item.
  • list of tuple
Parameters:
  • ip (str) - the ip number to use for matching.
  • mask (str) - the netmask to use for matching.
Exceptions raised:
  • PLDNotAvailable - If data is not ready yet, and you should retry this call later. (This is not an error.)
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDServerError - If either argument is of incorrect format.

dyn_list_no(self, id)

List dynamic netobject items matching the specified netobject id

This command is NOT supported on system with PacketLogic version v11.359 or earlier. Using it will raise a timeout exception after about a minute.

>>> rt.dyn_list_no(31576)
[(31576, '192.168.1.1'),
 (31576, '192.168.0.131'),
 (31576, '192.168.2.13')]
Returns:
  • a list of tuples containing the netobject id and the item.
  • list of tuple
Parameters:
  • id (int) - the id number of the netobject to match against.
Exceptions raised:
  • PLDNotAvailable - If data is not ready yet, and you should retry this call later. (This is not an error.)
  • PLDPermissionError - If the user lacks permission for requested action

dyn_list_no_recurse(self, id)

List dynamic netobject items matching the specified netobject id or an netobject under it.

>>> rt.dyn_list_no_recurse(31576)
[(31576, '192.168.1.1'),
 (31577, '192.168.0.131'),
 (31576, '192.168.2.13')]
Returns:
  • a list of tuples containing the netobject id and the item.
  • list of tuple
Parameters:
  • id (int) - the id number of the parent netobject to match against.
Exceptions raised:
  • PLDNotAvailable - If data is not ready yet, and you should retry this call later. (This is not an error.)
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v13.1 firmware or newer.

dyn_remove(self, id, ip)

Remove a dynamic netobject item

>>> rt.dyn_remove(31682, '127.0.0.1')
True
Returns:
  • True if remove was successful
  • boolean
Parameters:
  • id (int) - the id number of the netobject to remove the item from.
  • ip (str) - the ip number to remove.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action

dyn_set(self, baseno, ip, items)

Set multiple dynamic netobject items under a base netobject.

This function replaces all dynamic netobject items that exists for the specified ip address in the netobject tree under the specified base netobject id.

Returns:
  • True if call was successful
  • boolean
Parameters:
  • baseno (int) - the id number of the netobject to operate under.
  • ip (str) - the ip number to set items for.
  • items (sequence of tuples) - the items to add, each item should be a tuple of (netobjectid, subscribername) or (netobject, subscribername, properties). Where properties is a dict which may contain the keys is_subscriber, linkspeed_in and linkspeed_out
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.4 firmware or newer.

dyn_strerror(self)

Return last error message from dyn_add/dyn_remove/dyn_set

>>> rt.dyn_add(19, '10.0.0.1')
True
>>> rt.dyn_add(19, '10.0.0.1')
False
>>> rt.dyn_strerror()
'Item already exists'
Returns:
  • Last error message
  • str
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.4 firmware or newer.

dynrule_clear(self, realm)

Re-enable all rules in given realm.

Parameters:
  • realm (str) - Realm in which this disabling was done.

dynrule_disable(self, realm, ruletype, rulename)

Disable a rule.

Parameters:
  • realm (str) - Realm in which this disabling is done.
  • ruletype (str) - "filtering", "shaping" or "statistics"
  • rulename (str) - Name of rule to disable

dynrule_enable(self, realm, ruletype, rulename)

Enable a previously disabled rule.

Parameters:
  • realm (str) - Realm in which this disabling was done.
  • ruletype (str) - "filtering", "shaping" or "statistics"
  • rulename (str) - Name of rule to enable

force_statistics_write(self)

Force Statistics write to the disk.

Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.1 firmware or newer.

fwlog_clear(self)

Clear the firewall log.

Returns:
  • Nothing
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action

fwlog_query_offsets(self, first_nr, last_nr, clear=False, no_reverse=False)

Query the firewall log for a list of entries between two offsets

>>> info, results = rt.fwlog_query_offsets (0, 50)
>>> print info
{'logentries': 14054L}
>>> print len(results)
50
>>> for i in results[0:3]:
....:     print i
....:
{'clientport': 39682, 'protocol': 6, 'service': 'Lunarstorm live', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '1.2.3.4', 'client': '5.6.7.8', 'serverport': 8080, 'time': 1138204688, 'type': 0, 'properties': ''}
{'clientport': 55172, 'protocol': 6, 'service': 'HTTP', 'clienthostname': '', 'serverhostname': 'www.google.com', 'rule': 'Log HTTP', 'server': '209.85.129.104', 'client': '192.168.9.174', 'serverport': 80, 'time': 1250775399L, 'type': 0, 'properties': 'File length=0\nServer Hostname=www.google.com\nURL=http://www.google.com/search?q=packetlogic&ie=utf-8&oe=utf-8&aq=t\nRequest method=GET\nDirection=Inbound\nFilename=/search?q=packetlogic&ie=utf-8&oe=utf-8&aq=t\nUser-Agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.12) Gecko/2009072221\nTransfer-Encoding=None\nUpload file length=0\n'}
{'clientport': 3252, 'protocol': 6, 'service': 'eDonkey transfer', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '10.10.11.11', 'client': '40.50.60.70', 'serverport': 7804, 'time': 1138204688, 'type': 0, 'properties': ''}

Grab all entries in the firewall log and clear once we get the last batch

>>> l = []
>>> numentries = rt.fwlog_query_offsets(0,0)[0]['logentries']
>>> for x in range(0, numentries, 500):
....:   l += rt.fwlog_query_offsets(x, min(x+500, numentries), no_reverse=True)[1]
....:
>>> l += rt.fwlog_query_offsets(numentries, -1, clear=True, no_reverse=True)[1] # grab entries logged while quering
Returns:
  • 2-tuple with firewall log information and matching entries. last_nr - first_nr entries will be returned.
  • tuple of list and dict
Parameters:
  • first_nr (str) - Start the list at this offset. 0 means the start of the firewall log.
  • last_nr (str) - End the list at this offset.
  • clear (bool) - If True, log is cleared after values are retrieved. This clears the whole log and not the selected portion. Not supported in v12.0 firmwares.
  • no_reverse (bool) - If True, the offsets are handled from oldest entry, not newest entry. i.e fwlog_query_offsets(0,10,no_reverse=True) will list 10 oldest entries, not 10 newest. Not supported in v12.0 firmwares.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If clear or no_reverse parameter is used on v12.0 firmware.
  • clear parameter is not supported on v12.0 firmwares.
  • no_reverse parameter is not supported on v12.0 firmwares.

fwlog_query_rule(self, id)

Query the firewall log for a list of entries matching a specific firewall rule

>>> info, results = rt.fwlog_query_rule(58)
>>> print info
{'logentries': 14054L}
>>> print results
[{'client': '10.0.0.2',
  'clienthostname': '',
  'clientport': 2985,
  'properties': '',
  'protocol': 6,
  'rule': 'Monitor ',
  'server': '10.0.1.3',
  'serverhostname': '',
  'serverport': 1512,
  'service': 'Skype',
  'time': 1138204680,
  'type': 0},
 {'client': '1.2.3.4',
  'clienthostname': '',
  'clientport': 3247,
  'properties': '',
  'protocol': 6,
  'rule': 'Monitor ',
  'server': '10.3.2.1',
  'serverhostname': '',
  'serverport': 17561,
  'service': 'Undetermined',
  'time': 1138204680,
  'type': 0},
 {'client': '3.2.1.2',
  'clienthostname': '',
  'clientport': 52263,
  'properties': 'Serverinfo= AAMAILE.int.aalogistik.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at  Wed, 25 Jan 2006 16:57:54 +0100 \n',
  'protocol': 6,
  'rule': 'Monitor ',
  'server': '1.2.4.3',
  'serverhostname': '',
  'serverport': 25,
  'service': 'Undetermined',
  'time': 1138204680,
  'type': 0}]
Returns:
  • 2-tuple with firewall log information and matching entries.
  • tuple of dict and list
Parameters:
  • id (int) - Rule id
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action

fwlog_query_time_range(self, timefr, timeto)

Query the firewall log for a list between two points in time

>>> info,results = rt.fwlog_query_time_range ("2006-01-01 00:00", "2006-02-02 00:00")
>>> print results[0]
{'clientport': 38742, 'protocol': 6, 'service': 'eDonkey transfer', 'clienthostname': '', 'serverhostname': '', 'rule': 'Monitor ', 'server': '3.3.3.3', 'client': '1.1.1.1', 'serverport': 4662, 'time': 1138204658, 'type': 0, 'properties': ''}
Returns:
  • 2-tuple with firewall log information and matching entries.
  • tuple of list and dict
Parameters:
  • timefr (str) - Start the list at this date, the date has to be in YYYY-MM-DD HH:MM format
  • timeto (str) - End the list at this date, the date has to be in YYYY-MM-DD HH:MM format
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action

get_channels_data(self, maxage=5)

Get channel statistics data once.

(Should not be used simultaneously to add_channels_callback and update_forever)

Returns:
  • Dict containing all channels. Channel id is used as key and the value is another dict containing values.
  • dict
Parameters:
  • maxage (int) - Max age in seconds of cached information. If longer time has passed since last call, new data will be requested from PacketLogic.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission.

get_netobj_data(self, under=None)

Get Realtime NetObject data once.

(Should not be used simultaneously to add_netobj_callback and update_forever)

Returns:
  • An object that is iterable to fetch all NetObjects, otherwise it has methods to fetch specific data.
  • RealtimeNetObjectTree
Parameters:
  • under (str) - Path to netobject
Exceptions raised:
  • PLDPermissionError - If the user lacks permission.

get_services_data(self)

Get Realtime Services data once.

(Should not be used simultaneously to add_service_callback and update_forever)

Exceptions raised:
  • PLDPermissionError - If the user lacks permission.
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.1 firmware or newer.

get_sysdiag_data(self, maxage=5)

Get system diagnostics data once.

(Should not be used simultaneously to add_stats_callback and update_forever)

Returns:
  • Dict containing all system diagnostics data in the form of nested dicts, the toplevel dict contains the different system diagnostics zones.
  • dict
Parameters:
  • maxage (int) - Max age in seconds of cached information. If longer time has passed since last call, new data will be requested from PacketLogic.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission.
  • For firmware version 13.1 and newer this is a compatibility wrapper around pl.SysDiag(). If support for earlier firmwares is not needed using pl.SysDiag() directly is preferred.

get_view_builder(self)

Get a ViewBuilder object for creating views.

See ViewBuilder object documentation for details.

Returns:
  • This function requires v14.1 firmware or newer.

inject_packet(self, iface, pkt)

Inject a packet.

This function is just for testing purposes.

Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • ValueError - If the size of a packet exceeds 4096 bytes.

reload_drdl(self)

Reload drdl signatures. For internal use only.

Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v12.1 firmware or newer.

shapingcnt_request_all(self)

Requests all shaping counters, regardless if they have changed or not.

  • This function requires v12.2 firmware or newer.

shapingcnt_subscriber_flush(self, subscriber)

Requests all shaping counters for a specific subscriber, regardless if they have changed or not.

  • This function requires v15.Z firmware or newer.

stop_updating(self)

Stop the updating and clear callback functions.

update_forever(self, interval=5)

Start updating.

This method will enter a loop that requests updates every 5 seconds (or other interval specified by the interval argument). Updates are sent to the callback functions registered with methods named add_*_callback (among others add_service_callback, add_channels_callback and add_update_done_callback). To break out of the updating loop call the stop_updating method.

Parameters:
  • interval (float) - Interval (seconds) at which updates are requested.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for at least one of the registered callbacks

vbs_list(self)

List available vbs objects

>>> rt.vbs_list()
[('00E081600B81', 24, 'VBS low', 1),
 ('00E081600B81', 74, 'VBS medium', 1),
 ('00E081600B81', 26, 'VBS max', 1)]
Returns:
  • A list of available VBS objects in a tuple (machineid, id of vbs object, name, split type)

    split type is one of SPLIT_NONE, SPLIT_LOCALHOST, SPLIT_HOST_NETOBJECT, SPLIT_SERVER_NETOBJECT, SPLIT_CLIENT_NETOBJECT, SPLIT_CONNECTION

  • list of tuple
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function isn't supported in v12.0 and v12.1 firmwares.

vbs_query(self, machine, objid, extra=0)

Query vbs data from a specific vbs object

>>> rt.vbs_query('0010F3067C3A', 24)
[{'bidirectional': 0L,
  'bidirectional speed': 0,
  'extra': -183572567,
  'id': 24,
  'inbound': 0L,
  'inbound speed': 0,
  'machineid': '0010F3067C3A',
  'name': 'VBS Grund',
  'outbound': 0L,
  'outbound speed': 0,
  'splitname': '169.231.14.245'}]
Returns:
  • A list of dictionaries, where each dictionary holds VBS data with the following contents:
    • 'machineid', 'id', 'name' identify the shaping object.
    • 'inbound/outbound/bidirectional' accumulated volume of transferred data
    • 'inbound/outbound/bidirectional speed' holds the current speed
    • 'splitname' text representation of the split instance of the shaping object (for example for split by local host, the local host IP address as a string).
    • 'extra' numerical representation of the split instance of the shaping object (for example for split by local host; an integer representation of the IP address, for split by netobject; the id number of the netobject). This is the number that would be passed as 'extra' argument to vbs_reset or vbs_query.
  • list of dict
Parameters:
  • machine (str) - MachineID of the PacketLogic you want to query.
  • objid (int) - ID of VBS shapingobject
  • extra (int) - Extra key; netobject id in case of split by netobject, or ip number in case of split by local host (encoded as an integer). If argument isn't given ALL available split keys are listed.
Exceptions raised:
  • PLDPermissionError - If the user lacks permission for requested action
  • This function isn't supported in v12.0 and v12.1 firmwares.
  • In v12.2 firmware or newer the <code>machineid</code> argument is ignored.
  • In v12.2 firmware or newer bidirectional VBS isn't supported, therefore the 'bidirectional' value returned is always 0.

vbs_reset(self, machine, soid, extra=0)

Reset vbs accounting data for a vbs object.

Parameters:
  • machine (str) - MachineID of the PacketLogic you want to query.
  • soid (int) - ID of VBS object
  • extra (int) - Extra key; netobject id in case of split by netobject, or ip number in case of split by local host (encoded as an integer). See the return value of vbs_query for details.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function isn't supported in v12.0 and v12.1 firmwares.

vbs_set(self, invalue, outvalue, machine, soid, extra=0)

Set transfer to the specified value. Can only be used on object without sliding window (duration=1).

Parameters:
  • invalue (int) - The new value of inbound transfer (in KiB)
  • outvalue (int) - The new value of outbound transfer (in KiB)
  • machine (str) - MachineID of the PacketLogic you want to query.
  • soid (int) - ID of VBS object
  • extra (int) - Extra key; netobject id in case of split by netobject, or ip number in case of split by local host (encoded as an integer). See the return value of vbs_query for details.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function does not exist in v12.0 firmware or newer.

vcrc(self, criteria)

Run virtual connection ruleset checker.

>>> rt.vcrc({'serverip':'192.168.9.1'})
>>> rt.vcrc({'serverip': '192.168.9.1',
            'service': 'HTTP',
            'vlan': 1234})
>>> rt.vcrc({'serverip':'217.73.103.54'})
{'fwrules': [(60L, 2031L), (63L, 2031L)], 'shapingrules': [(65L, 2031L),
(66L, 1903L)], 'monitor_iface': 0L, 'fwrule': 63, 'ruleset_state': 3,
'test_id': 1L, 'rewrite_obj': 0L}
Returns:
  • dict with information, including lists for shaping and firewall rules with a tuple per matching rule. The first element in each tuple is the rule id, and the second element is a bitmask which describes what criteria for that rule are mutable. Mutable in this context means that there exist values for that criteria which will make the rule not match. The bitmask has the following bits defined: vlan = 0 mpls = 1 protocol = 2 client ip = 3 server ip = 4 client port = 5 server port = 6 service = 7 bgp = 8 xfb = 9 properties = 10 The ruleset_state returned in the dict signifies the final firewall state for the connection. It is one of the following: UNKNOWN = 0 ACCEPT = 1 REJECT = 2 DROP = 3 REWRITE = 4 DIVERT = 5
Parameters:
  • criteria (dict) - Dict with any of the following keys:

    * vlan * mpls * protocol * clientip * serverip * clientport * serverport * service * xfb * properties

wait_for_ruleset(self, commitid, timeout=60)

Waits for a ruleset of 'commitid' to be loaded and compiled by plrcd. wait_for_ruleset() will return when plrcd sees a commitid that is at least as new as 'commitid' given. If plrcd already has loaded or loads a newer commitid than the given 'commitid' it will also return with True.

Typical use:

>>> # Add Test netobject to pldb
>>> test = rs.object_add("/NetObjects/Test")
>>> commitid = rs.commit()
>>> # Wait for Test netobject to be visible in plrcd
>>> rt.wait_for_ruleset(commitid)
>>> # Add a dynnetobj item in plrcd under Test netobject
>>> rt.dyn.add(test.id, "10.0.0.1")
Returns:
  • True if commitid has been seen. False if timeout occured.
  • boolean
Parameters:
  • commitid (CommitID) - CommitID to wait for.
  • timeout (int) - Max seconds to wait before returning with False.
Exceptions raised:
  • PLDUnsupportedInFirmware - If firmware doesn't support this function.
  • This function requires v14.0 firmware or newer.

add_stats_callback

Deprecated alias for add_sysdiag_callback

current_ruleset

Undocumented!

distversion

Undocumented!

dyn

Get a handle for dynamic netobject operations. See Dyn object for details.

get_stats_data

Deprecated alias for get_sysdiag_data

instanceid

Undocumented!

keyvault

Get a handle for KeyVault operations. See KeyVault object for details.

systemid

Undocumented!

RealtimeAggrNode

This object should not be instantiated manually. Instances will be passed as argument to the function registered with PLD.add_aggr_view_callback.

Properties:
children List of child nodes (if any)
connections Number of connections
cps inbound/outbound cps
external_quality inbound/outbound external quality
internal_quality inbound/outbound internal quality
name The name of this node
rawname The name of this node in its original type without any prefix
rtt inbound/outbound handshake rtt
speed inbound/outbound bps

children

List of child nodes (if any).

connections

Number of connections

cps

inbound/outbound cps

external_quality

inbound/outbound external quality

internal_quality

inbound/outbound internal quality

name

The name of this node

rawname

The name of this node in its original type without any prefix

rtt

inbound/outbound handshake rtt

speed

inbound/outbound bps

RealtimeConn

Object containing realtime information of a connection. This object should not be instantiated manually. Use the add_host_callback method.

>>> def cb(ip, connections):
...    print "=" * 30
...    print time.ctime()
...    print ip
...    if connections is None:
...        print " * Host removed"
...        rt.stop_updating()
...    else:
...        for c in connections:
...            if c.service != "HTTP":
...                continue
...            f = " * "
...            f += "%s:%d" % c.client
...            f += "->%s:%d" % c.server
...            if c.server_hostname:
...                f += "[%r]" % c.server_hostname
...            f += " in=%dbps out=%dbps" % c.speed
...            f += " prio=%d" % c.shaping_prio
...            print f
>>> rt.add_host_callback(host, cb)
>>> rt.update_forever(5.0)
Properties:
base_service Base Service of the connection as a string
client Client endpoint of the connection as a tuple (clientip, clientport)
dscp DSCP value of the connection in inbound and outbound directions
engineflags Engineflags on the connection
external_quality External QoE values (inbound, outbound)
internal_quality Internal QoE values (inbound, outbound)
ls_device_id The id of estimated line sharing device
ls_device_type The type of line sharing device estimation
mpls MPLS label of the connection in inbound and outbound directions
outbound_hoplimit The hoplimit/ttl value from outbound packets in this connection
protocol IP protocol used by connection
server Server endpoint of the connection as a tuple (serverip, serverport)
server_hostname Server hostname if extracted by signatures
service Service of the connection as a string
session_contexts
shaping_prio Priority value of the connection as assigned by shaping rules
shaping_rules Shaping rules matching the connection as a list of rule names
speed Average speed of the connection during the last update interval as a tuple
starttime Unix timestamp when first packet in connection was seen (according to the
vlan VLAN IDs of the connection in inbound and outbound direction
vlan_priority VLAN priorities of the connection in inbound and outbound direction
xfbflags XFBflags on the connection
xfer Bytes transferred during the lifetime of the connection as a tuple (inbound

base_service

Base Service of the connection as a string

client

Client endpoint of the connection as a tuple (clientip, clientport)

dscp

DSCP value of the connection in inbound and outbound directions

engineflags

Engineflags on the connection

external_quality

External QoE values (inbound, outbound).

External Quality of Experience values in range 0-100 (percent) for this connection. Value is -1 if not available.

internal_quality

Internal QoE values (inbound, outbound).

Internal Quality of Experience values in range 0-100 (percent) for this connection. Value is -1 if not available.

ls_device_id

The id of estimated line sharing device

ls_device_type

The type of line sharing device estimation

mpls

MPLS label of the connection in inbound and outbound directions

outbound_hoplimit

The hoplimit/ttl value from outbound packets in this connection

protocol

IP protocol used by connection

server

Server endpoint of the connection as a tuple (serverip, serverport)

server_hostname

Server hostname if extracted by signatures

service

Service of the connection as a string

session_contexts

Undocumented!

shaping_prio

Priority value of the connection as assigned by shaping rules

shaping_rules

Shaping rules matching the connection as a list of rule names

speed

Average speed of the connection during the last update interval as a tuple (inbound bps, outbound bps)

starttime

Unix timestamp when first packet in connection was seen (according to the clock on the PacketLogic system)

vlan

VLAN IDs of the connection in inbound and outbound direction

vlan_priority

VLAN priorities of the connection in inbound and outbound direction

xfbflags

XFBflags on the connection

xfer

Bytes transferred during the lifetime of the connection as a tuple (inbound bytes, outbound bytes)

RealtimeHost

Object containing realtime information of a host. This object should not be instantiated manually. Use the add_netobj_callback method.

>>> def cb(data):
...     print "Number of hosts: %d" % len(data.hosts)
...     interesting_hosts = ["10.2.200.188", "10.2.20.58"]
...     for h in data.hosts:
...         if h in interesting_hosts:
...             print " %s: %s" % (h.addr, h.speed)
...
>>> rt.add_netobj_callback(cb, under="/NetObjects/<Ungrouped>", include_hosts=True)
>>> rt.update_forever()
Properties:
external_quality External QoE values (inbound, outbound)
internal_quality Internal QoE values (inbound, outbound)
Instance variables:
addr IP address of host
speed Speed in byte/s in/out.
connections Connections all/unestablished.
cps Connections per second in/out.

external_quality

External QoE values (inbound, outbound).

External Quality of Experience values in range 0-100 (percent) for this host. Value is -1 if not available.

internal_quality

Internal QoE values (inbound, outbound).

Internal Quality of Experience values in range 0-100 (percent) for this host. Value is -1 if not available.

RealtimeNetObject

Object containing Realtime NetObject data.

Properties:
fullpath Full path of this object including the object's name
path Path which this object resides under
Instance variables:
id The internal id.
parent References the parent NetObject, if any.
name Name of NetObject.
speed Speed in bps in/out.
forwarded Forwarded bytes in/out. Obsolete in v12.0 and newer, will always be 0 in these versions.
connections Connections in/out.
cps Connections per second in/out.

fullpath

Full path of this object including the object's name.

path

Path which this object resides under.

RealtimeNetObjectTree

NetObject data accessed through the NetObject callback function

>>> import packetlogic2
>>> pl = packetlogic2.connect('192.168.1.25', 'admin', 'password')
>>> rt = pl.Realtime()
>>> count = 1
>>> def f(data):
...     global count
...     
...     if count > 100:
...             rt.stop_updating()
...     if data:
...             for m in data.list('/NetObjects/DSL'):
...                     print "name: %s" % m.fullpath
...                     print "speed: ", m.speed
...                     print "connections: ", m.connections
...             m = data.find('/NetObjects/DSL/Lab')
...             if m is not None:
...                     print "name: %s" % m.fullpath
...                     print "speed: ", m.speed
...                     print "connections: ", m.connections
...     count +=1
...
>>> rt.add_netobj_callback(f)
>>> rt.update_forever()
Methods:
Ungrouped RealtimeNetObject find(self, path)
Find a single Realtime NetObject with the given full path
list of RealtimeNetObjects list(self, path='/NetObjects', recursive=True)
Return a list of Realtime NetObject data, matching the given path, and

find(self, path)

Find a single Realtime NetObject with the given full path.

Returns:

list(self, path='/NetObjects', recursive=True)

Return a list of Realtime NetObject data, matching the given path, and optional recursive flag.

Returns:
Parameters:
  • path (str) - Path where to start looking. If the path ends with a slash (in recursive mode), it will include the children of that NetObject (if any) but not the NetObject itself. The path should begin with '/NetObjects'.
  • recursive (bool) - If True any level of children NetObjects will also be returned. Otherwise only the NetObjects that is direct children to the given full path is returned. (Do not end path with / if recursive is True).

ViewBuilder

Builder for creating views with filters and distributions.

This object should not be instantiated manually. Use the PLD.get_view_builder to create a new object.

Methods:
Ungrouped distribution(self, field, arg=None)
Add a distribution to the view
dump_meta(self)
Print a human readable representation of available filters and fields to
filter(self, key, *values)
Add a filter to the view
filter_out(self, key, *values)
Add a filter to exclude traffic from the view
Properties:
available_fields List of fields available for use in distributions
available_filters List of available filter keys

distribution(self, field, arg=None)

Add a distribution to the view.

Adds the specified field as a sub-distribution of current distribution.

>>> v = rt.get_view_builder()
>>> v.filter_out("Service", "QUIC")
>>> v.distribution("Server Hostname")
>>> v.distribution("NetObject Level", "DHCP/By MAC")
>>> v.distribution("Local Host")
Parameters:
  • field (str) - The field to distribute based on.
  • arg (str) - Argument as required by some fields

dump_meta(self)

Print a human readable representation of available filters and fields to stdout.

filter(self, key, *values)

Add a filter to the view.

Makes filter only include connections where the property specified by key is one of the specified values. The key can be either string or a tuple containing additional arguments to the filter.

>>> v = rt.get_view_builder()
>>> v.filter(("Incoming VLAN Id", "1"), 100)
>>> v.filter(("Session Context", "myschema/mycolumn"), xyz,)
>>> v.filter("Host", "10.0.0.1")
>>> v.filter("Server Port", 443)
Parameters:
  • key (str or tuple) - The key to filter on plus additional arguments if required by the filter.

filter_out(self, key, *values)

Add a filter to exclude traffic from the view.

Makes filter exclude connections where the property specified by key is one of the specified values. The key can be either string or a tuple containing additional arguments to the filter.

>>> v = rt.get_view_builder()
>>> v.filter("Host", "10.0.0.1")
>>> v.filter("Server Port", 443)
>>> v.filter_out("Service", "SSL v3")
Parameters:
  • key (str or tuple) - The key to filter on plus additional arguments if required by the filter.

available_fields

List of fields available for use in distributions.

available_filters

List of available filter keys.