### Initialize and Get PyChart Options Source: https://python.applogicnetworks.com/python2/current/stats_per_netobject.html Initializes the pychart theme and retrieves its options. This is a setup step before creating charts. ```python theme.get_options() ``` -------------------------------- ### GET /list Source: https://python.applogicnetworks.com/python2/current/fileserv.html Lists all files of a specified type. ```APIDOC ## GET /list ### Description List all files of specified type. ### Method GET ### Parameters #### Query Parameters - **ftype** (int or str) - Required - Type of file. ### Response #### Success Response (200) - **files** (list of dict) - List of files, each represented as a dict with the key 'r_path'. ``` -------------------------------- ### GET /config/list Source: https://python.applogicnetworks.com/python2/current/config.html Retrieves a list of all configuration values. ```APIDOC ## GET /config/list ### Description List all configuration values. The values are represented as strings, but the actual type can be determined using the 'type' field in conjunction with Config.TYPE_* constants. ### Method GET ### Endpoint /config/list ### Response #### Success Response (200) - **list** (list of dict) - A list of configuration objects containing key, description, type, value, and visibility status. ``` -------------------------------- ### GET /types Source: https://python.applogicnetworks.com/python2/current/fileserv.html Lists all available file types (directories) on the system. ```APIDOC ## GET /types ### Description List file types (directories) available on the system. ### Method GET ### Response #### Success Response (200) - **types** (list of dict) - List of file types, each with keys 'name', 'id', and 'flags'. ``` -------------------------------- ### Manage Shaping Rule Flags Source: https://python.applogicnetworks.com/python2/current/plrule.html Examples for setting, resetting, and cloning flags on a shaping rule. ```python >>> shrule.set_flags(exclusive=1, stats=False) >>> shrule.flags ShapingRuleFlags(exclusive=True) ``` ```python >>> shrule.flags.exclusive True ``` ```python >>> shrule.set_flags(None) >>> shrule.flags ShapingRuleFlags(None) ``` ```python >>> shrule.set_flags(another_shrule) >>> shrule.flags ShapingRuleFlags(stats=True) ``` ```python >>> shrule.set_flags(None, exclusive=True) >>> shrule.flags ShapingRuleFlags(exclusive=True) ``` -------------------------------- ### Perform KeyVault Operations Source: https://python.applogicnetworks.com/python2/current/realtime.html Example usage of setting a key in the vault and configuring a property object for encryption. ```python >>> # 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" ``` -------------------------------- ### GET /Users/list Source: https://python.applogicnetworks.com/python2/current/users.html Lists all users currently configured on the system. ```APIDOC ## GET /Users/list ### Description Lists all users on the system. ### Method GET ### Response #### Success Response (200) - **users** (list of User) - A list of User objects representing all users on the system. ``` -------------------------------- ### Start Graph Generation Source: https://python.applogicnetworks.com/python2/current/stats_per_netobject.html Initiates the graph generation process by calling the do_graph function with the root network object path. ```python do_graph("/NetObjects/") ``` -------------------------------- ### Get bit_length of an Integer Source: https://python.applogicnetworks.com/python2/current/statistics.html Calculates the number of bits required to represent an integer in binary format. Example shows usage with the integer 37. ```python >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` -------------------------------- ### Manage PortObject Items Source: https://python.applogicnetworks.com/python2/current/portobject.html Demonstrates creating a PortObject, adding individual ports and port ranges, and verifying the items list. ```python >>> o = r.object_add("/PortObjects/Test") >>> o.add("80") >>> o.add("6667-6669") >>> print o.items ['80', '6667-6669'] ``` -------------------------------- ### Create and Populate SystemObject Source: https://python.applogicnetworks.com/python2/current/systemobject.html Demonstrates adding a new SystemObject and populating it with an item value. ```python >>> o = r.object_add("/SystemObjects/Test") >>> o.add("000102030405") >>> print o.items ['000102030405'] ``` -------------------------------- ### Get Top Active Hosts Statistics Source: https://python.applogicnetworks.com/python2/current/stats_list_top_active_percents.html This script retrieves and displays statistics about the data transferred by the most active hosts within a specified date range. It connects to the PacketLogic system, fetches host activity data, sorts hosts by data transfer, and calculates the percentage of data transferred by the top 1%, 5%, 10%, and 20% most active hosts. Ensure you have the 'packetlogic2' library installed and provide the correct connection details and date range as command-line arguments. ```python #!/usr/bin/env python """Script to retrieve statistics about how much data the 1%, 5%, 10%, and 20% of most active hosts have transferred.""" __version__ = "1.2 2006-11-14 Procera Networks" ############################################################################### # # NO WARRANTY # # BECAUSE THE PROGRAM IS PROVIDED FREE OF CHARGE, THERE IS NO WARRANTY # FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN # OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES # PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED # OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS # TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE # PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, # REPAIR OR CORRECTION. # # IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING # WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR # REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, # INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED # TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY # YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER # PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # ############################################################################### import sys import packetlogic2 try: [host, user, pwd, startdate, enddate] = sys.argv[1:] except ValueError: print "Usage: top_stats.py plhost pluser plpass startdate enddate" print "Example: top_stats.py 192.168.1.25 admin pldemo00 2005-05-09 2005-05-16" sys.exit(1) # Connect to PacketLogic try: pl = packetlogic2.connect(host, user, pwd) s = pl.Statistics() except: t, v, tb = sys.exc_info() print "Couldn't connect to PacketLogic: %s" % v sys.exit(1) #Get a list of all host active the requested days hosts = [] for d in s.list(startdate, enddate, "/Hosts"): hosts.append((d['in'] + d['out'], d['name'])) print "There was %d different hosts recorded active between %s and %s" % (len(hosts), startdate, enddate) # Make hosts with most transferred data come first in list hosts.sort() hosts.reverse() # Remove hostname xfers = [a for a, b in hosts] # The most active host is first tophost = hosts[0] print "Top host (%s) transferred a total of %dMiB" % (tophost[1].split("/")[-1], tophost[0]>>20) print def get_top(lst, x, tot): num = len(lst)*x/100+1 amount = sum(lst[:num]) perc = 100*amount/tot print "The top %d%% (%d) active hosts transferred %d%% (%dMiB)" % (x, num, perc, amount>>20) total = sum(xfers) print "A total of %dMiB was transferred between %s and %s" % (total>>20, startdate, enddate) print get_top(xfers, 1, total) get_top(xfers, 5, total) get_top(xfers, 10, total) get_top(xfers, 20, total) ``` -------------------------------- ### GET /flowobject_list Source: https://python.applogicnetworks.com/python2/current/ruleset.html Returns a list of all FlowObjects. ```APIDOC ## GET /flowobject_list ### Description Return a list of all FlowObjects. ### Response #### Success Response (200) - **objects** (list of FlowObject) - A list of FlowObjects. ``` -------------------------------- ### Connect to PacketLogic SystemOverview Source: https://python.applogicnetworks.com/python2/current/systemoverview.html Initialize a connection to the PacketLogic system and instantiate the SystemOverview resource. ```python >>> import packetlogic2 >>> pl = packetlogic2.connect("192.168.1.25", "admin", "password") >>> so = pl.SystemOverview() ``` -------------------------------- ### GET /flowobject_find Source: https://python.applogicnetworks.com/python2/current/ruleset.html Finds a FlowObject by its name. ```APIDOC ## GET /flowobject_find ### Description Find a FlowObject by its name. ### Parameters #### Query Parameters - **name** (str) - Required - Name of FlowObject to find - **systemid** (str) - Optional - System ID ### Response #### Success Response (200) - **object** (FlowObject) - The found FlowObject or None if not found. ``` -------------------------------- ### Registering a RealtimeHost Callback Source: https://python.applogicnetworks.com/python2/current/realtime.html Demonstrates how to define a callback function to process host data and register it with the Realtime object. ```python >>> 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/", include_hosts=True) >>> rt.update_forever() ``` -------------------------------- ### Configure Command-Line Options Source: https://python.applogicnetworks.com/python2/current/ruleset_disable_enable_rules.html Defines host connection parameters and rule action flags using optparse. ```python parser = optparse.OptionParser() grp_host = optparse.OptionGroup(parser, "PacketLogic host options", "Options determining how to connect to the PacketLogic system") grp_host.add_option("--host", dest="host", default="192.168.1.25", action="store", help="PacketLogic host to connect to") grp_host.add_option("--user", dest="user", default="admin", action="store", help="PacketLogic user to authenticate with") grp_host.add_option("--pass", dest="passwd", default="pldemo00", action="store", help="PacketLogic passwd to authenticate with") parser.add_option_group(grp_host) grp_act = optparse.OptionGroup(parser, "Rule actions", "Options determining how to change the ruleset") grp_act.add_option("--shaping", dest="shaping", default=False, action="store_true", help="Enable/disable shaping rules") grp_act.add_option("--filtering", dest="filtering", default=False, action="store_true", help="Enable/disable filtering rules") grp_act.add_option("--statistics", dest="statistics", default=False, action="store_true", help="Enable/disable statistics rules") grp_act.add_option("--enable", dest="enable", default=[], action="append", help="enable rule named RULE", metavar="RULE") grp_act.add_option("--disable", dest="disable", default=[], action="append", help="disable rule named RULE", metavar="RULE") grp_act.add_option("--use-fnmatch", dest="usefnmatch", default=False, action="store_true", help="use file name matching wildcards instead of exact rule names") parser.add_option_group(grp_act) (options, args) = parser.parse_args() ``` -------------------------------- ### GET /fwrule_find Source: https://python.applogicnetworks.com/python2/current/ruleset.html Finds a firewall rule by its name. ```APIDOC ## GET /fwrule_find ### Description Find a firewall rule by name. ### Parameters #### Query Parameters - **name** (str) - Required - The name of the firewall rule. - **systemid** (str) - Optional - System identifier. ### Response #### Success Response (200) - **rule** (FwRule) - The firewall rule or null if not found. ``` -------------------------------- ### GET /flowobject_find_id Source: https://python.applogicnetworks.com/python2/current/ruleset.html Finds a FlowObject by its unique ID. ```APIDOC ## GET /flowobject_find_id ### Description Find a FlowObject by its id. ### Parameters #### Query Parameters - **object_id** (int) - Required - Id of flow object to find - **systemid** (str) - Optional - System ID ### Response #### Success Response (200) - **object** (FlowObject) - The found FlowObject or None if not found. ``` -------------------------------- ### Connect to PacketLogic and Access Ruleset Source: https://python.applogicnetworks.com/python2/current/ruleset.html Demonstrates how to establish a connection to the PacketLogic system and instantiate the Ruleset object. Ensure you have the packetlogic2 library installed and replace placeholder connection details with your actual credentials and IP address. ```python import packetlogic2 pl = packetlogic2.connect("192.168.1.25", "admin", "password") r = pl.Ruleset() ``` -------------------------------- ### Take a new backup Source: https://python.applogicnetworks.com/python2/current/backup.html Creates a new database backup, returning the generated filename. ```python >>> b.take() '20091026-08.15.plb' ``` -------------------------------- ### GET /dyn_list Source: https://python.applogicnetworks.com/python2/current/realtime.html List all dynamic netobject items. ```APIDOC ## GET /dyn_list ### Description List all dynamic netobject items. ### Method GET ### Endpoint dyn_list() ### Response #### Success Response (200) - **items** (list of tuple) - A list of tuples containing the netobject id and the item. ``` -------------------------------- ### Connect to PacketLogic System Source: https://python.applogicnetworks.com/python2/current/resourceedit.html Demonstrates how to import the packetlogic2 library and establish a connection to the PacketLogic system using PLConnection. This is the recommended way to access modules like ResourceEdit. ```python import packetlogic2 pl = packetlogic2.connect("192.168.1.25", "admin", "password") re = pl.ResourceEdit() ``` -------------------------------- ### GET /services_prop_list Source: https://python.applogicnetworks.com/python2/current/hosttriggers.html Retrieves a list of all service properties. ```APIDOC ## GET /services_prop_list ### Description List all properties. ### Method GET ### Response #### Success Response (200) - **properties** (list of str) - List of service properties. ``` -------------------------------- ### Perform Configuration Actions Source: https://python.applogicnetworks.com/python2/current/config_modify.html Executes the requested configuration action based on command-line options. Supports getting a value, setting a new value, setting a default value, or displaying detailed information. ```python if options.get: print confval['value'] elif options.set: c.set(args[0], args[1]) elif options.set_default: c.set(args[0], confval['defvalue']) elif options.info: print "%s:" % confval['key'] print " %s" % confval['description'] print " value: %s" % confval['value'] print " min value: %s" % confval['minvalue'] print " max value: %s" % confval['maxvalue'] print " default: %s" % confval['defvalue'] ``` -------------------------------- ### GET /services_list Source: https://python.applogicnetworks.com/python2/current/hosttriggers.html Retrieves a list of all available services. ```APIDOC ## GET /services_list ### Description List all services. ### Method GET ### Response #### Success Response (200) - **services** (list of str) - List of services. ``` -------------------------------- ### Initialize PacketLogic Connection and Channels Source: https://python.applogicnetworks.com/python2/current/channels.html Establish a connection to the PacketLogic system and instantiate the Channels resource. ```python >>> import packetlogic2 >>> pl = packetlogic2.connect("192.168.1.25", "admin", "password") >>> ch = pl.Channels() ``` -------------------------------- ### GET /download Source: https://python.applogicnetworks.com/python2/current/fileserv.html Downloads a specified file from the server. ```APIDOC ## GET /download ### Description Download specified file from the server. ### Method GET ### Parameters #### Query Parameters - **ftype** (int or str) - Required - Type of file, the name of the area as a string, the 'id' provided by the types() method or one of the constants on the Fileserv object. - **fname** (str) - Required - Name of file. ### Response #### Success Response (200) - **content** (str) - The contents of the requested file. ``` -------------------------------- ### GET /fwrule_list Source: https://python.applogicnetworks.com/python2/current/ruleset.html Retrieves a list of all existing firewall rules. ```APIDOC ## GET /fwrule_list ### Description Return a list of all firewall rules. ### Response #### Success Response (200) - **rules** (list) - A list of FwRule objects. ``` -------------------------------- ### Create Test Objects and Shaping Rules with Python Source: https://python.applogicnetworks.com/python2/current/ruleset_create_testobjects.html Automates the creation of NetObjects, ShapingObjects, and ShapingRules for testing purposes. Requires connection credentials as command-line arguments. ```python #!/usr/bin/env python """ Script that creates a bunch of NetObjects, ShapingObjects and Shapingrules for testing purposes. Creates Broadband 30-45 with ten random named subobjectsi Creates the same ShapingRules with the NetObjects as host conditions. """ __version__ = "1.1 2008-11-14 Procera Networks" ############################################################################### # # NO WARRANTY # # BECAUSE THE PROGRAM IS PROVIDED FREE OF CHARGE, THERE IS NO WARRANTY # FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN # OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES # PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED # OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS # TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE # PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, # REPAIR OR CORRECTION. # # IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING # WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR # REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, # INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING # OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED # TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY # YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER # PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # ############################################################################### import sys import random import packetlogic2 try: [host, user, pwd] = sys.argv[1:] except ValueError: print "Usage: %s plhost pluser plpass" % sys.argv[0] print "Example: %s packetlogic admin pldemo00" % sys.argv[0] sys.exit(1) # Connect to PacketLogic try: pl = packetlogic2.connect(host, user, pwd) r = pl.Ruleset() except: t, v, tb = sys.exc_info() print "Couldn't connect to PacketLogic: %s" % v sys.exit(1) if not r.shapingobject_find("unlimited"): r.shapingobject_add("unlimited") shapeobj = r.shapingobject_find("unlimited") for i in range(30, 50, 5): objname = "Broadband%d" % i if r.shapingrule_find(objname): r.shapingrule_remove(objname) r.remove("/NetObjects/%s" % objname) r.shapingrule_add(objname) a = r.shapingrule_find(objname) a.set_objects([shapeobj.id]) r.add("/NetObjects/%s" % objname) print "adding %s" % objname for num in range(1, 10): if i == 30: group = "Class A" elif i == 35: group = "Class B" elif i == 40: group = "Class C" else: group = "Class D" netobjectname = "/NetObjects/%s/%s - %s" % (objname, group, random.randint(1000, 30000)) r.add("%s" % netobjectname) all_obj = r.object_list("/NetObjects/%s" % objname) for obj in all_obj: if obj == all_obj[0]: a.cond_add(r.CONDITION_NETOBJECT_HOST, r.CONDITION_OP_EQ, [obj.id]) else: a.cond_object_add(r.CONDITION_NETOBJECT_HOST, obj.id) r.commit() ``` -------------------------------- ### GET /fwrule_find_id Source: https://python.applogicnetworks.com/python2/current/ruleset.html Finds a firewall rule by its unique identifier. ```APIDOC ## GET /fwrule_find_id ### Description Find a firewall rule by id. ### Parameters #### Query Parameters - **rule_id** (int) - Required - The id of the firewall rule. - **systemid** (str) - Optional - System identifier. ### Response #### Success Response (200) - **rule** (FwRule) - The firewall rule or null if not found. ``` -------------------------------- ### Initialize Backup Connection Source: https://python.applogicnetworks.com/python2/current/backup.html Access the Backup resource through an established PLConnection object. ```python >>> import packetlogic2 >>> pl = packetlogic2.connect("192.168.1.25", "admin", "password") >>> b = pl.Backup() ``` -------------------------------- ### Test Server Connectivity Source: https://python.applogicnetworks.com/python2/current/config.html Send a command to the server to test if it is up and responsive. ```python c.ping(string='') ``` -------------------------------- ### GET /flowobject_list_fields Source: https://python.applogicnetworks.com/python2/current/ruleset.html Returns a list of all available FlowObject fields. ```APIDOC ## GET /flowobject_list_fields ### Description Return a list of all FlowObject fields. ### Response #### Success Response (200) - **fields** (list of FlowObjectField) - A list of FlowObjectFields. ``` -------------------------------- ### View Builder Source: https://python.applogicnetworks.com/python2/current/realtime.html Gets a ViewBuilder object for creating views. ```APIDOC ## GET /get_view_builder ### Description Get a ViewBuilder object for creating views. See ViewBuilder object documentation for details. ### Method GET ### Endpoint /get_view_builder ### Response #### Success Response (200) - **viewBuilder** (ViewBuilder) - A ViewBuilder object. ### Notes This function requires v14.1 firmware or newer. ``` -------------------------------- ### List All IPFIX Objects Source: https://python.applogicnetworks.com/python2/current/ruleset.html Returns a list containing all configured IPFIX objects. Requires v15.0 firmware or newer. ```python >>> r.ipfixobject_list() [, ] ``` -------------------------------- ### Backup and Fileserv Methods Source: https://python.applogicnetworks.com/python2/current/fullindex.html Methods for Backup and Fileserv classes. ```APIDOC ## Backup and Fileserv Methods ### Description This section details methods for the Backup and Fileserv classes. ### Methods - **download** (Method) - Method in Backup, Fileserv - **download_to** (Method) - Method in Backup ``` -------------------------------- ### GET /dump_bgptable Source: https://python.applogicnetworks.com/python2/current/realtime.html Dump the BGP table for debugging purposes. ```APIDOC ## GET /dump_bgptable ### Description Dump the BGP table in packetlogicd for debugging purposes. Note: This API might change without notice. ### Method GET ### Endpoint dump_bgptable() ### Response #### Success Response (200) - **bgp_table** (tuple of list) - A tuple containing prefix and path information. In 14.1+, returns (depth, prefixstr, path_id, lchildren, rchildren). ``` -------------------------------- ### Create and Populate RewriteObject Source: https://python.applogicnetworks.com/python2/current/rewriteobject.html Demonstrates initializing a RewriteObject and adding a destination IP rule. ```python >>> o = r.object_add("/RewriteObjects/Test") >>> o.add("dstip=192.168.1.1") >>> print o.items ['dstip=192.168.1.1'] ``` -------------------------------- ### Connect to a PacketLogic System Source: https://python.applogicnetworks.com/python2/current/api_reference.html Establishes a connection to a PacketLogic system and initializes resource objects. ```python >>> import packetlogic2 >>> pl = packetlogic2.connect("192.168.1.25", "admin", "pldemo00") >>> print pl.remoteversion 12.1.2.70 >>> rt = pl.Realtime() >>> rs = pl.Ruleset() ``` -------------------------------- ### GET /template_flags/items Source: https://python.applogicnetworks.com/python2/current/systemoverview.html Retrieves the properties of TemplateFlags as a list of tuples. ```APIDOC ## GET /template_flags/items ### Description Return a list of (prop, value) tuples for TemplateFlags, similar to dict.items(). ### Method GET ### Endpoint /template_flags/items ### Response #### Success Response (200) - **items** (list of tuples) - A list containing (property, value) pairs. ``` -------------------------------- ### Add Host Callback and Update Forever Source: https://python.applogicnetworks.com/python2/current/realtime.html This example demonstrates how to add a callback function to monitor host connections and continuously update the information. The callback function processes connection details and prints them to the console. Ensure 'rt' and 'host' are defined and 'time' module is imported. ```python >>> 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) ``` -------------------------------- ### GET /NetObjects/find Source: https://python.applogicnetworks.com/python2/current/realtime.html Finds a single Realtime NetObject by its full path. ```APIDOC ## GET /NetObjects/find ### Description Find a single Realtime NetObject with the given full path. ### Method GET ### Parameters #### Query Parameters - **path** (str) - Required - The full path of the NetObject to find. ### Response #### Success Response (200) - **RealtimeNetObject** (object) - The specified NetObject data, or None if not found. ``` -------------------------------- ### GET /xfb_flags_list Source: https://python.applogicnetworks.com/python2/current/hosttriggers.html Lists all XFB flags available for use in FlagObjects. ```APIDOC ## GET /xfb_flags_list ### Description List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects. ### Method GET ### Response #### Success Response (200) - **flags** (list of str) - List of XFB flags. ``` -------------------------------- ### Initialize Ruleset Resource Source: https://python.applogicnetworks.com/python2/current/ruleset_disable_enable_rules.html Retrieves the Rules and Objects resource from the connected system. ```python rs = pl.Ruleset() ``` -------------------------------- ### GET /protocols/translate Source: https://python.applogicnetworks.com/python2/current/config.html Translates a protocol name or number to a tuple containing both. ```APIDOC ## GET /protocols/translate ### Description Translate a protocol name or number to a tuple with name and number. ### Method GET ### Parameters #### Query Parameters - **protocol** (int, str) - Required - Name or number of an IP protocol. - **strict** (bool) - Optional - If True, raises ValueError for unknown protocols. ``` -------------------------------- ### GET /protocol Source: https://python.applogicnetworks.com/python2/current/fileserv.html Translates a protocol name or number to a tuple containing both. ```APIDOC ## GET /protocol ### Description Translate protocol name OR number to tuple with name AND number. ### Method GET ### Parameters #### Query Parameters - **protocol** (int, str) - Required - Name or number of an IP protocol. - **strict** (bool) - Optional - If True, raises ValueError for unknown protocols. ``` -------------------------------- ### POST /HostTriggers/add Source: https://python.applogicnetworks.com/python2/current/hosttriggers.html Adds a new host trigger to the system with specified bandwidth, connection, and QoE parameters. ```APIDOC ## POST /HostTriggers/add ### Description Adds a new host trigger to the system. ### Method POST ### Parameters #### Request Body - **name** (str) - Required - Name of the trigger - **script** (str) - Required - Script filename to execute - **in_bw** (int) - Optional - Inbound bandwidth limit in Kbps - **out_bw** (int) - Optional - Outbound bandwidth limit in Kbps - **in_fwd** (int) - Optional - Inbound forwarded bandwidth limit in Kbps - **out_fwd** (int) - Optional - Outbound forwarded bandwidth limit in Kbps - **in_cps** (int) - Optional - Inbound connections per second - **out_cps** (int) - Optional - Outbound connections per second - **conns** (int) - Optional - Number of concurrent connections - **uconns** (int) - Optional - Number of concurrent unest. connections - **out_ttls** (int) - Optional - Number of different TTL values seen on outbound traffic - **qoe_in_int** (int) - Optional - QoE for inbound traffic on internal interface - **qoe_in_ext** (int) - Optional - QoE for inbound traffic on external interface - **qoe_out_int** (int) - Optional - QoE for outbound traffic on internal interface - **qoe_out_ext** (int) - Optional - QoE for outbound traffic on external interface - **netobject** (int) - Optional - Netobject ID - **trigtype** (int) - Optional - Trigger type - **uconn_rate** (int) - Optional - Unest. connection rate - **subitem_count** (int) - Optional - Number of subitems in view tree - **view_name** (str) - Optional - DynamicLiveView name ``` -------------------------------- ### Users Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's users resource. ```APIDOC ## GET /api/users ### Description Retrieves a connection to the PacketLogic's users resource. ### Method GET ### Endpoint /api/users ### Response #### Success Response (200) - **Users object** - An object representing the users resource connection. ``` -------------------------------- ### SystemOverview Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's SystemOverview resource. ```APIDOC ## GET /api/system_overview ### Description Retrieves a connection to the PacketLogic's SystemOverview resource. ### Method GET ### Endpoint /api/system_overview ### Response #### Success Response (200) - **SystemOverview object** - An object representing the SystemOverview resource connection. ``` -------------------------------- ### Download a file Source: https://python.applogicnetworks.com/python2/current/fileserv.html Downloads a specified file from the file server. Use this to retrieve configuration files or logs. The returned content is a string. ```python >>> mib = fs.download('SNMP', 'PACKETLOGIC-MIB') >>> len(mib) 191948 >>> mib[:84] '-- THIS FILE IS AUTO-GENERATED - DO NOT EDIT!\n\nPACKETLOGIC-MIB DEFINITIONS ::= BEGIN' ``` -------------------------------- ### Statistics Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's Statistics resource. ```APIDOC ## GET /api/statistics ### Description Retrieves a connection to the PacketLogic's Statistics resource. ### Method GET ### Endpoint /api/statistics ### Response #### Success Response (200) - **Statistics object** - An object representing the Statistics resource connection. ``` -------------------------------- ### List all FlowObjects Source: https://python.applogicnetworks.com/python2/current/ruleset.html Returns a list containing all FlowObjects currently configured. Requires firmware v21.xx or newer. ```python >>> r.flowobject_list() [, ] ``` -------------------------------- ### Ruleset Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's Ruleset resource. ```APIDOC ## GET /api/ruleset ### Description Retrieves a connection to the PacketLogic's Ruleset resource. ### Method GET ### Endpoint /api/ruleset ### Response #### Success Response (200) - **Ruleset object** - An object representing the Ruleset resource connection. ``` -------------------------------- ### List All Config Values Source: https://python.applogicnetworks.com/python2/current/config.html Retrieve a list of all configuration values. Each item in the list is a dictionary describing a config option, including its type and current value. ```python c.list() ``` -------------------------------- ### ResourceEdit Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's ResourceEdit resource. ```APIDOC ## GET /api/resource_edit ### Description Retrieves a connection to the PacketLogic's ResourceEdit resource. ### Method GET ### Endpoint /api/resource_edit ### Parameters #### Query Parameters - **port** (integer) - Optional - The port number for the ResourceEdit resource. ### Response #### Success Response (200) - **ResourceEdit object** - An object representing the ResourceEdit resource connection. ``` -------------------------------- ### POST /hosttrigger/add Source: https://python.applogicnetworks.com/python2/current/hosttriggers.html Adds a new host trigger to the system with specified bandwidth, connection, and QoE parameters. ```APIDOC ## POST /hosttrigger/add ### Description Adds a new host trigger to the system. QoE triggers can have values from 100 to 0, triggering when QoE falls below the configured value. ### Parameters #### Request Body - **name** (str) - Required - The new triggers name - **script** (str) - Required - The script filename to execute - **in_bw** (int) - Optional - Inbound bandwidth limit in Kbps - **out_bw** (int) - Optional - Outbound bandwidth limit in Kbps - **in_fwd** (int) - Optional - Inbound forwarded bandwidth limit in Kbps (deprecated) - **out_fwd** (int) - Optional - Outbound forwarded bandwidth limit in Kbps (deprecated) - **in_cps** (int) - Optional - Inbound connections per second - **out_cps** (int) - Optional - Outbound connections per second - **conns** (int) - Optional - Number of concurrent connections - **uconns** (int) - Optional - Number of concurrent unestablished connections - **out_ttls** (int) - Optional - Number of different TTL values on outbound traffic - **qoe_in_int** (int) - Optional - QoE for in traffic on internal interface - **qoe_in_ext** (int) - Optional - QoE for in traffic on external interface - **qoe_out_int** (int) - Optional - QoE for out traffic on internal interface - **qoe_out_ext** (int) - Optional - QoE for out traffic on external interface - **netobject** (int) - Optional - Netobject id - **trigtype** (int) - Optional - Trigger type - **uconn_rate** (int) - Optional - Unestablished connection rate - **subitem_count** (int) - Optional - Number of subitems in view tree - **view_name** (str) - Optional - DynamicLiveView name ``` -------------------------------- ### Realtime Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's realtime resource. ```APIDOC ## GET /api/realtime ### Description Retrieves a connection to the PacketLogic's realtime resource. ### Method GET ### Endpoint /api/realtime ### Parameters #### Query Parameters - **port** (integer) - Optional - The port number for the realtime resource. ### Response #### Success Response (200) - **Realtime object** - An object representing the realtime resource connection. ``` -------------------------------- ### Add and List ServiceObject Items Source: https://python.applogicnetworks.com/python2/current/serviceobject.html Demonstrates how to add an item to a ServiceObject and then print the list of items associated with it. This is typically done via the Ruleset object. ```python >>> o = r.object_add("/ServiceObjects/Test") >>> o.add("HTTP") >>> print o.items ['HTTP'] ``` -------------------------------- ### Logs Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's logs resource. ```APIDOC ## GET /api/logs ### Description Retrieves a connection to the PacketLogic's logs resource. ### Method GET ### Endpoint /api/logs ### Response #### Success Response (200) - **Logs object** - An object representing the logs resource connection. ``` -------------------------------- ### List all users on the system Source: https://python.applogicnetworks.com/python2/current/users.html Use this method to retrieve a list of all users configured in the system. Each user is returned as a User object. ```python >>> u.list() [, ] ``` -------------------------------- ### LogLevels Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's LogLevels resource. ```APIDOC ## GET /api/log_levels ### Description Retrieves a connection to the PacketLogic's LogLevels resource. ### Method GET ### Endpoint /api/log_levels ### Response #### Success Response (200) - **LogLevels object** - An object representing the log levels resource connection. ``` -------------------------------- ### Create and Populate TimeObject Source: https://python.applogicnetworks.com/python2/current/timeobject.html Demonstrates adding date ranges and weekly schedules to a TimeObject instance. ```python >>> o = r.object_add("/TimeObjects/Test") >>> o.add("200905090000-200909140000") >>> o.add("Mon,Tue,Wed,Thu,Fri@0800-1600") >>> print o.items ['200905090000-200909140000', 'Mon,Tue,Wed,Thu,Fri@0800-1600'] ``` -------------------------------- ### Fileserv Resource Source: https://python.applogicnetworks.com/python2/current/api_reference.html Get a connection to the PacketLogic's Fileserv resource. ```APIDOC ## GET /api/fileserv ### Description Retrieves a connection to the PacketLogic's Fileserv resource. ### Method GET ### Endpoint /api/fileserv ### Response #### Success Response (200) - **Fileserv object** - An object representing the file server resource connection. ```