Example #1
0
File: ip.py Project: mattmb/spoke
 def _populate_from_ldap(self):
     """Create a list of allocated IP addresses from LDAP"""
     if not self.ip_ldap_search_base:
         msg = 'LDAP enabled but no LDAP search base defined'
         raise error.ConfigError(msg)
     # Do LDAP search and populate allocated IP address store
     ldap = SpokeLDAP()
     dn = self.ip_ldap_search_base
     search_scope = 2  # ldap.SCOPE_SUBTREE
     # Filter requires a modified DHCP schema with substr match support
     filter = '%s=%s*' % (self.ip_ldap_attr, self.ip_ldap_key)
     attr = [self.ip_ldap_attr]
     result = ldap._get_object(dn, search_scope, filter, attr)
     if result['data'] == []:
         msg = 'No reserved IP addresses found in LDAP'
         self.log.debug(msg)
         return True
     # Loop through our result and build a set of allocated addresses
     for item in result['data']:
         # Fetch the value of the IP Address attribute
         entry = item[1][self.ip_ldap_attr][0]
         # Remove the string prefix
         ip = entry.split(' ')[1]
         # Check if ip address is in our subnet
         if self.subnet.has_key(ip):
             self.aloc_ips.add(ip)
     msg = 'Found %s IP addreses in LDAP' % len(self.aloc_ips)
     self.log.debug(msg)
Example #2
0
 def __init__(self, org_name, user_id):
     """Get config, setup logging and LDAP connection."""   
     SpokeLDAP.__init__(self)     
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 0 #ldap.SCOPE_BASE
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.org_def_children = self.config.get('ATTR_MAP', \
                             'org_def_children', 'people,groups,dns,hosts')
     self.org_children = self.org_def_children.split(',')
     self.user_login = self.config.get('ATTR_MAP', 'user_login', 'aenetAccountLoginName')
     self.user_id = user_id
     self.user = self._get_user(org_name, self.user_id)
     self.user_dn = self.user['data'][0].__getitem__(0)
     self.user_attrs = self.user['data'][0].__getitem__(1)
     self.user_classes = self.user_attrs['objectClass']
     self.imap_class = self.config.get('ATTR_MAP', 'imap_class', 'aenetCyrus')
     self.imap_enable = self.config.get('ATTR_MAP', 'imap_enable', 'aenetCyrusEnabled')
     self.imap_mailbox = self.config.get('ATTR_MAP', 'imap_mailbox', 'aenetCyrusMailboxName')
     self.imap_domain = self.config.get('ATTR_MAP', 'imap_domain', 'aenetCyrusMailboxDomain')
     self.imap_partition = self.config.get('ATTR_MAP', 'imap_partition', 'aenetCyrusMailboxPartition')
     self.imap_partition_def = self.config.get('ATTR_MAP', \
                                 'imap_partition_def', 'partition-default')
     self.smtp_class = self.config.get('ATTR_MAP', 'smtp_class', 'aenetPostfix')
     self.smtp_address = self.config.get('ATTR_MAP', 'smtp_address', 'aenetPostfixEmailAccept')
     self.smtp_destination = self.config.get('ATTR_MAP', \
                             'smtp_destination', 'aenetPostfixEmailDeliver')
     self.smtp_enable = self.config.get('ATTR_MAP', 'smtp_enable', 'aenetPostfixEnabled')
     self.smtp_pri_address = self.config.get('ATTR_MAP', \
                             'smtp_pri_address', 'aenetPostfixEmailAddress')
Example #3
0
 def __init__(self, dhcp_server, group=None, host=None):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_service_class = 'dhcpService'
     self.dhcp_option_attr = 'dhcpOption'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix',
                                             '-config')
     self.dhcp_server = dhcp_server
     self.service_name = self.dhcp_server + self.dhcp_conf_suffix
     self.dhcp_service = self._get_dhcp_service(self.dhcp_server)
     self.dhcp_service_dn = self.dhcp_service['data'][0].__getitem__(0)
     self.target_dn = self.dhcp_service_dn
     if group is not None:
         self.dhcp_group_name = group
         self.dhcp_group = self._get_dhcp_group(self.dhcp_server, \
                                                     self.dhcp_group_name)
         self.dhcp_group_dn = self.dhcp_group['data'][0].__getitem__(0)
         self.target_dn = self.dhcp_group_dn
     if host is not None:
         self.dhcp_host_name = host
         self.dhcp_host = self._get_dhcp_host(self.dhcp_server, \
                                 self.dhcp_group_name, self.dhcp_host_name)
         self.dhcp_host_dn = self.dhcp_host['data'][0].__getitem__(0)
         self.target_dn = self.dhcp_host_dn
