Documentation for PythonAPI
22.40.00py2

packetlogic2.pldb.channels

This module contains functionality for managing channels on the PacketLogic system.

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

>>> import packetlogic2
>>> pl = packetlogic2.connect("192.168.1.25", "admin", "password")
>>> ch = pl.Channels()

Classes defined here:

  • Channel - Information about a Channel
  • Channels - This is the resource for Channel inquiry and manipulation

Channel

Information about a Channel.

Returned in a list by Channels.channel_list.

Methods:
Ungrouped set_active(self, active)
Set or reset the active state on this Channel
update(self, internal_media=None, external_media=None, role=None, label=None, direction=None, int_ipv4_address=None, ext_ipv4_address=None, int_ipv6_address=None, ext_ipv6_address=None, int_ipv4_gateway=None, ext_ipv4_gateway=None, int_ipv6_gateway=None, ext_ipv6_gateway=None)
Update properties on this Channel
Class Variables:
__slots__ For internal use only.
Properties:
active Active state
caps Capabilities bitmask
description Deprecated alias for 'location'
direction Channel direaction
ext_ipv4_address IPv4 address of the external interface
ext_ipv4_gateway IPv4 address of the external gateway
ext_ipv6_address IPv6 address of the external interface
ext_ipv6_gateway IPv6 address of the external gateway
external System name of the external interface
external_media Media type on External interface
extpci PCI address of the external interface
id ID Number of the channel
int_ipv4_address IPv4 address of the internal interface
int_ipv4_gateway IPv4 address of the internal gateway
int_ipv6_address IPv6 address of the internal interface
int_ipv6_gateway IPv6 address of the internal gateway
internal System name of the internal interface
internal_media Media type on Internal interface
intpci PCI address of the internal interface
label The channel's label
location The channel's location
role Channel role
type Channel type

set_active(self, active)

Set or reset the active state on this Channel.

Parameters:
  • active (bool) - The active state to set on this Channel.

update(self, internal_media=None, external_media=None, role=None, label=None, direction=None, int_ipv4_address=None, ext_ipv4_address=None, int_ipv6_address=None, ext_ipv6_address=None, int_ipv4_gateway=None, ext_ipv4_gateway=None, int_ipv6_gateway=None, ext_ipv6_gateway=None)

Update properties on this Channel. Omitting an argument or setting it to None will leave that property unchanged.

Parameters:
  • internal_media (int) - One of the CHANNEL_MEDIA_ constants.
  • external_media (int) - One of the CHANNEL_MEDIA_ constants.
  • role (int) - One of the ROLE_ constants.
  • label (str) - Label for this channel.
  • direction (int) - One of the DIRECTION_ constants.
  • int_ipv4_address (str) - internal ipv4 address
  • ext_ipv4_address (str) - external ipv4 address
  • int_ipv6_address (str) - internal ipv6 address
  • ext_ipv6_address (str) - external ipv6 address
  • int_ipv4_gateway (str) - internal ipv4 gateway
  • ext_ipv4_gateway (str) - external ipv4 gateway
  • int_ipv6_gateway (str) - internal ipv6 gateway
  • ext_ipv6_gateway (str) - external ipv6 gateway

active

Active state.

caps

Capabilities bitmask. One or more of the CAPS_ constants.

description

Deprecated alias for 'location'.

direction

Channel direaction. One of the DIRECTION_ constants.

ext_ipv4_address

IPv4 address of the external interface.

ext_ipv4_gateway

IPv4 address of the external gateway.

ext_ipv6_address

IPv6 address of the external interface.

ext_ipv6_gateway

IPv6 address of the external gateway.

external

System name of the external interface.

external_media

Media type on External interface. One of the MEDIA_ constants.

extpci

PCI address of the external interface.

id

ID Number of the channel.

int_ipv4_address

IPv4 address of the internal interface.

int_ipv4_gateway

IPv4 address of the internal gateway.

int_ipv6_address

IPv6 address of the internal interface.

int_ipv6_gateway

IPv6 address of the internal gateway.

internal

System name of the internal interface.

internal_media

