diff --git a/seed/base-machine/dictionaries/12-base.xml b/seed/base-machine/dictionaries/12-base.xml index 168801c2..f2dbdf3e 100644 --- a/seed/base-machine/dictionaries/12-base.xml +++ b/seed/base-machine/dictionaries/12-base.xml @@ -10,39 +10,25 @@ False - - - zones_name - zones_list - - - zones_name - interfaces_list - - server_name + domain_name_eth ip_eth - - - server_name - extra_domainnames - - domain_name_eth - - zones_name + zones_list zone_name_eth diff --git a/seed/base-machine/funcs/funcs.py b/seed/base-machine/funcs/funcs.py index 848abfaf..8e67ffdc 100644 --- a/seed/base-machine/funcs/funcs.py +++ b/seed/base-machine/funcs/funcs.py @@ -6,7 +6,7 @@ from os.path import dirname as _dirname, abspath as _abspath, join as _join, isf from os import makedirs as _makedirs -from risotto.utils import ZONES_SERVER +#from risotto.utils import ZONES_SERVER _HERE = _dirname(_abspath(__main__.__file__)) @@ -81,30 +81,8 @@ def _set_password(server_name: str, return file_content -def get_range(lst): - return list(range(max(1, len(lst)))) - - def get_zone_name(zones: list, index: str, ): if zones is not None: return zones[int(index)] - - -def get_domain_name(server_name: str, - extra_domainnames: list, - suffix: str, - ) -> str: - index = int(suffix) - if index == 0: - return server_name - return extra_domainnames[index - 1] - - -def get_provider_name(network_name: str, - provider: str, - ) -> str: - if network_name not in ZONES_SERVER['providers'] or provider not in ZONES_SERVER['providers'][network_name]: - return - return ZONES_SERVER['providers'][network_name][provider][0] diff --git a/seed/base/funcs/base.py b/seed/base/funcs/base.py index 10a4031f..6e3dde36 100644 --- a/seed/base/funcs/base.py +++ b/seed/base/funcs/base.py @@ -1,9 +1,26 @@ from typing import List from risotto.utils import load_domains, DOMAINS +from risotto.utils import multi_function as _multi_function +@_multi_function def get_ip(server_name: str) -> str: - load_domains() - host_name, domain_name = server_name.split('.', 1) - domain = DOMAINS[domain_name] - return domain[1][domain[0].index(host_name)] + if server_name is None: + return + if isinstance(server_name, list): + return_list = True + else: + return_list = False + server_name = [server_name] + lst = [] + for s_name in server_name: + host_name, domain_name = s_name.split('.', 1) + if not domain_name in DOMAINS: + raise ValueError(f'cannot find IP in domain name "{domain_name}" (for "{s_name}")') + domain = DOMAINS[domain_name] + ret = domain[1][domain[0].index(host_name)] + if not return_list: + return ret + if ret not in lst: + lst.append(ret) + return lst diff --git a/seed/dns-external/dictionaries/14-dns-external.xml b/seed/dns-external/dictionaries/14-dns-external.xml index 9cdb18b2..06f3b086 100644 --- a/seed/dns-external/dictionaries/14-dns-external.xml +++ b/seed/dns-external/dictionaries/14-dns-external.xml @@ -5,14 +5,7 @@ False - + - - - zone_name_eth0 - ExternalDNS - dns_client_address - - diff --git a/seed/dns-local/dictionaries/13-dns-local.xml b/seed/dns-local/dictionaries/13-dns-local.xml index 129bfc85..fb58cb48 100644 --- a/seed/dns-local/dictionaries/13-dns-local.xml +++ b/seed/dns-local/dictionaries/13-dns-local.xml @@ -10,21 +10,13 @@ - + diff --git a/seed/ldap-client/funcs/openldap_client.py b/seed/ldap-client/funcs/openldap_client.py index 59789164..e67591b7 100644 --- a/seed/ldap-client/funcs/openldap_client.py +++ b/seed/ldap-client/funcs/openldap_client.py @@ -11,6 +11,8 @@ def calc_ldapclient_base_dn(ldap_base_dn: str, base: bool=False, group: bool=False, ) -> str: + if ldap_base_dn is None: + return if family_name == 'all': family_name = None base = True @@ -28,3 +30,23 @@ def calc_ldapclient_base_dn(ldap_base_dn: str, if family_name != '-': base_name = f'ou={family_name},{base_name}' return base_name + + +class _Undefined: + pass + + +_undefined = _Undefined() + + +def get_default_base_dn(server_name: str) -> str: + if not server_name or '.' not in server_name: + return None + values = server_name.split('.') + # cannot calculated base dn should be server.domain.tld + # remove 'server' in dn + if len(values) < 3: + return None + domain = ['ou=' + domain for domain in values[1:-2]] + domain.append(f'o={values[-2]},o={values[-1]}') + return ','.join(domain) diff --git a/seed/ldap-client/templates/ldap.conf b/seed/ldap-client/templates/ldap.conf index 7c40a7f5..3a65745d 100644 --- a/seed/ldap-client/templates/ldap.conf +++ b/seed/ldap-client/templates/ldap.conf @@ -6,7 +6,7 @@ # This file should be world readable but not world writable. #BASE dc=example,dc=com -BASE %%ldapclient_base_dn +BASE %%ldapclient_search_dn #URI ldap://ldap.example.com ldap://ldap-master.example.com:666 URI ldaps://%%ldap_server_address:%%ldap_port diff --git a/seed/lemonldap/applicationservice.yml b/seed/lemonldap/applicationservice.yml index f715b6a0..723261ea 100644 --- a/seed/lemonldap/applicationservice.yml +++ b/seed/lemonldap/applicationservice.yml @@ -6,4 +6,3 @@ depends: - reverse-proxy-client - relay-mail-client - nginx-common -provider: OAuth2 diff --git a/seed/lemonldap/dictionaries/70_lemonldap_ng.xml b/seed/lemonldap/dictionaries/70_lemonldap_ng.xml index bf229ac1..37b7de86 100644 --- a/seed/lemonldap/dictionaries/70_lemonldap_ng.xml +++ b/seed/lemonldap/dictionaries/70_lemonldap_ng.xml @@ -28,6 +28,7 @@ False +