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(self, host_id): self.__super.find(host_id) (self.dns_owner_id, self.ttl, self.hinfo) = self.query_1(""" SELECT dns_owner_id, ttl, hinfo FROM [:table schema=cerebrum name=dns_host_info] WHERE host_id=:host_id""", {'host_id' : host_id}) dns = DnsOwner(self._db) dns.find(self.dns_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
def find(self, cname_id): self.__super.find(cname_id) (self.cname_owner_id, self.ttl, self.target_owner_id ) = self.query_1(""" SELECT cname_owner_id, ttl, target_owner_id FROM [:table schema=cerebrum name=dns_cname_record] WHERE cname_id=:cname_id""", {'cname_id' : cname_id}) dns = DnsOwner(self._db) dns.find(self.cname_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
def find(self, cname_id): self.__super.find(cname_id) (self.cname_owner_id, self.ttl, self.target_owner_id) = self.query_1( """ SELECT cname_owner_id, ttl, target_owner_id FROM [:table schema=cerebrum name=dns_cname_record] WHERE cname_id=:cname_id""", {'cname_id': cname_id}) dns = DnsOwner(self._db) dns.find(self.cname_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
def find(self, aaaa_record_id): self.__super.find(aaaa_record_id) (self.ipv6_number_id, self.ttl, self.mac, self.dns_owner_id ) = self.query_1(""" SELECT ipv6_number_id, ttl, mac, dns_owner_id FROM [:table schema=cerebrum name=dns_aaaa_record] WHERE aaaa_record_id=:aaaa_record_id""", {'aaaa_record_id' : aaaa_record_id}) dns = DnsOwner(self._db) dns.find(self.dns_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
def find(self, host_id): self.__super.find(host_id) (self.dns_owner_id, self.ttl, self.hinfo) = self.query_1( """ SELECT dns_owner_id, ttl, hinfo FROM [:table schema=cerebrum name=dns_host_info] WHERE host_id=:host_id""", {'host_id': host_id}) dns = DnsOwner(self._db) dns.find(self.dns_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
def find(self, a_record_id): self.__super.find(a_record_id) (self.ip_number_id, self.ttl, self.mac, self.dns_owner_id) = self.query_1( """ SELECT ip_number_id, ttl, mac, dns_owner_id FROM [:table schema=cerebrum name=dns_a_record] WHERE a_record_id=:a_record_id""", {'a_record_id': a_record_id}) dns = DnsOwner(self._db) dns.find(self.dns_owner_id) self.name = dns.name try: del self.__in_db except AttributeError: pass self.__in_db = True self.__updated = []
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 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()