Documentation for PythonAPI
17.2.0py1

packetlogic2.pldb.fileserv

This module contains functionality for accessing the "File server" on the PacketLogic system.

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

>>> import packetlogic2
>>> pl = packetlogic2.connect("192.168.1.25", "admin", "pldemo00")
>>> fs = pl.Fileserv()

Classes defined here:

  • Fileserv - This resource gives access to the "Fileserv" on the PacketLogic system,

Fileserv

This resource gives access to the "Fileserv" on the PacketLogic system, allowing up- and download of files.

Inherits from: Resource
Methods:
Fileserv str download(self, ftype, fname)
Download specified file
list of dict list(self, ftype)
List all files of specified type
remove(self, ftype, fname)
Remove specified file from fileserv
list of dict types(self)
List available file types (directories) available on the system
upload(self, ftype, fname, data)
Upload a file to fileserv
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
Properties:
ATTRIBUTES Deprecated ID number used to access files in the 'Attribute descriptions'
BOOKMARKS Deprecated ID number used to access files in the 'Bookmarks' area
DHCP_SNOOPER Deprecated ID number used to access files in the 'DHCP snooper files' area
DOCUMENTATION Deprecated ID number used to access files in the 'Documentation' area
FIRMWARE_UPLOAD Deprecated ID number used to access files in the 'Upgrade files' area
FWTRIGGER Deprecated ID number used to access files in the 'Firewall trigger files'
HOSTTRIGGER Deprecated ID number used to access files in the 'Host trigger files' area
LICENSE_UPLOAD Deprecated ID number used to access files in the 'Upgrade files' area
PCAP_1 Deprecated ID number used to access files in the 'PCAP writer files' area
PCAP_2 Deprecated ID number used to access files in the 'PCAP-2 writer files'
RADIUS_SNOOPER Deprecated ID number used to access files in the 'RADIUS snooper files'
SIP_SNOOPER Deprecated ID number used to access files in the 'SIP snooper files' area
SNMP_MIB Deprecated ID number used to access files in the 'SNMP' area
commitid The CommitID associated with this session

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.

download(self, ftype, fname)

Download specified file.

>>> mib = fs.download('SNMP', 'PACKETLOGIC-MIB')
>>> len(mib)
191948
>>> mib[:84]
'-- THIS FILE IS AUTO-GENERATED - DO NOT EDIT!\n\nPACKETLOGIC-MIB DEFINITIONS ::= BEGIN'
Returns:
  • The contents of the requested file.
  • str
Parameters:
  • ftype (int or str) - 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) - Name of file.

list(self, ftype)

List all files of specified type.

>>> fs.list(5)
[{'r_path': 'PACKETLOGIC-MIB'}]
>>> fs.list(fs.SNMP_MIB)
[{'r_path': 'PACKETLOGIC-MIB'}]
>>> fs.list('SNMP')
[{'r_path': 'PACKETLOGIC-MIB'}]
Returns:
  • List of files. Each file is represented as a dict with the key 'r_path'
  • list of dict

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

remove(self, ftype, fname)

Remove specified file from fileserv.

Parameters:
  • ftype (int) - 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) - Name of file.

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

types(self)

List available file types (directories) available on the system.

>>> fs.types()
[{'flags': 3L, 'id': 0L, 'name': 'Host Trigger Files'},
 {'flags': 3L, 'id': 1L, 'name': 'Firewall Trigger Files'},
 {'flags': 3L, 'id': 2L, 'name': 'DHCP Snooping files'},
 {'flags': 3L, 'id': 3L, 'name': 'RADIUS Snooping files'},
 {'flags': 3L, 'id': 4L, 'name': 'SIP Snooper files'},
 {'flags': 1L, 'id': 5L, 'name': 'SNMP'},
 {'flags': 3L, 'id': 6L, 'name': 'License upload'},
 {'flags': 1L, 'id': 7L, 'name': 'Documentation'},
 {'flags': 1L, 'id': 8L, 'name': 'PCAP Writer files'},
 {'flags': 1L, 'id': 9L, 'name': 'PCAP-2 Writer files'},
 {'flags': 3L, 'id': 10L, 'name': 'Upgrade files'},
 {'flags': 3L, 'id': 11L, 'name': 'Attribute descriptions'}]
Returns:
  • List of the different file types available. Each type is represented as a dict with the keys 'name', 'id' and 'flags'
  • list of dict

upload(self, ftype, fname, data)

Upload a file to fileserv.

>>> licensedata=file('001122334455').read()
>>> fs.upload('Upgrade files', '001122334455.lic', licensedata)
Parameters:
  • ftype (int) - 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) - Name of file.
  • data (str) - The contents of the file.

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

ATTRIBUTES

Deprecated ID number used to access files in the 'Attribute descriptions' area. Use string instead.

BOOKMARKS

Deprecated ID number used to access files in the 'Bookmarks' area. Use string instead.

DHCP_SNOOPER

Deprecated ID number used to access files in the 'DHCP snooper files' area. Use string instead.

DOCUMENTATION

Deprecated ID number used to access files in the 'Documentation' area. Use string instead.

FIRMWARE_UPLOAD

Deprecated ID number used to access files in the 'Upgrade files' area. Use string instead.

FWTRIGGER

Deprecated ID number used to access files in the 'Firewall trigger files' area. Use string instead.

HOSTTRIGGER

Deprecated ID number used to access files in the 'Host trigger files' area. Use string instead.

LICENSE_UPLOAD

Deprecated ID number used to access files in the 'Upgrade files' area. Use string instead.

PCAP_1

Deprecated ID number used to access files in the 'PCAP writer files' area. Use string instead.

PCAP_2

Deprecated ID number used to access files in the 'PCAP-2 writer files' area. Use string instead.

RADIUS_SNOOPER

Deprecated ID number used to access files in the 'RADIUS snooper files' area. Use string instead.

SIP_SNOOPER

Deprecated ID number used to access files in the 'SIP snooper files' area. Use string instead.

SNMP_MIB

Deprecated ID number used to access files in the 'SNMP' area. Use string instead.

commitid

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