Пример #1
0
def activate():
    config = GlpiConfig("glpi")
    logger = logging.getLogger()
    if config.disable:
        logger.warning("Plugin glpi: disabled by configuration.")
        return False

    if not GlpiLocation().init(config): # does Glpi().activate()
        return False
    if not Glpi().db_check():
        return False

    ComputerManager().register("glpi", GlpiComputers)
    ProvisioningManager().register("glpi", GlpiProvisioner)
    if config.displayLocalisationBar:
        ComputerLocationManager().register("glpi", GlpiLocation)

    if config.check_db_enable:
        scheduleCheckStatus(config.check_db_interval)

    # Register the panel to the DashboardManager
    try:
        from mmc.plugins.dashboard.manager import DashboardManager
        from mmc.plugins.glpi.panel import GlpiPanel
        DM = DashboardManager()
        DM.register_panel(GlpiPanel("glpi"))
    except ImportError:
        pass

    return True
Пример #2
0
    def activate(self, conffile=None):
        self.logger = logging.getLogger()

        if self.is_activated:
            self.logger.info("Glpi don't need activation")
            return None

        self.config = GlpiConfig("glpi", conffile)

        # we choose the good backend for the database
        if Glpi07().try_activation(self.config):
            self.database = Glpi07()
        elif Glpi08().try_activation(self.config):
            self.database = Glpi08()
        elif Glpi084().try_activation(self.config):
            self.database = Glpi084()
        elif Glpi0855().try_activation(self.config):
            self.database = Glpi0855()
        elif Glpi090().try_activation(self.config):
            self.database = Glpi090()
        elif Glpi91().try_activation(self.config):
            self.database = Glpi91()
        elif Glpi92().try_activation(self.config):
            self.database = Glpi92()
        elif Glpi93().try_activation(self.config):
            self.database = Glpi93()
        elif Glpi94().try_activation(self.config):
            self.database = Glpi94()
        else:
            self.logger.warn(
                "Can't load the right database backend for your version of GLPI"
            )
            return False

        # activate the backend
        ret = self.database.activate(self.config)
        self.is_activated = self.database.is_activated
        # Register the panel to the DashboardManager
        try:
            logging.getLogger().debug('Try to load glpi panels')
            from mmc.plugins.dashboard.manager import DashboardManager
            from mmc.plugins.dashboard.panel import Panel
            DM = DashboardManager()
            DM.register_panel(Panel("inventory"))
            if self.database.fusionantivirus is not None:
                DM.register_panel(Panel("antivirus"))
            # Registring OS Repartition panel
            DM.register_panel(Panel("os_repartition"))
        except ImportError:
            logging.getLogger().debug('Failed to load glpi panels')

        return ret
Пример #3
0
def activate():
    config = GlpiConfig("glpi")
    logger = logging.getLogger()
    if config.disable:
        logger.warning("Plugin glpi: disabled by configuration.")
        return False

    if not GlpiLocation().init(config):  # does Glpi().activate()
        return False
    if not Glpi().db_check():
        return False

    ComputerManager().register("glpi", GlpiComputers)
    ProvisioningManager().register("glpi", GlpiProvisioner)
    if config.displayLocalisationBar:
        ComputerLocationManager().register("glpi", GlpiLocation)

    if config.check_db_enable:
        scheduleCheckStatus(config.check_db_interval)

    return True
Пример #4
0
    def activate(self, conffile=None):
        self.logger = logging.getLogger()

        if self.is_activated:
            self.logger.info("Glpi don't need activation")
            return None

        self.config = GlpiConfig("glpi", conffile)

        # we choose the good backend for the database
        if Glpi07().try_activation(self.config):
            self.database = Glpi07()
        elif Glpi08().try_activation(self.config):
            self.database = Glpi08()
        else:
            self.logger.warn(
                "Can't load the right database backend for your version of GLPI"
            )
            return False

        # activate the backend
        ret = self.database.activate(self.config)
        self.is_activated = self.database.is_activated

        # we get all the needed methods
        methods = ['initMappers', 'getMachineUUID', 'activate', 'config', 'decode', 'doesUserHaveAccessToMachine', 'doesUserHaveAccessToMachines', \
            'getLastMachineInventoryFull', 'getLastMachineInventoryPart', 'getLocationsCount', 'getMachineIp', 'getMachinesMac', 'getMachineMac', 'getMachineUUID', \
            'getUserLocations', 'getUserParentLocations', 'getUserProfile', 'getUserProfiles', 'getUsersInSameLocations', 'init', 'inventoryExists', 'glpi_version', \
            'getRestrictedComputersList', 'getRestrictedComputersListLen', 'getComputersList', 'getComputer', 'getComputerCount', 'getMachinesLocations', \
            'getAllComments', 'getAllContactNums', 'getAllContacts', 'getAllEntities', 'getAllGroups', 'getAllHostnames', 'getAllLocations', \
            'getAllModels', 'getAllNetworks', 'getAllOs', 'getAllOsSps', 'getAllSoftwares', 'getAllVersion4Software', 'glpi_version_new', 'getMachineByMacAddress', \
            'getMachineUUIDByMacAddress', 'getMachineByComment', 'getMachineByContact', 'getMachineByContactNum', 'getMachineByEntity', 'getMachineByGroup', 'getMachineByHostname', \
            'getMachineByLocation', 'getMachineByModel', 'getMachineByNetwork', 'getMachineByOs', 'getMachineByOsSp', 'getMachineBySoftware', 'getMachineBySoftwareAndVersion', \
            'glpi_chosen_version', 'getLocationsFromPathString', 'getLocationParentPath', 'getTotalComputerCount', 'isComputerNameAvailable', 'getMachineNumberByState', \
            'getMachineListByState', 'countLastMachineInventoryPart', 'delMachine', 'setGlpiEditableValue'
            ]
        for i in methods:
            setattr(self, i, getattr(self.database, i))

        return ret
#!/usr/bin/python

from mmc.plugins.base import createGroup, changeGroupDescription
from mmc.plugins.base.config import BasePluginConfig
from mmc.plugins.glpi.config import GlpiConfig
import ldap
import MySQLdb
import sys

# GLPI MySQL parameters
configglpi = GlpiConfig("glpi")
dbhost = configglpi.dbhost
dbname = configglpi.dbname
dbuser = configglpi.dbuser
dbpasswd = configglpi.dbpasswd

# MySQL connexion
mysqlcon = None

# Get GLPI profile list from MySQL
try:
    mysqlcon = MySQLdb.connect(dbhost, dbuser, dbpasswd, dbname)
    mysqlcur = mysqlcon.cursor()
    mysqlcur.execute("SELECT %s FROM %s" % ("name", "glpi_profiles"))
    glpi_profiles = mysqlcur.fetchall()
except MySQLdb.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit(1)

# Create GLPI-<group> in MMC
# Also create it in GLPI
Пример #6
0
 def __init__(self, conffile=None):
     self.logger = logging.getLogger()
     self.config = GlpiConfig("glpi", conffile)
     self.glpi = Glpi()