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
def activate(): logger = logging.getLogger() config = InventoryConfig() config.init("inventory") logger.debug("Inventory %s" % str(config.disable)) if config.disable: logger.warning("Plugin inventory: disabled by configuration.") return False # When this module is used by the MMC agent, the global inventory variable is shared. # This means an Inventory instance is not created each time a XML-RPC call is done. if not InventoryLocation().init( config ): # does Inventory().activate() (which does the Inventory().db_check()) return False logger.info("Plugin inventory: Inventory database version is %d" % Inventory().dbversion) ComputerManager().register("inventory", InventoryComputers) ProvisioningManager().register('inventory', InventoryProvisioner) ComputerLocationManager().register('inventory', InventoryLocation) PossibleQueries().init(config) # Register the panel to the DashboardManager try: from mmc.plugins.dashboard.manager import DashboardManager from mmc.plugins.inventory.panel import InventoryPanel DM = DashboardManager() DM.register_panel(InventoryPanel("inventory")) except ImportError: pass return True
def activate(): config = DashboardConfig("dashboard") if config.disabled: logger.warning("Plugin dashboard: disabled by configuration.") return False DM = DashboardManager() DM.register_panel(GeneralPanel("general")) DM.register_panel(SpacePanel("space")) DM.register_panel(ShortcutsPanel("shortcuts")) return True
def init(self, config): self.config = config self.config.readSubscriptionConf() if self.config.is_subscribe_done: try: from mmc.plugins.dashboard.manager import DashboardManager from mmc.plugins.base.panel import SupportPanel DM = DashboardManager() DM.register_panel(SupportPanel("support")) except ImportError: pass
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
def activate(): config = updateConfig("update") if config.disabled: logger.warning("Plugin UpdateMgr: disabled by configuration.") return False if not updateDatabase().activate(config): logger.error("UpdateMgr database not activated") return False DashboardManager().register_panel(Panel('product_updates')) DashboardManager().register_panel(Panel('clients_updates')) # Add create update commands in the task manager if config.enable_update_commands: TaskManager().addTask("update.create_update_commands", (create_update_commands, ), cron_expression=config.update_commands_cron) if config.enable_update_description: TaskManager().addTask( "add_update_description", (add_update_description, ), cron_expression=config.add_update_description_cron) return True
def activate(): logger = logging.getLogger() logger.debug("Pkgs is activating") config = PkgsConfig("pkgs") if config.disabled: logger.warning("Plugin pkgs: disabled by configuration.") return False DashboardManager().register_panel(Panel('appstream')) TaskManager().addTask("pkgs.updateAppstreamPackages", (updateAppstreamPackages, ), cron_expression='23 10 * * *') return True
def activate(): config = DashboardConfig("dashboard") if config.disabled: logger.warning("Plugin dashboard: disabled by configuration.") return False DM = DashboardManager() DM.register_panel(GeneralPanel("general")) DM.register_panel(SpacePanel("space")) DM.register_panel(ShortcutsPanel("shortcuts")) DM.register_panel(ProcessPanel("process")) DM.register_panel(ComputersOnlinePanel("computersOnline")) DM.register_panel(BackupPanel("backup")) DM.register_panel(UpdatePanel("product_updates")) return True
def activate(): config = SupportConfig(NAME) if config.disabled: logging.getLogger().warning( "Plugin Support: disabled by configuration.") return False DM = DashboardManager() DM.register_panel(RemoteSupportPanel("remotesupport")) DM.register_panel(license_panel) TaskManager().addTask("support.get_license_info", (LicenseChecker().get_license_info, ), cron_expression=config.cron_search_for_updates) LicenseChecker().get_license_info(True) return True
def activate(): config = ServicesConfig("services") if config.disabled: logger.warning("Plugin services: disabled by configuration.") return False logger.debug("Loading systemd units") try: ServiceManager().list() except NameError: logger.error( "Failed to list systemd units. Is python-systemd-dbus installed ?") return False try: from mmc.plugins.dashboard.manager import DashboardManager from mmc.plugins.services.panel import ServicesPanel, SystemPanel DM = DashboardManager() DM.register_panel(ServicesPanel("services")) DM.register_panel(SystemPanel("system")) except ImportError: pass return True
def activate(): """ this function define if the module "base" can be activated. @return: return True if this module can be activate @rtype: boolean """ config = SambaConfig("samba") if config.disabled: logger.info("samba plugin disabled by configuration.") return False if config.defaultSharesPath: if config.defaultSharesPath.endswith("/"): logger.error("Trailing / is not allowed in defaultSharesPath") return False if not os.path.exists(config.defaultSharesPath): logger.error("The default shares path '%s' does not exist" % config.defaultSharesPath) return False for cpath in config.authorizedSharePaths: if cpath.endswith("/"): logger.error("Trailing / is not allowed in authorizedSharePaths") return False if not os.path.exists(cpath): logger.error("The authorized share path '%s' does not exist" % cpath) return False # Verify if samba conf file exist conf = config.samba_conf_file if not os.path.exists(conf): logger.error(conf + " does not exist") return False # validate smb.conf smbconf = SambaConf() if not smbconf.validate(conf): logger.error("SAMBA configuration file is not valid") return False # For each share, test if it sharePath exists for share in getDetailedShares(): shareName = share[0] infos = shareInfo(shareName) if infos: sharePath = infos['sharePath'] if sharePath and not '%' in sharePath and not os.path.exists( sharePath): # only show error logger.error("The samba share path '%s' does not exist." % sharePath) else: return False try: ldapObj = ldapUserGroupControl() except ldap.INVALID_CREDENTIALS: logger.error("Can't bind to LDAP: invalid credentials.") return False # Test if the Samba LDAP schema is available in the directory try: schema = ldapObj.getSchema("sambaSamAccount") if len(schema) <= 0: logger.error("Samba schema is not included in LDAP directory") return False except: logger.exception("invalid schema") return False # Verify if init script exist init = config.samba_init_script if not os.path.exists(init): logger.error(init + " does not exist") return False # If SAMBA is defined as a PDC, make extra checks if smbconf.isPdc(): samba = SambaLDAP() # Create SAMBA computers account OU if it doesn't exist head, path = samba.baseComputersDN.split(",", 1) ouName = head.split("=")[1] samba.addOu(ouName, path) # Check that a sambaDomainName entry is in LDAP directory domainInfos = samba.getDomain() # Set domain policy samba.setDomainPolicy() if not domainInfos: logger.error( "Can't find sambaDomainName entry in LDAP for domain %s. Please check your SAMBA LDAP configuration." % smbconf.getContent("global", "workgroup")) return False smbconfbasesuffix = smbconf.getContent("global", "ldap suffix") if not smbconfbasesuffix: logger.error("SAMBA 'ldap suffix' option is not setted.") return False if ldap.explode_dn(samba.baseDN) != ldap.explode_dn(smbconfbasesuffix): logger.error( "SAMBA 'ldap suffix' option is not equal to MMC 'baseDN' option." ) return False # Check that SAMBA and MMC given OU are in sync for option in [ ("ldap user suffix", "baseUsersDN", samba.baseUsersDN), ("ldap group suffix", "baseGroupsDN", samba.baseGroupsDN), ("ldap machine suffix", "baseComputersDN", samba.baseComputersDN) ]: smbconfsuffix = smbconf.getContent("global", option[0]) if not smbconfsuffix: logger.error("SAMBA '" + option[0] + "' option is not setted") return False # Do a case insensitive comparison of the corresponding MMC / SAMBA options if ldap.explode_rdn(smbconfsuffix)[0].lower() != ldap.explode_rdn( option[2])[0].lower(): logger.error("SAMBA option '" + option[0] + "' is not equal to MMC '" + option[1] + "' option.") return False # Check that "ldap delete dn" SAMBA option is set to "No" smbconfdeletedn = smbconf.isValueTrue( smbconf.getContent("global", "ldap delete dn")) if smbconfdeletedn == 1: logger.error("SAMBA option 'ldap delete dn' must be disabled.") return False # Check that Domain Computers group exists # We need it to put a machine account in the right group when joigning it to the domain if not samba.getDomainComputersGroup(): logger.error( "Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Computers' group. Please check your SAMBA LDAP configuration." ) return False # Check that Domain Admins group exists if not samba.getDomainAdminsGroup(): logger.error( "Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Admins' group. Please check your SAMBA LDAP configuration." ) return False # Check that Domain Guests group exists if not samba.getDomainGuestsGroup(): logger.error( "Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Guests' group. Please check your SAMBA LDAP configuration." ) return False # Check that Domain Users group exists if not samba.getDomainUsersGroup(): logger.error( "Can't find sambaGroupMapping entry in LDAP corresponding to 'Domain Users' group. Please check your SAMBA LDAP configuration." ) return False # Check that add machine script option is set, and that the given script exist addMachineScript = smbconf.getContent("global", "add machine script") if not addMachineScript: logger.error("SAMBA 'add machine script' option is not set.") return False else: script = addMachineScript.split(" ")[0] if not os.path.exists(script): logger.error( "SAMBA 'add machine script' option is set to a non existing file: " + script) return False # Issue a warning if NSCD is running if os.path.exists("/var/run/nscd.pid") or os.path.exists( "/var/run/.nscd_socket") or os.path.exists("/var/run/nscd"): logger.warning( "Looks like NSCD is installed on your system. You should not run NSCD on a SAMBA server." ) # Check that os level is set to 255 oslevel = smbconf.getContent("global", "os level") if int(oslevel) < 255: logger.debug("Set SAMBA os level to 255.") smbconf.setContent("global", "os level", "255") smbconf.save() reloadSamba() try: from mmc.plugins.dashboard.manager import DashboardManager from mmc.plugins.samba.panel import SambaPanel DM = DashboardManager() DM.register_panel(SambaPanel("samba")) except ImportError: pass return True
def get_panels_infos(): return DashboardManager().get_panels_infos()
def get_panel_infos(panel): return DashboardManager().get_panel_infos(panel)