コード例 #1
0
ファイル: TreeOU.py プロジェクト: pulse-project/pulse
    def str_to_ou(self, ou_string):
        """
        Generate a OU string with the path of the node. For example, for the node /root/first_child/grand_son,
        it's str_to_ou() is OU=grand_son,OU=first_child,OU=root,DC=myDomain,DC=local.
        The DC datas are read from the configuration file.

        Params:
            String ou_string contains the path of the node pointed.

        Returns:
            String which contains the result (i.e.: OU=grand_son,OU=first_child,OU=root,DC=myDomain,DC=local)
            or
            returns False if the string can't be generated
        """
        config = PluginConfigFactory.new(BasePluginConfig, "base")
        if config.has_section('authentication_externalldap'):
            # Get the parameters from the config file
            suffix = config.get('authentication_externalldap', 'suffix')

            ou_list = ou_string.split('/')
            ou_list.reverse()

            ous = []
            for ou in ou_list:
                ou = 'OU=' + ou
                ous.append(ou)

            ous.append(suffix)
            return ','.join(ous)

        else:
            return False
コード例 #2
0
ファイル: sync.py プロジェクト: resonancellc/mds
def get_openldap_config():
    """Return OpenLdap credentials used by mmc base plugin"""
    mmc_base_config = PluginConfigFactory.new(BasePluginConfig, "base")
    return {
        'base_dn': mmc_base_config.baseDN,
        'bind_dn': mmc_base_config.username,
        'bind_pw': mmc_base_config.password
    }
コード例 #3
0
ファイル: sync.py プロジェクト: AnatomicJC/mmc
def get_openldap_config():
    """
    Return OpenLdap credentials used by mmc base plugin
    """
    from mmc.support.config import PluginConfigFactory
    from mmc.plugins.base.config import BasePluginConfig
    mmc_base_config = PluginConfigFactory.new(BasePluginConfig, "base")
    return {'base_dn': mmc_base_config.baseDN,
            'bind_dn': mmc_base_config.username,
            'bind_pw': mmc_base_config.password}
コード例 #4
0
ファイル: configuration.py プロジェクト: sebastiendu/mmc
def loadInventoryConf(module_name):
    """
    before commiting the config for the inventory module
    we are switching to, we make sure the config is loaded
    (if not we load it), to be able to modify its value
    before starting the module
    Also enable and disable the correct module (but they
    are not yet started, just the config is modified)
    """
    inventory_config = PluginConfigFactory.new(InventoryConfig, "inventory")
    glpi_config = PluginConfigFactory.new(GlpiConfig, "glpi")
    print("Instance of inventory config in loadInventoryConf is %s" % inventory_config)

    # Enable and disable the right modules in their config
    # base_config = PluginConfigFactory.get("base")
    # base_config.set('computers', 'method', module_name)
    glpi_config.set("main", "disable", "0" if module_name == "glpi" else 1)
    inventory_config.init("inventory")
    inventory_config.cp.set("main", "disable", "0" if module_name == "inventory" else 1)

    print("Disable: ", inventory_config.disable)
コード例 #5
0
ファイル: configuration.py プロジェクト: gnumaniac/pulse
def loadInventoryConf(module_name):
    """
    before commiting the config for the inventory module
    we are switching to, we make sure the config is loaded
    (if not we load it), to be able to modify its value
    before starting the module
    Also enable and disable the correct module (but they
    are not yet started, just the config is modified)
    """
    inventory_config = PluginConfigFactory.new(InventoryConfig, "inventory")
    glpi_config = PluginConfigFactory.new(GlpiConfig, "glpi")
    print('Instance of inventory config in loadInventoryConf is %s' %
          inventory_config)

    # Enable and disable the right modules in their config
    # base_config = PluginConfigFactory.get("base")
    # base_config.set('computers', 'method', module_name)
    glpi_config.set('main', 'disable', '0' if module_name == 'glpi' else 1)
    inventory_config.init('inventory')
    inventory_config.cp.set('main', 'disable',
                            '0' if module_name == 'inventory' else 1)

    print('Disable: ', inventory_config.disable)
コード例 #6
0
ファイル: __init__.py プロジェクト: sebastiendu/mmc
    def __init__(self, config=None, init=True):
        Singleton.__init__(self)
        if not hasattr(self, "logaction"):
            if config == None:
                from mmc.plugins.base import BasePluginConfig
                from mmc.support.config import PluginConfigFactory

                try:
                    # Read the configuration
                    self.make(PluginConfigFactory.new(BasePluginConfig, "base"), init)
                except IOError:
                    # Fallback on default configuration
                    self.make(None, init)
            else:
                self.make(config, init)
コード例 #7
0
 def __init__(self, config=None, init=True):
     Singleton.__init__(self)
     if not hasattr(self, 'logaction'):
         if config == None:
             from mmc.plugins.base import BasePluginConfig
             from mmc.support.config import PluginConfigFactory
             try:
                 # Read the configuration
                 self.make(
                     PluginConfigFactory.new(BasePluginConfig, 'base'),
                     init)
             except IOError:
                 # Fallback on default configuration
                 self.make(None, init)
         else:
             self.make(config, init)
コード例 #8
0
def getLdapRootDN():
    """
    Returns the LDAP root DN.
    """
    config = PluginConfigFactory.new(BasePluginConfig, 'base')
    return {'LDAP root': config.baseDN}
コード例 #9
0
ファイル: status.py プロジェクト: AnatomicJC/mmc
def getLdapRootDN():
    """
    Returns the LDAP root DN.
    """
    config = PluginConfigFactory.new(BasePluginConfig, 'base')
    return {'LDAP root': config.baseDN}