Media type on Internal interface. One of the MEDIA_ constants.

intpci

PCI address of the internal interface.

label

The channel's label.

Label used for referencing this channel from filtering rules.

location

The channel's location.

A string describing the channels location. e.g: "Channel 1/2"

role

Channel role. One of the ROLE_ constants.

type

Channel type. One of the TYPE_ constants.

ChannelLabel

Information about a Channel label.

Returned in a list by Channels.channel_divert_label_list or Channels.channel_monitor_label_list.

Methods:
Ungrouped add_channel(self, channelid, role=0)
Add ChannelLabel to specified channel id
remove(self)
Remove this ChannelLabel
remove_channel(self, channel=None, role=0)
Remove channel from list of channels
update(self, name=None, flags=0, role=None, protocol='', schemaname='', columnname='')
Update properties on this ChannelLabel
Class Variables:
CHANNEL_LABEL_FLAGS_NONE No label flags
CHANNEL_LABEL_FLAGS_DIVERT_RR_CONN Round robin load balancing
CHANNEL_LABEL_FLAGS_DIVERT_HASH_LHOST Hash on local host
CHANNEL_LABEL_FLAGS_LAYER3_MONITOR Label is of type layer3 monitor
CHANNEL_LABEL_FLAGS_ENCAP_NO_BINARY_HEADER Do not add binary header (l3 monitor)
CHANNEL_LABEL_FLAGS_ENCAP_WITH_BINARY_HEADER Add binary header (l3 monitor)
CHANNEL_LABEL_FLAGS_IP_REWRITE Rewrite IP Addresses (l3 monitor)
CHANNEL_LABEL_FLAGS_INCOMING_TRAFFIC Monitor incoming traffic (l3 monitor)
CHANNEL_LABEL_FLAGS_OUTGOING_TRAFFIC Monitor outgoing traffic (l3 monitor)
CHANNEL_LABEL_FLAGS_HB_DISABLED Disable heartbeat
CHANNEL_LABEL_FLAGS_HB_ICMP Use ICMP heartbeat
CHANNEL_LABEL_FLAGS_HB_HTTP Use HTTP HEAD heartbeat
CHANNEL_LABEL_FLAGS_NO_STRIP Use no strip mode
CHANNEL_LABEL_FLAGS_STRIP_L2_HDR Use strip linklevel header mode
CHANNEL_LABEL_FLAGS_STRIP_L3_HDR Use strip network header mode
CHANNEL_LABEL_FLAGS_TIMESTAMP Include timestamp in binary header
CHANNEL_LABEL_FLAGS_SESSION_CONTEXT Include session context field in binary header
Properties:
channels Channels
columnname Column Name
flags Flags
id Id
name Name
protocol Protocol
schemaname Schema Name

add_channel(self, channelid, role=0)

Add ChannelLabel to specified channel id. The role of the specified channel must be the same as the role specified for the ChannelLabel.

remove(self)

Remove this ChannelLabel

remove_channel(self, channel=None, role=0)

Remove channel from list of channels

update(self, name=None, flags=0, role=None, protocol='', schemaname='', columnname='')

Update properties on this ChannelLabel. Omitting an argument or setting it to None will leave that property unchanged.

channels

Channels

columnname

Column Name

flags

Flags

id

Id

name

Name

protocol

Protocol

schemaname

Schema Name

ChannelLabelChannel

Represents channels in a label

Methods:
Ungrouped update(self, channel=None, vlan=None, flags=None, int_address=None, int_heartbeat=None, int_gateway=None, ext_address=None, ext_heartbeat=None, ext_gateway=None, int_port=None, ext_port=None, destination_name=None, destination_address=None, heartbeat_url=None, heartbeat_port=None, role=0)
Update properties on this ChannelLabelChannel
Properties:
channel Channel
destination_address monitor destination IP
destination_name monitor destination reference name
ext_address external vlan IP
ext_gateway external gateway
ext_heartbeat external heartbeat
ext_port external port number for encapsulation
flags flags
heartbeat_port HTTP HEAD heartbeat port number for HEAD request
heartbeat_url HTTP HEAD heartbeat URL for HEAD request
int_address internal vlan IP
int_gateway internal gateway
int_heartbeat internal heartbeat
int_port internal port number for encapsulation
vlan vlan

