def add_dns_records(self):
        options = self.options

        logger.info("Adding DNS records for %s", self.replica_fqdn)
        name, domain = self.replica_fqdn.split(".", 1)

        for reverse_zone in options.reverse_zones:
            logger.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError as e:
                raise admintool.ScriptError(
                    "Could not add A/AAAA DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                if reverse_zone is None:
                    logger.warning(
                        "Could not find any IPA managed reverse zone. "
                        "Not creating PTR records")
                    return
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError as e:
                    raise admintool.ScriptError(
                        "Could not add PTR DNS record for the replica: %s" % e)
Exemple #2
0
def install_dns_records(config, options, remote_api):

    if not bindinstance.dns_container_exists(
            config.master_host_name,
            ipautil.realm_to_suffix(config.realm_name),
            dm_password=config.dirman_password):
        return

    try:
        bind = bindinstance.BindInstance(dm_password=config.dirman_password,
                                         api=remote_api)
        for ip in config.ips:
            reverse_zone = bindinstance.find_reverse_zone(ip, remote_api)

            bind.add_master_dns_records(config.host_name,
                                        str(ip),
                                        config.realm_name,
                                        config.domain_name,
                                        reverse_zone,
                                        not options.no_ntp,
                                        options.setup_ca)
    except errors.NotFound as e:
        root_logger.debug('Replica DNS records could not be added '
                          'on master: %s', str(e))

    # we should not fail here no matter what
    except Exception as e:
        root_logger.info('Replica DNS records could not be added '
                         'on master: %s', str(e))
    def add_dns_records(self):
        options = self.options

        self.log.info("Adding DNS records for %s", self.replica_fqdn)
        name, domain = self.replica_fqdn.split(".", 1)

        if not api.Backend.ldap2.isconnected():
            api.Backend.ldap2.connect(
                bind_dn=DN(('cn', 'Directory Manager')),
                bind_pw=self.dirman_password)

        for reverse_zone in options.reverse_zones:
            self.log.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError as e:
                raise admintool.ScriptError(
                    "Could not add A/AAAA DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError as e:
                    raise admintool.ScriptError(
                        "Could not add PTR DNS record for the replica: %s"
                        % e)
    def add_dns_records(self):
        options = self.options

        logger.info("Adding DNS records for %s", self.replica_fqdn)
        name, domain = self.replica_fqdn.split(".", 1)

        for reverse_zone in options.reverse_zones:
            logger.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError as e:
                raise admintool.ScriptError(
                    "Could not add A/AAAA DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                if reverse_zone is None:
                    logger.warning(
                        "Could not find any IPA managed reverse zone. "
                        "Not creating PTR records")
                    return
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError as e:
                    raise admintool.ScriptError(
                        "Could not add PTR DNS record for the replica: %s"
                        % e)
    def add_dns_records(self):
        options = self.options

        self.log.info("Adding DNS records for %s", self.replica_fqdn)
        name, domain = self.replica_fqdn.split(".", 1)

        if not api.Backend.ldap2.isconnected():
            api.Backend.ldap2.connect(bind_dn=DN(('cn', 'Directory Manager')),
                                      bind_pw=self.dirman_password)

        for reverse_zone in options.reverse_zones:
            self.log.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError as e:
                raise admintool.ScriptError(
                    "Could not add A/AAAA DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                if reverse_zone is None:
                    self.log.warning(
                        "Could not find any IPA managed reverse zone. "
                        "Not creating PTR records")
                    return
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError as e:
                    raise admintool.ScriptError(
                        "Could not add PTR DNS record for the replica: %s" % e)
    def add_dns_records(self):
        options = self.options

        self.log.info("Adding DNS records for %s", self.replica_fqdn)
        api.Backend.ldap2.connect(
            bind_dn=DN(('cn', 'Directory Manager')),
            bind_pw=self.dirman_password)

        name, domain = self.replica_fqdn.split(".", 1)

        ip = options.ip_address
        ip_address = str(ip)

        if options.reverse_zone:
            reverse_zone = bindinstance.normalize_zone(options.reverse_zone)
        else:
            reverse_zone = bindinstance.find_reverse_zone(ip)
            if reverse_zone is None and not options.no_reverse:
                reverse_zone = bindinstance.get_reverse_zone_default(ip)

        try:
            add_zone(domain)
        except errors.PublicError, e:
            raise admintool.ScriptError(
                "Could not create forward DNS zone for the replica: %s" % e)
Exemple #7
0
def install_dns_records(config, options, remote_api, fstore=None):

    if not bindinstance.dns_container_exists(
            ipautil.realm_to_suffix(config.realm_name)):
        return

    try:
        bind = bindinstance.BindInstance(api=remote_api, fstore=fstore)
        for ip in config.ips:
            reverse_zone = bindinstance.find_reverse_zone(ip, remote_api)

            bind.add_master_dns_records(config.host_name, str(ip),
                                        config.realm_name, config.domain_name,
                                        reverse_zone)
    except errors.NotFound as e:
        logger.debug('Replica DNS records could not be added '
                     'on master: %s', str(e))

    # we should not fail here no matter what
    except Exception as e:
        logger.info('Replica DNS records could not be added '
                    'on master: %s', str(e))
Exemple #8
0
def install_dns_records(config, options, remote_api, fstore=None):

    if not bindinstance.dns_container_exists(
            ipautil.realm_to_suffix(config.realm_name)):
        return

    try:
        bind = bindinstance.BindInstance(api=remote_api, fstore=fstore)
        for ip in config.ips:
            reverse_zone = bindinstance.find_reverse_zone(ip, remote_api)

            bind.add_master_dns_records(config.host_name,
                                        [str(ip)],
                                        config.realm_name,
                                        config.domain_name,
                                        reverse_zone)
    except errors.NotFound as e:
        logger.debug('Replica DNS records could not be added '
                     'on master: %s', str(e))

    # we should not fail here no matter what
    except Exception as e:
        logger.info('Replica DNS records could not be added '
                    'on master: %s', str(e))
                "Could not create forward DNS zone for the replica: %s" % e)

        for reverse_zone in options.reverse_zones:
            self.log.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError, e:
                raise admintool.ScriptError(
                    "Could not add forward DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError, e:
                    raise admintool.ScriptError(
                        "Could not add reverse DNS record for the replica: %s"
                        % e)

    def check_dns(self, replica_fqdn):
        """Return true if the replica hostname is resolvable"""
        resolver = dns.resolver.Resolver()
        exceptions = (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer,
                      dns.resolver.Timeout, dns.resolver.NoNameservers)

        try:
            dns_answer = resolver.query(replica_fqdn, 'A', 'IN')
Exemple #10
0
                "Could not create forward DNS zone for the replica: %s" % e)

        for reverse_zone in options.reverse_zones:
            self.log.info("Adding reverse zone %s", reverse_zone)
            add_zone(reverse_zone)

        for ip in options.ip_addresses:
            ip_address = str(ip)
            try:
                add_fwd_rr(domain, name, ip_address)
            except errors.PublicError, e:
                raise admintool.ScriptError(
                    "Could not add forward DNS record for the replica: %s" % e)

            if not options.no_reverse:
                reverse_zone = bindinstance.find_reverse_zone(ip)
                try:
                    add_ptr_rr(reverse_zone, ip_address, self.replica_fqdn)
                except errors.PublicError, e:
                    raise admintool.ScriptError(
                        "Could not add reverse DNS record for the replica: %s"
                        % e)

    def check_dns(self, replica_fqdn):
        """Return true if the replica hostname is resolvable"""
        resolver = dns.resolver.Resolver()
        exceptions = (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer,
                      dns.resolver.Timeout, dns.resolver.NoNameservers)

        try:
            dns_answer = resolver.query(replica_fqdn, 'A', 'IN')