Example #4
0
File: host.py Project: mattmb/spoke
 def __init__(self, org_name):    
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.host_container = self.config.get('HOST', 'host_container', 'hosts')
     self.host_container_dn = '%s=%s,%s' % (self.container_attr, \
                                         self.host_container, self.org_dn)
     self.host_class = self.config.get('HOST', 'host_class', 'aenetHost')
     self.host_key = self.config.get('HOST', 'host_key', 'cn')
     self.host_uuid_attr = self.config.get('HOST', 'host_uuid_attr', 'aenetHostUUID')
     self.host_name_attr = self.config.get('HOST', 'host_name_attr', 'aenetHostName')
     self.host_cpu_attr = self.config.get('HOST', 'host_cpu_attr', 'aenetHostCPU')
     self.host_mem_attr = self.config.get('HOST', 'host_mem_attr', 'aenetHostMem')
     self.host_extra_opts_attr = self.config.get('HOST', 
                             'host_extra_opts_attr', 'aenetHostExtraOpts')
     self.host_family_attr = self.config.get('HOST', 'host_family_attr', 'aenetHostFamily')
     self.host_network_layout_attr = self.config.get('HOST', 
                     'host_network_layout_attr', 'aenetHostNetworkLayout')
     self.host_storage_layout_attr = self.config.get('HOST', 
                     'host_storage_layout_attr', 'aenetHostStorageLayout')
     self.host_type_attr = self.config.get('HOST', 'host_type_attr', 'aenetHostType')
Example #5
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 2  #ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr',
                                           'ou')
     self.user_login = self.config.get('ATTR_MAP', 'user_login',
                                       'aenetAccountLoginName')
     self.user_class = self.config.get('ATTR_MAP', 'user_class',
                                       'aenetAccount')
     self.user_key = self.config.get('ATTR_MAP', 'user_key', 'uid')
     self.user_name = self.config.get('ATTR_MAP', 'user_name',
                                      'aenetAccountDisplayName')
     self.user_enable = self.config.get('ATTR_MAP', 'user_enable',
                                        'aenetAccountEnabled')
     self.user_container = self.config.get('ATTR_MAP', 'user_container',
                                           'people')
Example #6
0
File: ip.py Project: mattmb/spoke
 def _populate_from_ldap(self):
     """Create a list of allocated IP addresses from LDAP"""
     if not self.ip_ldap_search_base:
         msg = 'LDAP enabled but no LDAP search base defined'
         raise error.ConfigError(msg)
     # Do LDAP search and populate allocated IP address store
     ldap = SpokeLDAP()
     dn = self.ip_ldap_search_base
     search_scope = 2 # ldap.SCOPE_SUBTREE
     # Filter requires a modified DHCP schema with substr match support
     filter = '%s=%s*' % (self.ip_ldap_attr, self.ip_ldap_key)
     attr = [self.ip_ldap_attr]
     result = ldap._get_object(dn, search_scope, filter, attr)
     if result['data'] == []:
         msg = 'No reserved IP addresses found in LDAP'
         self.log.debug(msg)
         return True
     # Loop through our result and build a set of allocated addresses
     for item in result['data']:
     # Fetch the value of the IP Address attribute
         entry = item[1][self.ip_ldap_attr][0]
         # Remove the string prefix
         ip = entry.split(' ')[1]           
         # Check if ip address is in our subnet
         if self.subnet.has_key(ip):
             self.aloc_ips.add(ip)
     msg = 'Found %s IP addreses in LDAP' % len(self.aloc_ips)
     self.log.debug(msg)
