CheckpointFWBackupStatus
Deprecated. Use ssh command instead. Connect to a CheckPoint firewall appliance using SSH and retrieve the status for backup tasks. The user account being used to access the device must be set to use the SSH shell and not the built-in CheckPoint CLI. For more information, consult the CheckPoint documentation.
- Type
- python
- Pack
- CheckpointFirewall
Source
import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
CLI_SHOW = 'show backup status'
BASH_SHOW = '/etc/cli.sh -c "' + CLI_SHOW + '"'
def main():
keepPolling = True
res = []
tbl = []
devices = demisto.get(demisto.args(), 'devices')
devicesBackupStarted = []
devicesBackupError = []
if not devices:
res.append(
{"Type": entryTypes["error"], "ContentsFormat": formats["text"], "Contents": "Received empty device list!"})
else:
devices = ','.join(devices) if isinstance(devices, list) else devices
sshArgs = {"using": devices, "cmd": BASH_SHOW}
while keepPolling:
resSSH = demisto.executeCommand("ssh", sshArgs)
try:
for entry in resSSH:
if isError(entry):
res += resSSH
break
else:
device = entry['ModuleName']
if demisto.get(entry, 'Contents.success'):
output = demisto.get(entry, 'Contents.output')
backFileLoc = output.find("Backup file location")
backFileLocEnd = output.find("Backup process finished")
result = 'Answer returned'
devicesBackupStarted.append({
'DeviceName': device,
'System': demisto.get(entry, 'Contents.system'),
'Status': ("Done" if output.find("local backup succeeded.") > -1 else "Pending"),
'Path': (output[backFileLoc + len(
"Backup file location: "): backFileLocEnd - 1] if backFileLoc > -1
else None)}) # noqa: E128
else:
devicesBackupError.append(device)
output = "Output:\n" + str(demisto.get(entry, 'Contents.output')) + "Error:\n" + \
str(demisto.get(entry, 'Contents.error'))
result = 'Failed to query'
tbl.append({'DeviceName': device, 'System': demisto.get(entry, 'Contents.system'),
'Query result': result, 'Output': output})
except Exception as ex:
res.append({"Type": entryTypes["error"], "ContentsFormat": formats["text"],
"Contents": "Error occurred while parsing output from command. "
"Exception info:\n" + str(ex) + "\n\nInvalid output:\n" + str(resSSH)})
keepPolling = False
demisto.setContext('CheckpointBackup', devicesBackupStarted)
res.append({"Type": entryTypes["note"], "ContentsFormat": formats["table"], "Contents": tbl})
return_results(res)
if __name__ in ('__main__', '__builtin__', 'builtins'):
main()
README
Connects a Checkpoint firewall appliance using SSH and retrieves the status of backup tasks. The user account that accesses the device must be setup to use the SSH shell and not the built in Checkpoint CLI. Consult the Checkpoint documentation for instructions on how to do this.
Script Data
| Name | Description |
|---|---|
| Script Type | python |
| Tags | checkpoint |
Dependencies
This script uses the following commands and scripts.
- ssh
Inputs
| Argument Name | Description |
|---|---|
| devices | The list of devices to backup (comma-separated). |
| waittimeout | The wait time in seconds. If not provided, it will not wait. |
Outputs
| Path | Description | Type |
|---|---|---|
| CheckpointBackup.DeviceName | The name of the backed-up device. | Unknown |
| CheckpointBackup.System | The backed up system. | Unknown |
| CheckpointBackup.Status | The status of the backup process. | Unknown |
| CheckpointBackup.Path | The path of the backup file. | Unknown |