def find_by_name(self, name): # Will result in a number of queries, but it is not expected # that find_by_name will be used in performance-intesive # queries. dns = DnsOwner(self._db) dns.find_by_name(name) self.find_by_dns_owner_id(dns.entity_id)
def find_by_name(self, name): # Will result in a number of queries, but it is not expected # that find_by_name will be used in performance-intesive # queries. dns = DnsOwner(self._db) dns.find_by_name(name) self.find_by_dns_owner_id(dns.entity_id)
def add_cname_record(db, cname_record_name, target_name, fail_on_exists=True): """ Creates a CNAME-record. If fail_on_exists=False, it will simply return without doing anything, if the CNAME-record already exists. This is due to the method being used by OU._setup_project_hosts, which can be run several times for the same project when it is reconfigured. :param db: A Cerebrum-database instance :type db: Cerebrum.database.Database :param cname_record_name: FQDN of the CNAME-record :type cname_record_name: str :param target_name: FQDN of the target domain :type target_name: str :param fail_on_exists: True or False :type fail_on_exists: bool """ cname = CNameRecord(db) dns_owner = DnsOwner(db) constants = Factory.get('Constants') try: dns_owner.find_by_name(target_name) proxy_dns_owner_ref = dns_owner.entity_id except Errors.NotFoundError: raise Errors.NotFoundError('%s does not exist.' % target_name) dns_owner.clear() try: dns_owner.find_by_name(cname_record_name) except Errors.NotFoundError: dns_owner.populate(constants.DnsZone(cereconf.DNS_DEFAULT_ZONE), cname_record_name) dns_owner.write_db() cname_dns_owner_ref = dns_owner.entity_id try: cname.find_by_cname_owner_id(cname_dns_owner_ref) if fail_on_exists: raise Errors.RealityError('CNAME %s already exists.' % cname_record_name) except Errors.NotFoundError: cname.populate(cname_dns_owner_ref, proxy_dns_owner_ref) cname.write_db()
def add_cname_record(db, cname_record_name, target_name, fail_on_exists=True): """ Creates a CNAME-record. If fail_on_exists=False, it will simply return without doing anything, if the CNAME-record already exists. This is due to the method being used by OU._setup_project_hosts, which can be run several times for the same project when it is reconfigured. :param db: A Cerebrum-database instance :type db: Cerebrum.Database :param cname_record_name: FQDN of the CNAME-record :type cname_record_name: str :param target_name: FQDN of the target domain :type target_name: str :param fail_on_exists: True or False :type fail_on_exists: bool """ cname = CNameRecord(db) dns_owner = DnsOwner(db) constants = Factory.get('Constants') try: dns_owner.find_by_name(target_name) proxy_dns_owner_ref = dns_owner.entity_id except Errors.NotFoundError: raise Errors.NotFoundError('%s does not exist.' % target_name) dns_owner.clear() try: dns_owner.find_by_name(cname_record_name) except Errors.NotFoundError: dns_owner.populate(constants.DnsZone(cereconf.DNS_DEFAULT_ZONE), cname_record_name) dns_owner.write_db() cname_dns_owner_ref = dns_owner.entity_id try: cname.find_by_cname_owner_id(cname_dns_owner_ref) if fail_on_exists: raise Errors.RealityError('CNAME %s already exists.' % cname_record_name) except Errors.NotFoundError: cname.populate(cname_dns_owner_ref, proxy_dns_owner_ref) cname.write_db()
def find_by_name(self, name): dns = DnsOwner(self._db) dns.find_by_name(name) self.find_by_cname_owner_id(dns.entity_id)
def find_by_name(self, name): dns = DnsOwner(self._db) dns.find_by_name(name) self.find_by_cname_owner_id(dns.entity_id)