class DBMonitorStep(BaseInstanceStep): def __init__(self, instance): super(DBMonitorStep, self).__init__(instance) self.provider = DBMonitorProvider() def _enable_monitoring(self): self.provider.enabled_dbmonitor_monitoring_instance(self.instance) def _disable_monitoring(self): self.provider.disabled_dbmonitor_monitoring_instance(self.instance) def do(self): raise NotImplementedError def undo(self): pass
def extra_dns_post_delete(sender, **kwargs): """ extra dns post delete signal. Delete extra dns on dbmonitor's database """ LOG.debug("extra_dns post-delete triggered") extra_dns = kwargs.get("instance") database = extra_dns.database DBMonitorProvider().remove_extra_dns(database=database, extra_dns=extra_dns.dns)
def register_backup_dbmonitor(databaseinfra, snapshot): try: from dbaas_dbmonitor.provider import DBMonitorProvider DBMonitorProvider().register_backup(databaseinfra=databaseinfra, start_at=snapshot.start_at, end_at=snapshot.end_at, size=snapshot.size, status=snapshot.status, type=snapshot.type, error=snapshot.error) except Exception, e: LOG.error("Error register backup on DBMonitor %s" % (e))
def extra_dns_post_save(sender, **kwargs): """ extra dns post save signal. Inserts extra dns on dbmonitor's database """ LOG.debug("extra_dns post-save triggered") extra_dns = kwargs.get("instance") is_new = kwargs.get("created") if is_new: database = extra_dns.database DBMonitorProvider().insert_extra_dns(database=database, extra_dns=extra_dns.dns)
def do(self, workflow_dict): try: databaseinfra = workflow_dict['databaseinfra'] target_engine = workflow_dict['target_engine'] DBMonitorProvider().update_dbmonitor_database_version( databaseinfra=databaseinfra, new_version=target_engine.version) return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0023) workflow_dict['exceptions']['traceback'].append(traceback) return False
def undo(self, workflow_dict): try: if not 'databaseinfra' in workflow_dict: return False LOG.info("Destroying dbmonitor monitoring...") DBMonitorProvider().remove_dbmonitor_monitoring( workflow_dict['databaseinfra']) return True except Exception, e: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0006) workflow_dict['exceptions']['traceback'].append(traceback) return False
def __init__(self, instance): super(DBMonitorStep, self).__init__(instance) self.provider = DBMonitorProvider()