Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python: implement connection test for Python-Bareos TLS-PSK
- Loading branch information
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
regress/configs/python-bareos-connection-test/bareos-dir.conf.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# | ||
# Default Bareos Director Configuration file | ||
# | ||
# The only thing that MUST be changed is to add one or more | ||
# file or directory names in the Include directive of the | ||
# FileSet resource. | ||
# | ||
# You might also want to change the default email address | ||
# from root to your address. See the "mail" and "operator" | ||
# directives in the Messages resource. | ||
# | ||
Director { # define myself | ||
Name = @hostname@-dir | ||
DIRPort = @dirport@ # where we listen for UA connections | ||
QueryFile = "@scriptdir@/query.sql" | ||
WorkingDirectory = "@working_dir@" | ||
PidDirectory = "@piddir@" | ||
Maximum Concurrent Jobs = 4 | ||
Password = "bareos" # Console password | ||
Messages = Standard | ||
} | ||
|
||
JobDefs { | ||
Name = "DefaultJob" | ||
Type = Backup | ||
Level = Incremental | ||
Client = @hostname@-fd | ||
FileSet = FS_TESTJOB | ||
Storage = File | ||
Messages = Standard | ||
Pool = Default | ||
Priority = 10 | ||
Maximum Concurrent Jobs = 16 | ||
} | ||
|
||
Job { | ||
Name = "BackupClient1" | ||
JobDefs = "DefaultJob" | ||
Client Run Before Job = "@working_dir@/runbeforejob.sh" | ||
Client Run Before Job = "@tmpdir@/runbeforejob.sh" | ||
} | ||
|
||
|
||
FileSet { | ||
Name = FS_TESTJOB | ||
Include { | ||
File=<@tmpdir@/file-list | ||
} | ||
} | ||
|
||
|
||
# Client (File Services) to backup | ||
Client { | ||
Name = @hostname@-fd | ||
Address = @hostname@ | ||
FDPort = @fdport@ | ||
Catalog = MyCatalog | ||
Password = "xevrjURYoCHhn26RaJoWbeWXEY/a3VqGKp/37tgWiuHc" # password for FileDaemon | ||
Maximum Concurrent Jobs = 4 | ||
|
||
} | ||
|
||
# Definiton of file storage device | ||
Storage { | ||
Name = File | ||
Address = @hostname@ # N.B. Use a fully qualified name here | ||
SDPort = @sdport@ | ||
Password = "ccV3lVTsQRsdIUGyab0N4sMDavui2hOBkmpBU0aQKOr9" | ||
Device = FileStorage | ||
Media Type = File | ||
Maximum Concurrent Jobs = 4 | ||
} | ||
|
||
# Generic catalog service | ||
Catalog { | ||
Name = MyCatalog | ||
@libdbi@ | ||
dbdriver = "@db_type@" | ||
dbname = @db_name@ | ||
user = @db_user@ | ||
password = "@db_password@" | ||
} | ||
|
||
|
||
Messages { | ||
Name = Standard | ||
console = all, !skipped, !saved, !audit | ||
catalog = all, !skipped, !audit | ||
} | ||
|
||
# Default pool definition | ||
Pool { | ||
Name = Default | ||
Pool Type = Backup | ||
Recycle = yes # Bareos can automatically recycle Volumes | ||
AutoPrune = yes # Prune expired volumes | ||
Volume Retention = 365d # one year | ||
} | ||
|
||
# | ||
# Restricted console used by tray-monitor to get the status of the director | ||
# | ||
Console { | ||
Name = @hostname@-mon | ||
Password = "mon-dir-password" | ||
CommandACL = status, .status | ||
JobACL = *all* | ||
} |
5 changes: 5 additions & 0 deletions
5
regress/configs/python-bareos-connection-test/python-bareos-test.py.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import bareos.bsock | ||
|
||
password=bareos.bsock.Password("bareos") | ||
directorconsole=bareos.bsock.DirectorConsole(address="@hostname@", port=@dirport@, password=password) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
# | ||
# Run a simple connection test | ||
# with Python-Bareos | ||
# | ||
TestName="python-bareos-connection-test" | ||
|
||
bareos_python_test_script="python-bareos-test.py" | ||
bareos_python_module_source_dir="../python-bareos" | ||
python_interpreter="python" | ||
python_tlspsk_module="sslpsk" | ||
|
||
. scripts/functions | ||
|
||
scripts/cleanup | ||
copy_configs | ||
|
||
start_test | ||
run_bareos | ||
|
||
error_occurred=0 | ||
|
||
if [ -z `command -v ${python_interpreter}` ]; then | ||
echo "Error: Could not find python interpreter." | ||
error_occurred=1 | ||
elif ! python -c "import ${python_tlspsk_module}"; then | ||
echo "Error: Could not import python module \"${python_tlspsk_module}\"." | ||
error_occurred=1 | ||
else | ||
PYTHONPATH=${bareos_python_module_source_dir} ${python_interpreter} configs/${TestName}/${bareos_python_test_script} | ||
if [ $? != 0 ]; then | ||
echo "Python-Bareos test failed." | ||
error_occurred=1 | ||
fi | ||
fi | ||
|
||
stop_bareos | ||
|
||
export estat | ||
let estat=error_occurred | ||
|
||
end_test | ||
|