1#!/usr/bin/env python2
2# -*- coding: utf-8 -*-
3# BAREOS® - Backup Archiving REcovery Open Sourced
4#
5# Copyright (C) 2014-2017 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
30libdirs = ['/usr/lib64/bareos/plugins/', '/usr/lib/bareos/plugins/']
31sys.path.extend([l for l in libdirs if os.path.isdir(l)])
32
33# newer Python versions, eg. Debian 8/Python >= 2.7.9 and
34# CentOS/RHEL since 7.4 by default do SSL cert verification,
35# we then try to disable it here.
36# see https://github.com/vmware/pyvmomi/issues/212
37py_ver = sys.version_info[0:3]
38if py_ver[0] == 2 and py_ver[1] == 7 and py_ver[2] >= 5:
39    import ssl
40    try:
41        ssl._create_default_https_context = ssl._create_unverified_context
42    except AttributeError:
43        pass
44
45# Provided by the Bareos FD Python plugin interface
46from bareos_fd_consts import bRCs
47
48# This module contains the wrapper functions called by the Bareos-FD, the
49# functions call the corresponding
50# methods from your plugin class
51import BareosFdWrapper
52from BareosFdWrapper import *  # noqa
53
54# This module contains the used plugin class
55import BareosFdPluginVMware
56
57
58def load_bareos_plugin(context, plugindef):
59    '''
60    This function is called by the Bareos-FD to load the plugin
61    We use it to intantiate the plugin class
62    '''
63    BareosFdWrapper.bareos_fd_plugin_object = \
64        BareosFdPluginVMware.BareosFdPluginVMware(
65            context, plugindef)
66
67    return bRCs['bRC_OK']
68
69# the rest is done in the Plugin module
70