channel

Channel

destination_address

monitor destination IP

destination_name

monitor destination reference name

ext_address

external vlan IP

ext_gateway

external gateway

ext_heartbeat

external heartbeat

ext_port

external port number for encapsulation

flags

flags

heartbeat_port

HTTP HEAD heartbeat port number for HEAD request

heartbeat_url

HTTP HEAD heartbeat URL for HEAD request

int_address

internal vlan IP

int_gateway

internal gateway

int_heartbeat

internal heartbeat

int_port

internal port number for encapsulation

vlan

vlan

Channels

This is the resource for Channel inquiry and manipulation. Changes needs to be commited to take effect.

Inherits from: Resource
Methods:
Ungrouped list of Channel channel_divert_label_list(self)
List all ChannelLabels (divert label) in the PacketLogic system
list of Channel channel_l3_monitor_label_list(self)
List all ChannelsLabels (layer 3 monitor label) in the PacketLogic system
channel_label_add(self, name='', role=None, protocol='', schemaname='', columnname='')
Create ChannelLabel with given name and role
list of Channel channel_list(self)
List all Channels (Traffic Interface Pairs) in the PacketLogic system
list of Channel channel_monitor_label_list(self)
List all ChannelsLabels (monitor label) in the PacketLogic system
Inherited from Resource close(self)
Immediately disconnects the resource
commit(self, message='PythonAPI commit')
Store the current transaction to the database
ping(self, string='')
Send a command to server to test if it is up
tuple of (str, int) protocol(self, protocol, strict=False)
Translate protocol name OR number to tuple with name AND number
dict of str:int and int:str protocols_dict(self)
Returns a dictionary with name:nr and nr:name items for IP protocols
rollback(self)
Abort the current transaction and discard the data
services_cmd(self, services=[], props=[])
Send services to pldbd
list of str services_list(self)
List all services
list of str services_prop_list(self)
List all properties
wait_for_commit(self, pinginterval=60)
Wait for new data to be committed on resource
list of str xfb_flags_list(self)
List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects
Class Variables:
CHANNEL_MEDIA_AUTO Media type is Auto Negotiated
CHANNEL_MEDIA_10HD Media type is 10 Mbps Half Duplex
CHANNEL_MEDIA_10FD Media type is 10 Mbps Full Duplex
CHANNEL_MEDIA_100HD Media type is 100 Mbps Half Duplex
CHANNEL_MEDIA_100FD Media type is 100 Mbps Full Duplex
CHANNEL_MEDIA_1000FD Media type is 1 Gbps Full Duplex
CHANNEL_MEDIA_10000FD Media type is 10 Gbps Full Duplex
CHANNEL_MEDIA_40000FD Media type is 40 Gbps Full Duplex
CHANNEL_MEDIA_100000FD Media type is 100 Gbps Full Duplex
ROLE_NONE Channel is not used
ROLE_TRAFFIC Channel used for passing traffic
ROLE_DIVERT Channel used for divert
ROLE_MONITOR Channel used for sending out monitored traffic
ROLE_FLOWSYNC Channel used for flowsync
ROLE_SHUNT Channel used for shunting traffic
ROLE_LAYER3 Channel used for layer3 traffic
ROLE_L3_MONITOR Channel used for layer3 monitor traffic
ROLE_L2_FLOWSYNC_L3_MONITOR Channel used for flowsync/layer3 monitor traffic
CAPS_AUTONEG Channel can do auto negotiation
CAPS_10HD Channel can do 10 Mbps Half Duplex
CAPS_10FD Channel can do 10 Mbps Full Duplex
CAPS_100HD Channel can do 100 Mbps Half Duplex
CAPS_100FD Channel can do 100 Mbps Full Duplex
CAPS_1000FD Channel can do 1 Gbps Full Duplex
CAPS_10000FD Channel can do 10 Gbps Full Duplex
CAPS_40000FD Channel can do 40 Gbps Full Duplex
CAPS_100000FD Channel can do 100 Gbps Full Duplex
CAPS_TRAFFIC Channel can be used for passing traffic
CAPS_DIVERT Channel can be used for divert
CAPS_MONITOR Channel can be used for sending out monitored traffic
CAPS_FLOWSYNC Channel can be used for flowsync
CAPS_LINK_TOGGLE Channel link can be toggled on/off
CAPS_SHUNT Channel can be used for shunting traffic
CAPS_LAYER3 Channel can be used for layer-3 traffic
CAPS_LAYER3_NEXT_HOP Channel can be used for layer-3, with default gateways.
DIRECTION_DEFAULT Channel is working in the default directions.
DIRECTION_REVERSE Channel is reversed.
DIRECTION_INTERNAL Both ports in the channel is internal
DIRECTION_EXTERNAL Both ports in the channel is external
Properties:
commitid The CommitID associated with this session

