def __init__(self, application, tenant_id=None, user_id=None): super(TestContextMiddleware, self).__init__(application) LOG.critical(_LC('Starting designate testcontext middleware')) LOG.critical(_LC('**** DO NOT USE IN PRODUCTION ****')) self.default_tenant_id = tenant_id self.default_user_id = user_id
def delete_record(self, context, domain, recordset, record): try: record_m = self._get_record(record['id']) except exceptions.RecordNotFound: # If the Record is already gone, that's ok. We're deleting it # anyway, so just log and continue. LOG.critical(_LC('Attempted to delete a record which is ' 'not present in the backend. ID: %s') % record['id']) else: record_m.delete(self.session) self._update_soa(domain)
def delete_tsigkey(self, context, tsigkey): """Delete a TSIG Key""" try: # Delete this TSIG Key itself tsigkey_m = self._get_tsigkey(tsigkey['id']) tsigkey_m.delete(self.session) except exceptions.TsigKeyNotFound: # If the TSIG Key is already gone, that's ok. We're deleting it # anyway, so just log and continue. LOG.critical(_LC('Attempted to delete a TSIG key which is ' 'not present in the backend. ID: %s') % tsigkey['id']) return # Delete this TSIG Key from every domain's metadata self.session.query(models.DomainMetadata)\ .filter_by(kind='TSIG-ALLOW-AXFR', content=tsigkey['name'])\ .delete()
def delete_domain(self, context, domain): try: domain_m = self._get_domain(domain['id']) except exceptions.DomainNotFound: # If the Domain is already gone, that's ok. We're deleting it # anyway, so just log and continue. LOG.critical(_LC('Attempted to delete a domain which is ' 'not present in the backend. ID: %s') % domain['id']) return domain_m.delete(self.session) # Ensure the records are deleted query = self.session.query(models.Record) query.filter_by(domain_id=domain_m.id).delete() # Ensure domainmetadata is deleted query = self.session.query(models.DomainMetadata) query.filter_by(domain_id=domain_m.id).delete()