diff options
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/cert.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/host.py | 8 | ||||
-rw-r--r-- | ipalib/plugins/service.py | 20 |
3 files changed, 14 insertions, 16 deletions
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py index ed1d65ad2..8920cfe4f 100644 --- a/ipalib/plugins/cert.py +++ b/ipalib/plugins/cert.py @@ -269,7 +269,7 @@ class cert_request(VirtualCommand): if not add: raise errors.NotFound(reason="The service principal for this request doesn't exist.") try: - service = api.Command['service_add'](principal, **{})['result'] + service = api.Command['service_add'](principal, **{'force': True})['result'] dn = service['dn'] except errors.ACIError: raise errors.ACIError(info='You need to be a member of the serviceadmin role to add services') diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index b42cbbcb7..78d4d5a02 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -84,7 +84,6 @@ def validate_host(ugettext, fqdn): return _('Fully-qualified hostname required') return None - class host(LDAPObject): """ Host object. @@ -196,8 +195,15 @@ class host_add(LDAPCreate): """ msg_summary = _('Added host "%(value)s"') + takes_options = ( + Flag('force', + doc=_('force host name even if not in DNS'), + ), + ) def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): + if not options.get('force', False): + util.validate_host_dns(self.log, keys[-1]) if 'locality' in entry_attrs: entry_attrs['l'] = entry_attrs['locality'] del entry_attrs['locality'] diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index 392ae60eb..ac949b788 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -60,7 +60,7 @@ EXAMPLES: """ import base64 -from ipalib import api, errors +from ipalib import api, errors, util from ipalib import Str, Flag, Bytes from ipalib.plugins.baseldap import * from ipalib import x509 @@ -183,19 +183,11 @@ class service_add(LDAPCreate): entry_attrs['usercertificate'] = base64.b64decode(cert) # FIXME: shouldn't we request signing at this point? - # TODO: once DNS client is done (code below for reference only!) - # if not kw['force']: - # fqdn = hostname + '.' - # rs = dnsclient.query(fqdn, dnsclient.DNS_C_IN, dnsclient.DNS_T_A) - # if len(rs) == 0: - # self.log.debug( - # 'IPA: DNS A record lookup failed for '%s'" % hostname - # ) - # raise ipaerror.gen_exception(ipaerror.INPUT_NOT_DNS_A_RECORD) - # else: - # self.log.debug( - # 'IPA: found %d records for '%s'" % (len(rs), hostname) - # ) + if not options.get('force', False): + # We know the host exists if we've gotten this far but we + # really want to discourage creating services for hosts that + # don't exist in DNS. + util.validate_host_dns(self.log, hostname) return dn |