mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add a proper _get_parent_domain
This commit is contained in:
parent
c44560b6f7
commit
b8cb374a49
2 changed files with 29 additions and 12 deletions
|
@ -40,6 +40,8 @@ from yunohost.domain import (
|
|||
domain_config_get,
|
||||
_get_domain_settings,
|
||||
_set_domain_settings,
|
||||
_get_parent_domain_of,
|
||||
_list_subdomains_of,
|
||||
)
|
||||
from yunohost.utils.dns import dig, is_yunohost_dyndns_domain, is_special_use_tld
|
||||
from yunohost.utils.error import YunohostValidationError, YunohostError
|
||||
|
@ -107,18 +109,6 @@ def domain_dns_suggest(domain):
|
|||
return result
|
||||
|
||||
|
||||
def _list_subdomains_of(parent_domain):
|
||||
|
||||
_assert_domain_exists(parent_domain)
|
||||
|
||||
out = []
|
||||
for domain in domain_list()["domains"]:
|
||||
if domain.endswith(f".{parent_domain}"):
|
||||
out.append(domain)
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def _build_dns_conf(base_domain, include_empty_AAAA_if_no_ipv6=False):
|
||||
"""
|
||||
Internal function that will returns a data structure containing the needed
|
||||
|
|
|
@ -105,6 +105,33 @@ def _assert_domain_exists(domain):
|
|||
raise YunohostValidationError("domain_name_unknown", domain=domain)
|
||||
|
||||
|
||||
def _list_subdomains_of(parent_domain):
|
||||
|
||||
_assert_domain_exists(parent_domain)
|
||||
|
||||
out = []
|
||||
for domain in domain_list()["domains"]:
|
||||
if domain.endswith(f".{parent_domain}"):
|
||||
out.append(domain)
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def _get_parent_domain_of(domain):
|
||||
|
||||
_assert_domain_exists(domain)
|
||||
|
||||
if "." not in domain:
|
||||
return domain
|
||||
|
||||
parent_domain = domain.split(".", 1)[-1]
|
||||
if parent_domain not in domain_list()["domains"]:
|
||||
return domain # Domain is its own parent
|
||||
|
||||
else:
|
||||
return _get_parent_domain_of(parent_domain)
|
||||
|
||||
|
||||
@is_unit_operation()
|
||||
def domain_add(operation_logger, domain, dyndns=False):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue