1#!/usr/bin/env python2
2# -*- coding: utf-8 -*-
3# BAREOS - Backup Archiving REcovery Open Sourced
4#
5# Copyright (C) 2014-2020 Bareos GmbH & Co. KG
6#
7# This program is Free Software; you can redistribute it and/or
8# modify it under the terms of version three of the GNU Affero General Public
9# License as published by the Free Software Foundation, which is
10# listed in the file LICENSE.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20# 02110-1301, USA.
21#
22# Author: Stephan Duehr
23#
24# Bareos-fd-vmware is a python Bareos FD Plugin intended to backup and
25# restore VMware images and configuration
26#
27
28import sys
29import os.path
30
31libdirs = ["/usr/lib64/bareos/plugins/", "/usr/lib/bareos/plugins/"]
32sys.path.extend([l for l in libdirs if os.path.isdir(l)])
33
34# newer Python versions, eg. Debian 8/Python >= 2.7.9 and
35# CentOS/RHEL since 7.4 by default do SSL cert verification,
36# we then try to disable it here.
37# see https://github.com/vmware/pyvmomi/issues/212
38py_ver = sys.version_info[0:3]
39if py_ver[0] == 2 and py_ver[1] == 7 and py_ver[2] >= 5:
40    import ssl
41
42    try:
43        ssl._create_default_https_context = ssl._create_unverified_context
44    except AttributeError:
45        pass
46
47# Provided by the Bareos FD Python plugin interface
48from bareosfd import bRC_OK
49
50# This module contains the wrapper functions called by the Bareos-FD, the
51# functions call the corresponding
52# methods from your plugin class
53import BareosFdWrapper
54from BareosFdWrapper import *  # noqa
55
56# This module contains the used plugin class
57import BareosFdPluginVMware
58
59
60def load_bareos_plugin(plugindef):
61    """
62    This function is called by the Bareos-FD to load the plugin
63    We use it to intantiate the plugin class
64    """
65    BareosFdWrapper.bareos_fd_plugin_object = BareosFdPluginVMware.BareosFdPluginVMware(
66        plugindef
67    )
68
69    return bRC_OK
70
71
72# the rest is done in the Plugin module
73