This module contains functionality for managing backups 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") >>> b = pl.Backup()
A connection to a PacketLogic's "Backup" resource.
The methods of this object allows listing, taking and restoring backups on the PacketLogic system.
Methods: | ||
---|---|---|
Backup | list of dict
|
list(self) List backups stored on server |
restore(self, name, section='All', systemid='local') Restore a backup |
||
str
|
take(self, name='', resource='') Take a new backup |
|
Ungrouped | str
|
download(self, name) Download specified backup file |
download_to(self, name, destpath) Download specified backup file to a local file |
||
remove(self, name) Remove a backup file |
||
upload(self, fname, data) Upload a backup |
||
upload_from(self, fname, srcpath) Upload a backup from a local file |
||
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: | |
---|---|
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 backup file.
>>> plb = b.download("20090916-16.24.plb") >>> len(plb) 596406L >>> plb[:52] "<?xml version='1.0' encoding='UTF-8'?>\n<PacketLogic "
str
str
) - Name of backup to download.
Download specified backup file to a local file
>>> download_to("20090916-16.24.plb", "/tmp/back.plb")
str
) - Name of backup to download.
str
) - Destination path for downloaded file
List backups stored on server.
>>> b.list() [{'cdate': '', 'path': '20090520-05.14.plb', 'size': 353714L}, {'cdate': '', 'path': '20090731-22.52.plb', 'size': 272156L}, {'cdate': '', 'path': '20090831-09.56.plb', 'size': 177219L}, {'cdate': '', 'path': '20090916-16.24.plb', 'size': 596406L}]
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 a backup file
>>> b.restore("mybackup.plb")
str
) - Name of backup file
Restore a backup
>>> b.restore("mybackup.plb", "Rules & Object Configuration")
str
) - Name of backup file
str
) - The section in the backup file to restore, such as "Rules & Object
Configuration" or "All" for all sections (default).
str
) - Systemid to use for the items, or "local" to use system's
default, or "file" to use the systemid in 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
Take a new backup.
Creates a new backup of current database contents. The backup will be given the current date and time as name.
>>> b.take() '20091026-08.15.plb'
str
str
) - Name of newly created backup file. Requires firmware v12.4 or newer.
str
) - Include only the specified resource in backup file, use empty string
"" to include all resources (default). Requires firmware v12.4 or
newer.
Upload a backup
>>> data = file("/tmp/back.plb","rb").read() >>> len() 596406L >>> data[:52] "<?xml version='1.0' encoding='UTF-8'?>\n<PacketLogic " >>> b.upload("name-on-pl.plb", data)
str
) - Name of file.
str
) - The contents of the file.
Upload a backup from a local file.
>>> b.upload_from("name-on-pl.plb", "/tmp/back.plb")
str
) - Name of file.
str
) - Path to source 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
The CommitID associated with this session. (14.0 or newer only)