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", "password") >>> fs = pl.Fileserv()
This resource gives access to the "Fileserv" on the PacketLogic system, allowing up- and download of files.
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 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_CLI | Deprecated ID number used to access files in the 'CLI files' 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 |
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.
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.
str
) - Message recorded in the commit log. Ignored in v12.1 and earlier.
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'
str
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.
str
) - Name of file.
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'}]
dict
with the key
'r_path'
list
of dict
Send a command to server to test if it is up.
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.
tuple
of (str
, int
)
int
, str
or a ProtocolObject
Item) - Name or number of an IP protocol
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).
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.
dict
of str
:int
and
int
:str
Remove specified file from fileserv.
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.
str
) - Name of file.
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.
Send services to pldbd
Sets stringtable for services and properties. Do NOT use this unless you know exactly what you are doing.
list
of str
) - List of services
list
of str
) - List of service properties
List file types (directories) available on the system.
>>> fs.types() [{'flags': 1L, 'id': 123L, 'name': 'Host Trigger Files'}, {'flags': 3L, 'id': 234L, 'name': 'Firewall Trigger Files'}, ...]
dict
with the keys 'name'
, 'id'
and
'flags'
list
of dict
Upload a file to fileserv.
>>> licensedata=file('001122334455').read() >>> fs.upload('Upgrade files', '001122334455.lic', licensedata)
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.
str
) - Name of file.
str
) - The contents of the file.
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.
List all XFB (Transfer Behaviour) flags, that can be used in FlagObjects.
list
of str
Deprecated ID number used to access files in the 'Attribute descriptions' area. Use string instead.
Deprecated ID number used to access files in the 'Bookmarks' area. Use string instead.
Deprecated ID number used to access files in the 'DHCP snooper files' area. Use string instead.
Deprecated ID number used to access files in the 'Documentation' area. Use string instead.
Deprecated ID number used to access files in the 'CLI files' area. Use string instead.
Deprecated ID number used to access files in the 'Upgrade files' area. Use string instead.
Deprecated ID number used to access files in the 'Firewall trigger files' area. Use string instead.
Deprecated ID number used to access files in the 'Host trigger files' area. Use string instead.
Deprecated ID number used to access files in the 'Upgrade files' area. Use string instead.
Deprecated ID number used to access files in the 'PCAP writer files' area. Use string instead.
Deprecated ID number used to access files in the 'PCAP-2 writer files' area. Use string instead.
Deprecated ID number used to access files in the 'RADIUS snooper files' area. Use string instead.
Deprecated ID number used to access files in the 'SIP snooper files' area. Use string instead.
Deprecated ID number used to access files in the 'SNMP' area. Use string instead.
The CommitID associated with this session. (14.0 or newer only)