summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2015-09-03 12:40:17 +0200
committerMartin Basti <mbasti@redhat.com>2015-10-12 13:34:20 +0200
commitfc6e1f0bb5e09c1c7036a0cebdb54905f34b1fb9 (patch)
treefa1b4c85ec72565ee68492b71a2b0e451f0910ed
parent4ceae037f5f756b0e690f8ec6e4729b42d2393b1 (diff)
downloadfreeipa-fc6e1f0bb5e09c1c7036a0cebdb54905f34b1fb9.tar.gz
freeipa-fc6e1f0bb5e09c1c7036a0cebdb54905f34b1fb9.tar.xz
freeipa-fc6e1f0bb5e09c1c7036a0cebdb54905f34b1fb9.zip
realmdomains: Minor style and wording improvements
https://fedorahosted.org/freeipa/ticket/5278 Reviewed-By: Martin Basti <mbasti@redhat.com>
-rw-r--r--ipalib/plugins/realmdomains.py75
1 files changed, 60 insertions, 15 deletions
diff --git a/ipalib/plugins/realmdomains.py b/ipalib/plugins/realmdomains.py
index f8f838d0e..27c4fa228 100644
--- a/ipalib/plugins/realmdomains.py
+++ b/ipalib/plugins/realmdomains.py
@@ -137,16 +137,46 @@ class realmdomains_mod(LDAPUpdate):
del_domain = entry_attrs.get('del_domain')
force = options.get('force')
+ current_domain = get_domain_name()
+
+ missing_soa_ns_record_error = _(
+ "DNS zone for each realmdomain must contain "
+ "SOA or NS records. No records found for: %s"
+ )
+
+ # User specified the list of domains explicitly
if associateddomain:
if add_domain or del_domain:
- raise errors.MutuallyExclusiveError(reason=_("you cannot specify the --domain option together with --add-domain or --del-domain"))
- if get_domain_name() not in associateddomain:
- raise errors.ValidationError(name='domain', error=_("cannot delete domain of IPA server"))
+ raise errors.MutuallyExclusiveError(
+ reason=_(
+ "The --domain option cannot be used together "
+ "with --add-domain or --del-domain. Use --domain "
+ "to specify the whole realm domain list explicitly, "
+ "to add/remove individual domains, use "
+ "--add-domain/del-domain.")
+ )
+
+ # Make sure our domain is included in the list
+ if current_domain not in associateddomain:
+ raise errors.ValidationError(
+ name='realmdomain list',
+ error=_("IPA server domain cannot be omitted")
+ )
+
+ # Unless forced, check that each domain has SOA or NS records
if not force:
- bad_domains = [d for d in associateddomain if not has_soa_or_ns_record(d)]
+ bad_domains = [
+ d for d in associateddomain
+ if not has_soa_or_ns_record(d)
+ ]
+
if bad_domains:
bad_domains = ', '.join(bad_domains)
- raise errors.ValidationError(name='domain', error=_("no SOA or NS records found for domains: %s" % bad_domains))
+ raise errors.ValidationError(
+ name='domain',
+ error=missing_soa_ns_record_error % bad_domains
+ )
+
return dn
# If --add-domain or --del-domain options were provided, read
@@ -155,18 +185,29 @@ class realmdomains_mod(LDAPUpdate):
if add_domain:
if not force and not has_soa_or_ns_record(add_domain):
- raise errors.ValidationError(name='add_domain', error=_("no SOA or NS records found for domain %s" % add_domain))
+ raise errors.ValidationError(
+ name='add_domain',
+ error=missing_soa_ns_record_error % add_domain
+ )
+
del entry_attrs['add_domain']
domains.append(add_domain)
if del_domain:
- if del_domain == get_domain_name():
- raise errors.ValidationError(name='del_domain', error=_("cannot delete domain of IPA server"))
+ if del_domain == current_domain:
+ raise errors.ValidationError(
+ name='del_domain',
+ error=_("IPA server domain cannot be deleted")
+ )
del entry_attrs['del_domain']
+
try:
domains.remove(del_domain)
except ValueError:
- raise errors.AttrValueNotFound(attr='associateddomain', value=del_domain)
+ raise errors.AttrValueNotFound(
+ attr='associateddomain',
+ value=del_domain
+ )
entry_attrs['associateddomain'] = domains
return dn
@@ -184,13 +225,15 @@ class realmdomains_mod(LDAPUpdate):
# Add a _kerberos TXT record for zones that correspond with
# domains which were added
- for d in domains_added:
+ for domain in domains_added:
+
# Skip our own domain
- if d == api.env.domain:
+ if domain == api.env.domain:
continue
+
try:
api.Command['dnsrecord_add'](
- unicode(d),
+ unicode(domain),
u'_kerberos',
txtrecord=api.env.realm
)
@@ -199,13 +242,15 @@ class realmdomains_mod(LDAPUpdate):
# Delete _kerberos TXT record from zones that correspond with
# domains which were deleted
- for d in domains_deleted:
+ for domain in domains_deleted:
+
# Skip our own domain
- if d == api.env.domain:
+ if domain == api.env.domain:
continue
+
try:
api.Command['dnsrecord_del'](
- unicode(d),
+ unicode(domain),
u'_kerberos',
txtrecord=api.env.realm
)