channel_divert_label_list(self)

List all ChannelLabels (divert label) in the PacketLogic system.

>>> ch.channel_divert_label_list()
[<ChannelLabel fancydivertlabel>]
Returns:
  • List containing a Channel object for each channel available on the system.
  • list of Channel

channel_l3_monitor_label_list(self)

List all ChannelsLabels (layer 3 monitor label) in the PacketLogic system.

>>> ch.channel_l3_monitor_label_list()
[<ChannelLabel fancymonitorlabel>]
Returns:
  • List containing a Channel object for each channel available on the system.
  • list of Channel

channel_label_add(self, name='', role=None, protocol='', schemaname='', columnname='')

Create ChannelLabel with given name and role.

Parameters:
  • name (char) - Name of ChannelLabel.
  • role (int) - One of the ROLE_DIVERT or ROLE_MONITOR or ROLE_L3_MONITOR constants
  • protocol (char) - Static field for Layer 3 monitor binary header (protocol in pldb)
  • schemaname (char) - Schema name for Layer 3 monitor binary header
  • columnname (char) - Schema column name for Layer 3 monitor binary header

channel_list(self)

List all Channels (Traffic Interface Pairs) in the PacketLogic system.

>>> ch.channel_list()
[<Channel #299 'Slot 4/GE.5 (Reserved)'>,
 <Channel #216 'Slot 4/GE.4'>,
 <Channel #212 'Slot 4/GE.3'>,
 <Channel #208 'Slot 4/GE.2'>,
 <Channel #204 'Slot 4/GE.1'>,
 <Channel #200 'Slot 4/10GE'>,
 <Channel #199 'Slot 3/GE.5 (Monitor/FlowSync)'>,
 <Channel #116 'Slot 3/GE.4'>,
 <Channel #112 'Slot 3/GE.3'>,
 <Channel #108 'Slot 3/GE.2'>,
 <Channel #104 'Slot 3/GE.1'>,
 <Channel #100 'Slot 3/10GE'>]
Returns:
  • List containing a Channel object for each channel available on the system.
  • list of Channel

channel_monitor_label_list(self)

List all ChannelsLabels (monitor label) in the PacketLogic system.

>>> ch.channel_monitor_label_list()
[<ChannelLabel fancymonitorlabel>]
Returns:
  • List containing a Channel object for each channel available on the system.
  • list of Channel

close(self)

Immediately disconnects the resource.

After this method has been called this object becomes useless.

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

commit(self, message='PythonAPI commit')

Store the current transaction to the database.

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

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

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

ping(self, string='')

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

protocol(self, protocol, strict=False)

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

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

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

protocols_dict(self)

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

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

rollback(self)

Abort the current transaction and discard the data.

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

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

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

Send services to pldbd

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

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

services_list(self)

List all services

Returns:
  • List of services
  • list of str

services_prop_list(self)

List all properties.

Returns:
  • List of service properties
  • list of str

wait_for_commit(self, pinginterval=60)

Wait for new data to be committed on resource.

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

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

xfb_flags_list(self)

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

Returns:
  • List of XFB flags
  • list of str

commitid

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