Example #7
0
File: dhcp.py Project: mattmb/spoke
 def __init__(self, dhcp_server, group=None, host=None):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_service_class = 'dhcpService'
     self.dhcp_option_attr = 'dhcpOption'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix', '-config')
     self.dhcp_server = dhcp_server
     self.service_name = self.dhcp_server + self.dhcp_conf_suffix
     self.dhcp_service = self._get_dhcp_service(self.dhcp_server)
     self.dhcp_service_dn = self.dhcp_service['data'][0].__getitem__(0)
     self.target_dn = self.dhcp_service_dn
     if group is not None:
         self.dhcp_group_name = group
         self.dhcp_group = self._get_dhcp_group(self.dhcp_server, \
                                                     self.dhcp_group_name)
         self.dhcp_group_dn = self.dhcp_group['data'][0].__getitem__(0)
         self.target_dn = self.dhcp_group_dn
     if host is not None:
         self.dhcp_host_name = host
         self.dhcp_host = self._get_dhcp_host(self.dhcp_server, \
                                 self.dhcp_group_name, self.dhcp_host_name)
         self.dhcp_host_dn = self.dhcp_host['data'][0].__getitem__(0)
         self.target_dn = self.dhcp_host_dn
Example #8
0
 def __init__(self, org_name, user_id):
     """Get config, setup logging and LDAP connection."""   
     SpokeLDAP.__init__(self)     
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 0 #ldap.SCOPE_BASE
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.org_def_children = self.config.get('ATTR_MAP', \
                             'org_def_children', 'people,groups,dns,hosts')
     self.org_children = self.org_def_children.split(',')
     self.user_login = self.config.get('ATTR_MAP', 'user_login', 'aenetAccountLoginName')
     self.user_id = user_id
     self.user = self._get_user(org_name, self.user_id)
     self.user_dn = self.user['data'][0].__getitem__(0)
     self.user_attrs = self.user['data'][0].__getitem__(1)
     self.user_classes = self.user_attrs['objectClass']
     self.imap_class = self.config.get('ATTR_MAP', 'imap_class', 'aenetCyrus')
     self.imap_enable = self.config.get('ATTR_MAP', 'imap_enable', 'aenetCyrusEnabled')
     self.imap_mailbox = self.config.get('ATTR_MAP', 'imap_mailbox', 'aenetCyrusMailboxName')
     self.imap_domain = self.config.get('ATTR_MAP', 'imap_domain', 'aenetCyrusMailboxDomain')
     self.imap_partition = self.config.get('ATTR_MAP', 'imap_partition', 'aenetCyrusMailboxPartition')
     self.imap_partition_def = self.config.get('ATTR_MAP', \
                                 'imap_partition_def', 'partition-default')
     self.smtp_class = self.config.get('ATTR_MAP', 'smtp_class', 'aenetPostfix')
     self.smtp_address = self.config.get('ATTR_MAP', 'smtp_address', 'aenetPostfixEmailAccept')
     self.smtp_destination = self.config.get('ATTR_MAP', \
                             'smtp_destination', 'aenetPostfixEmailDeliver')
     self.smtp_enable = self.config.get('ATTR_MAP', 'smtp_enable', 'aenetPostfixEnabled')
     self.smtp_pri_address = self.config.get('ATTR_MAP', \
                             'smtp_pri_address', 'aenetPostfixEmailAddress')
