def run(self, shorthostname, domain, **options): """ Implemented as frontend command (ie no forward/execute) """ hostname = unicode("%s.%s" % (shorthostname, domain)) self.log.debug('AII called with hostname %s (options %s)' % (hostname, options)) ip = options.get('ip', None) res = {} # first try to disable (e.g. in case --install=1 --disable=1 is passed) if options.get('disable', False): self.log.debug('Going to disable') res.update(self.disable_host(hostname)) # check for install if options.get('install', False): self.log.debug('Going to install') if ip is not None: self.log.debug('Adding ip %s for hostname %s' % (ip, hostname)) add_records_for_host(shorthostname, domain, [ip]) # do not print/log res, it contains a password res.update(self.aii_install(hostname)) # always return like this return dict(result=res)
def run(self, shorthostname, domain, **options): """ Implemented as frontend command (ie no forward/execute) """ hostname = unicode("%s.%s" % (shorthostname, domain)) self.log.debug('AII called with hostname %s (options %s)' % (hostname, options)) ip = options.get('ip', None) res = {} # first try to disable (e.g. in case --install=1 --disable=1 is passed) if options.get('disable', False): self.log.debug('Going to disable') res.update(self.disable_host(hostname)) # check for install if options.get('install', False): self.log.debug('Going to install') if ip is not None: self.log.debug('Adding ip %s for hostname %s' % (ip, hostname)) add_records_for_host(shorthostname, domain, [ip]) # do not print/log res, it contains a password res.update(self.aii_install(hostname)) # always return like this return dict(result=res)
def post_callback(self, ldap, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) exc = None if dns_container_exists(ldap): try: parts = keys[-1].split('.') host = parts[0] domain = unicode('.'.join(parts[1:])) if options.get('ip_address'): add_reverse = not options.get('no_reverse', False) add_records_for_host(DNSName(host), DNSName(domain).make_absolute(), options['ip_address'], add_forward=True, add_reverse=add_reverse) del options['ip_address'] update_sshfp_record(domain, unicode(parts[0]), entry_attrs) except Exception as e: exc = e if options.get('random', False): try: entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword')) except AttributeError: # On the off-chance some other extension deletes this from the # context, don't crash. pass if exc: raise errors.NonFatalError( reason=_('The host was added but the DNS update failed with: %(exc)s') % dict(exc=exc) ) set_certificate_attrs(entry_attrs) set_kerberos_attrs(entry_attrs, options) rename_ipaallowedtoperform_from_ldap(entry_attrs, options) if options.get('all', False): entry_attrs['managing'] = self.obj.get_managed_hosts(dn) self.obj.get_password_attributes(ldap, dn, entry_attrs) if entry_attrs['has_password']: # If an OTP is set there is no keytab, at least not one # fetched anywhere. entry_attrs['has_keytab'] = False convert_sshpubkey_post(ldap, dn, entry_attrs) return dn
def post_callback(self, ldap, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) exc = None if dns_container_exists(ldap): try: parts = keys[-1].split('.') host = parts[0] domain = unicode('.'.join(parts[1:])) if options.get('ip_address'): add_reverse = not options.get('no_reverse', False) add_records_for_host(DNSName(host), DNSName(domain).make_absolute(), options['ip_address'], add_forward=True, add_reverse=add_reverse) del options['ip_address'] update_sshfp_record(domain, unicode(parts[0]), entry_attrs) except Exception as e: exc = e if options.get('random', False): try: entry_attrs['randompassword'] = unicode(getattr(context, 'randompassword')) except AttributeError: # On the off-chance some other extension deletes this from the # context, don't crash. pass if exc: raise errors.NonFatalError( reason=_('The host was added but the DNS update failed with: %(exc)s') % dict(exc=exc) ) set_certificate_attrs(entry_attrs) set_kerberos_attrs(entry_attrs, options) rename_ipaallowedtoperform_from_ldap(entry_attrs, options) if options.get('all', False): entry_attrs['managing'] = self.obj.get_managed_hosts(dn) self.obj.get_password_attributes(ldap, dn, entry_attrs) if entry_attrs['has_password']: # If an OTP is set there is no keytab, at least not one # fetched anywhere. entry_attrs['has_keytab'] = False convert_sshpubkey_post(ldap, dn, entry_attrs) return dn
def post_callback(self, ldap, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) exc = None if dns_container_exists(ldap): try: parts = keys[-1].split('.') host = parts[0] domain = unicode('.'.join(parts[1:])) if options.get('ip_address'): add_reverse = not options.get('no_reverse', False) add_records_for_host(host, domain, options['ip_address'], add_forward=True, add_reverse=add_reverse) del options['ip_address'] update_sshfp_record(domain, unicode(parts[0]), entry_attrs) except Exception, e: exc = e
def post_callback(self, ldap, dn, entry_attrs, *keys, **options): assert isinstance(dn, DN) exc = None if dns_container_exists(ldap): try: parts = keys[-1].split('.') host = parts[0] domain = unicode('.'.join(parts[1:])) if options.get('ip_address'): add_reverse = not options.get('no_reverse', False) add_records_for_host(host, domain, options['ip_address'], add_forward=True, add_reverse=add_reverse) del options['ip_address'] update_sshfp_record(domain, unicode(parts[0]), entry_attrs) except Exception, e: exc = e