Example #9
0
 def __init__(self, org_name, domain_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.dns_cont_attr = self.config.get('DNS', 'dns_cont_attr', 'ou')
     self.dns_cont_name = self.config.get('DNS', 'dns_cont_name', 'dns')
     self.dns_cont_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
     self.dns_zone_name_attr = self.config.get('DNS', 'dns_zone_attr',
                                               'zoneName')
     self.dns_zone_class = self.config.get('DNS', 'dns_zone_class',
                                           'dNSZone')
     self.dns_resource_attr = self.config.get('DNS', 'dns_resource_attr',
                                              'relativeDomainName')
     self.dns_record_class = self.config.get('DNS', 'dns_record_class',
                                             'IN')
     self.dns_default_ttl = self.config.get('DNS', 'dns_default_ttl',
                                            '86400')
     self.dns_min_ttl = self.config.get('DNS', 'dns_min_ttl', '3600')
     self.dns_serial_start = self.config.get('DNS', 'dns_serial_start', '1')
     self.dns_slave_refresh = self.config.get('DNS', 'dns_slave_refresh',
                                              '3600')
     self.dns_slave_retry = self.config.get('DNS', 'dns_slave_retry', '600')
     self.dns_slave_expire = self.config.get('DNS', 'dns_slave_expire',
                                             '86400')
     self.dns_ns_attr = self.config.get('DNS', 'dns_ns_attr', 'nSRecord')
     self.dns_soa_attr = self.config.get('DNS', 'dns_soa_attr', 'sOARecord')
     self.dns_a_attr = self.config.get('DNS', 'dns_a_attr', 'aRecord')
     self.dns_cname_attr = self.config.get('DNS', 'dns_cname_attr',
                                           'cNAMERecord')
     self.dns_mx_attr = self.config.get('DNS', 'dns_mx_attr', 'mXRecord')
     self.dns_txt_attr = self.config.get('TXT', 'dns_txt_attr', 'tXTRecord')
     self.dns_ptr_attr = self.config.get('PTR', 'dns_ptr_attr', 'pTRRecord')
     self.dns_type_attrs = {
         'SOA': self.dns_soa_attr,
         'NS': self.dns_ns_attr,
         'A': self.dns_a_attr,
         'CNAME': self.dns_cname_attr,
         'MX': self.dns_mx_attr,
         'TXT': self.dns_txt_attr,
         'PTR': self.dns_ptr_attr
     }
     self.domain_name = common.validate_domain(domain_name)
     self.dns_dn = '%s=%s,%s' % (self.dns_cont_attr, self.dns_cont_name, \
                                                             self.org_dn)
     self.zone_dn = '%s=%s,%s' % (self.dns_zone_name_attr, \
                                             self.domain_name, self.dns_dn)
Example #10
0
File: dhcp.py Project: mattmb/spoke
 def __init__(self):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_server_class = 'dhcpServer'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix', '-config') 
Example #11
0
 def __init__(self):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_server_class = 'dhcpServer'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix',
                                             '-config')
Example #12
0
File: dhcp.py Project: mattmb/spoke
 def __init__(self, dhcp_server):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_group_class = 'dhcpGroup'
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix', '-config')
     self.service_name = dhcp_server + self.dhcp_conf_suffix
     self.service_dn = 'cn=%s,%s' % (self.service_name, self.base_dn)
Example #13
0
 def __init__(self, dhcp_server):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_group_class = 'dhcpGroup'
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix',
                                             '-config')
     self.service_name = dhcp_server + self.dhcp_conf_suffix
     self.service_dn = 'cn=%s,%s' % (self.service_name, self.base_dn)
Example #14
0
File: dhcp.py Project: mattmb/spoke
 def __init__(self, dhcp_server):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_subnet_class = 'dhcpSubnet'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix', '-config')
     self.dhcp_server = dhcp_server
     self.dhcp_service_name = self.dhcp_server + self.dhcp_conf_suffix
     self.dhcp_service = self._get_dhcp_service(self.dhcp_server)
     self.dhcp_service_dn = self.dhcp_service['data'][0].__getitem__(0)
Example #15
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)      
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 0 #ldap.SCOPE_BASE
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.smtp_class = self.config.get('ATTR_MAP', 'smtp_class', 'aenetPostfix')
     self.smtp_domain = self.config.get('ATTR_MAP', 'smtp_domain', 'aenetPostfixDomain')
     self.retrieve_attr = [self.smtp_domain]
Example #16
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)      
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 0 #ldap.SCOPE_BASE
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.smtp_class = self.config.get('ATTR_MAP', 'smtp_class', 'aenetPostfix')
     self.smtp_domain = self.config.get('ATTR_MAP', 'smtp_domain', 'aenetPostfixDomain')
     self.retrieve_attr = [self.smtp_domain]
Example #17
0
File: dhcp.py Project: mattmb/spoke
 def __init__(self, dhcp_server, group_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_host_class = 'dhcpHost'
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix', '-config')
     self.dhcp_server = dhcp_server
     self.dhcp_group_name = group_name
     group = self._get_dhcp_group(self.dhcp_server, self.dhcp_group_name)
     self.dhcp_group_dn = group['data'][0].__getitem__(0)
Example #18
0
 def __init__(self, dhcp_server):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_subnet_class = 'dhcpSubnet'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix',
                                             '-config')
     self.dhcp_server = dhcp_server
     self.dhcp_service_name = self.dhcp_server + self.dhcp_conf_suffix
     self.dhcp_service = self._get_dhcp_service(self.dhcp_server)
     self.dhcp_service_dn = self.dhcp_service['data'][0].__getitem__(0)
Example #19
0
File: host.py Project: mattmb/spoke
 def __init__(self):    
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.search_scope = 0 #ldap.SCOPE_BASE
     self.next_uuid_attr = self.config.get('UUID','next_uuid_attr', 'aenetHostUUID')
     self.base_dn = self.config.get('LDAP','basedn')
     self.next_uuid_dn = self.config.get('UUID','next_uuid_dn', self.base_dn)
     self.next_uuid_class = self.config.get('UUID','next_uuid_class', 'aenetNextUUID')
     self.next_uuid_start = self.config.get('UUID','next_uuid_start', 1)   
     self.next_uuid = self._get_next_uuid_dn()['data']
     self.next_uuid_attrs = self.next_uuid[0].__getitem__(1)
     self.next_uuid_classes = self.next_uuid_attrs['objectClass']
     self.retrieve_attr = [self.next_uuid_attr]
     self.filter = '%s=*' % self.next_uuid_attr
Example #20
0
 def __init__(self, dhcp_server, group_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.base_dn = self.config.get('DHCP', 'dhcp_basedn')
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.dhcp_host_class = 'dhcpHost'
     self.dhcp_options_class = 'dhcpOptions'
     self.dhcp_conf_suffix = self.config.get('DHCP', 'dhcp_conf_suffix',
                                             '-config')
     self.dhcp_server = dhcp_server
     self.dhcp_group_name = group_name
     group = self._get_dhcp_group(self.dhcp_server, self.dhcp_group_name)
     self.dhcp_group_dn = group['data'][0].__getitem__(0)
Example #21
0
File: dns.py Project: mattmb/spoke
 def __init__(self, org_name, domain_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.search_scope = 2 # ldap.SUB
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.dns_cont_attr = self.config.get('DNS', 'dns_cont_attr', 'ou')
     self.dns_cont_name = self.config.get('DNS', 'dns_cont_name', 'dns')
     self.dns_cont_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
     self.dns_zone_name_attr = self.config.get('DNS', 'dns_zone_attr', 'zoneName')
     self.dns_zone_class = self.config.get('DNS', 'dns_zone_class', 'dNSZone')
     self.dns_resource_attr = self.config.get('DNS','dns_resource_attr', 'relativeDomainName')
     self.dns_record_class = self.config.get('DNS','dns_record_class', 'IN')
     self.dns_default_ttl = self.config.get('DNS', 'dns_default_ttl', '86400')
     self.dns_min_ttl = self.config.get('DNS', 'dns_min_ttl', '3600')
     self.dns_serial_start = self.config.get('DNS', 'dns_serial_start', '1')
     self.dns_slave_refresh = self.config.get('DNS','dns_slave_refresh', '3600')
     self.dns_slave_retry = self.config.get('DNS', 'dns_slave_retry', '600')
     self.dns_slave_expire = self.config.get('DNS', 'dns_slave_expire', '86400')
     self.dns_ns_attr = self.config.get('DNS', 'dns_ns_attr', 'nSRecord')
     self.dns_soa_attr = self.config.get('DNS', 'dns_soa_attr', 'sOARecord')
     self.dns_a_attr = self.config.get('DNS', 'dns_a_attr', 'aRecord')
     self.dns_cname_attr = self.config.get('DNS', 'dns_cname_attr', 'cNAMERecord')
     self.dns_mx_attr = self.config.get('DNS', 'dns_mx_attr', 'mXRecord')
     self.dns_txt_attr = self.config.get('TXT', 'dns_txt_attr', 'tXTRecord')
     self.dns_ptr_attr = self.config.get('PTR', 'dns_ptr_attr', 'pTRRecord')
     self.dns_type_attrs = {'SOA':self.dns_soa_attr,
                            'NS':self.dns_ns_attr,
                            'A':self.dns_a_attr,
                            'CNAME':self.dns_cname_attr,
                            'MX': self.dns_mx_attr,
                            'TXT': self.dns_txt_attr,
                            'PTR': self.dns_ptr_attr}
     self.domain_name = common.validate_domain(domain_name)
     self.dns_dn = '%s=%s,%s' % (self.dns_cont_attr, self.dns_cont_name, \
                                                             self.org_dn)
     self.zone_dn = '%s=%s,%s' % (self.dns_zone_name_attr, \
                                             self.domain_name, self.dns_dn)
Example #22
0
 def __init__(self, org_name, user_id):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.org_name = org_name
     self.user_id = user_id
     self.user = self._get_user(self.org_name, self.user_id)
     self.user_dn = self.user['data'][0].__getitem__(0)
     self.user_attrs = self.user['data'][0].__getitem__(1)
     self.user_classes = self.user_attrs['objectClass']
     self.svn_class = self.config.get('VCS', 'svn_class', 'aenetSubversion')
     self.svn_repo_attr = self.config.get('VCS', 'svn_repo_attr', 'aenetSubversionRepos')
     self.svn_enable_attr = self.config.get('VCS', 'svn_enable_attr', 'aenetSubversionEnabled')
     self.retrieve_attr = [self.svn_repo_attr, self.svn_enable_attr]
     self.filter = self.svn_repo_attr + '=*'
     self.search_scope = 2 # ldap.SUB
Example #23
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 2 # ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     if self.org['data'] == []:
         msg = 'Org %s not found: cannot delete children' % self.org_name
         raise error.NotFound(msg)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.container_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
Example #24
0
File: org.py Project: mattmb/spoke
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.search_scope = 2 # ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     if self.org['data'] == []:
         msg = 'Org %s not found: cannot delete children' % self.org_name
         raise error.NotFound(msg)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.container_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
Example #25
0
 def __init__(self):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 2 # ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.org_class = self.config.get('ATTR_MAP', 'org_class', 'organization')
     self.user_class = self.config.get('ATTR_MAP', 'user_class', 'aenetAccount')
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.container_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
     self.org_def_children = self.config.get('ATTR_MAP', \
                             'org_def_children', 'people,groups,dns,hosts')
     self.org_children = self.org_def_children.split(',')
     self.org_suffix_attr = self.config.get('ATTR_MAP', 'org_suffix', 'aenetAccountSuffix')
Example #26
0
File: org.py Project: mattmb/spoke
 def __init__(self):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(__name__)
     self.search_scope = 2 # ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.org_class = self.config.get('ATTR_MAP', 'org_class', 'organization')
     self.user_class = self.config.get('ATTR_MAP', 'user_class', 'aenetAccount')
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.container_class = self.config.get('ATTR_MAP', \
                                     'container_class', 'organizationalUnit')
     self.org_def_children = self.config.get('ATTR_MAP', \
                             'org_def_children', 'people,groups,dns,hosts')
     self.org_children = self.org_def_children.split(',')
     self.org_suffix_attr = self.config.get('ATTR_MAP', 'org_suffix', 'aenetAccountSuffix')
Example #27
0
File: vcs.py Project: mattmb/spoke
 def __init__(self, org_name, user_id):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     self.org_name = org_name
     self.user_id = user_id
     self.user = self._get_user(self.org_name, self.user_id)
     self.user_dn = self.user['data'][0].__getitem__(0)
     self.user_attrs = self.user['data'][0].__getitem__(1)
     self.user_classes = self.user_attrs['objectClass']
     self.svn_class = self.config.get('VCS', 'svn_class', 'aenetSubversion')
     self.svn_repo_attr = self.config.get('VCS', 'svn_repo_attr',
                                          'aenetSubversionRepos')
     self.svn_enable_attr = self.config.get('VCS', 'svn_enable_attr',
                                            'aenetSubversionEnabled')
     self.retrieve_attr = [self.svn_repo_attr, self.svn_enable_attr]
     self.filter = self.svn_repo_attr + '=*'
     self.search_scope = 2  # ldap.SUB
Example #28
0
 def __init__(self):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 0  #ldap.SCOPE_BASE
     self.next_uuid_attr = self.config.get('UUID', 'next_uuid_attr',
                                           'aenetHostUUID')
     self.base_dn = self.config.get('LDAP', 'basedn')
     self.next_uuid_dn = self.config.get('UUID', 'next_uuid_dn',
                                         self.base_dn)
     self.next_uuid_class = self.config.get('UUID', 'next_uuid_class',
                                            'aenetNextUUID')
     self.next_uuid_start = self.config.get('UUID', 'next_uuid_start', 1)
     self.next_uuid = self._get_next_uuid_dn()['data']
     self.next_uuid_attrs = self.next_uuid[0].__getitem__(1)
     self.next_uuid_classes = self.next_uuid_attrs['objectClass']
     self.retrieve_attr = [self.next_uuid_attr]
     self.filter = '%s=*' % self.next_uuid_attr
Example #29
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)     
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 2 #ldap.SCOPE_SUBTREE
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.org_attr = self.config.get('ATTR_MAP', 'org_attr', 'o')
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr', 'ou')
     self.user_login = self.config.get('ATTR_MAP', 'user_login', 'aenetAccountLoginName')
     self.user_class = self.config.get('ATTR_MAP', 'user_class', 'aenetAccount')
     self.user_key = self.config.get('ATTR_MAP', 'user_key', 'uid')
     self.user_name = self.config.get('ATTR_MAP', 'user_name', 'aenetAccountDisplayName')
     self.user_enable = self.config.get('ATTR_MAP', 'user_enable', 'aenetAccountEnabled')
     self.user_container = self.config.get('ATTR_MAP', 'user_container', 'people')
Example #30
0
 def __init__(self, org_name, user_id):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logger.setup(self.__module__)
     try:
         self.user_pwd_attr = self.config.get('ATTR_MAP', 'user_password')
     except:
         self.user_pwd_attr = 'userPassword'
     self.retrieve_attr = [self.user_pwd_attr]
     self.filter = self.user_pwd_attr + '=*'
     self.org_name = org_name
     self.user_id = user_id
     self.user = self._get_user(self.org_name, self.user_id)
     self.user_dn = self.user['data'][0].__getitem__(0)
     self.user_attrs = self.user['data'][0].__getitem__(1)
     self.user_classes = self.user_attrs['objectClass']
     self.server = self.config.get('LDAP', 'server')
     self.port = self.config.get('LDAP', 'port', '389')
     self.start_tls = self.config.get('LDAP', 'start_tls', False)
     self.search_scope = 2 # ldap.SUB
Example #31
0
 def __init__(self, org_name):
     """Get config, setup logging and LDAP connection."""
     SpokeLDAP.__init__(self)
     self.config = config.setup()
     self.log = logging.getLogger(__name__)
     self.search_scope = 2  # ldap.SUB
     self.retrieve_attr = None
     self.org_name = org_name
     self.org = self._get_org(self.org_name)
     self.org_dn = self.org['data'][0].__getitem__(0)
     self.org_attrs = self.org['data'][0].__getitem__(1)
     self.org_classes = self.org_attrs['objectClass']
     self.container_attr = self.config.get('ATTR_MAP', 'container_attr',
                                           'ou')
     self.host_container = self.config.get('HOST', 'host_container',
                                           'hosts')
     self.host_container_dn = '%s=%s,%s' % (self.container_attr, \
                                         self.host_container, self.org_dn)
     self.host_class = self.config.get('HOST', 'host_class', 'aenetHost')
     self.host_key = self.config.get('HOST', 'host_key', 'cn')
     self.host_uuid_attr = self.config.get('HOST', 'host_uuid_attr',
                                           'aenetHostUUID')
     self.host_name_attr = self.config.get('HOST', 'host_name_attr',
                                           'aenetHostName')
     self.host_cpu_attr = self.config.get('HOST', 'host_cpu_attr',
                                          'aenetHostCPU')
     self.host_mem_attr = self.config.get('HOST', 'host_mem_attr',
                                          'aenetHostMem')
     self.host_extra_opts_attr = self.config.get('HOST',
                                                 'host_extra_opts_attr',
                                                 'aenetHostExtraOpts')
     self.host_family_attr = self.config.get('HOST', 'host_family_attr',
                                             'aenetHostFamily')
     self.host_network_layout_attr = self.config.get(
         'HOST', 'host_network_layout_attr', 'aenetHostNetworkLayout')
     self.host_storage_layout_attr = self.config.get(
         'HOST', 'host_storage_layout_attr', 'aenetHostStorageLayout')
     self.host_type_attr = self.config.get('HOST', 'host_type_attr',
                                           'aenetHostType')