def do(self): sleep(10) for sentinel_instance in self.sentinel_instances: reset_sentinel(sentinel_instance.hostname, sentinel_instance.address, sentinel_instance.port, self.infra.name) sleep(1)
def do(self): driver = self.infra.get_driver() for sentinel_instance in driver.get_non_database_instances(): reset_sentinel( sentinel_instance.hostname, sentinel_instance.address, sentinel_instance.port, self.infra.name )
def do(self): sleep(10) if self.sentinel_instance: reset_sentinel( self.host, self.sentinel_instance.address, self.sentinel_instance.port, self.sentinel_instance.databaseinfra.name )
def undo(self): self.stop_database() sleep(10) sentinel_instances = self.driver.get_non_database_instances() for sentinel_instance in sentinel_instances: host = sentinel_instance.hostname reset_sentinel(host, sentinel_instance.address, sentinel_instance.port, self.infra.name) sleep(10) self.start_database()
def do(self, workflow_dict): try: databaseinfra = workflow_dict['databaseinfra'] master = workflow_dict['host'] hosts = [master, ] if workflow_dict['not_primary_hosts'] >= 1: hosts.extend(workflow_dict['not_primary_hosts']) for host in hosts: LOG.info('Configuring {}'.format(host)) ConfigureRestore( host.database_instance(), SENTINELMASTER=master.address, SENTINELMASTERPORT=master.database_instance().port, MASTERNAME=databaseinfra.name ).do() for host in hosts: return_code, output = use_database_initialization_script( databaseinfra=databaseinfra, host=host, option='start' ) if return_code != 0: raise Exception(str(output)) LOG.info('Wait 1 minute before start other instance') sleep(60) driver = databaseinfra.get_driver() sentinel_instances = driver.get_non_database_instances() for sentinel_instance in sentinel_instances: host = sentinel_instance.hostname if host not in hosts: LOG.info("Reset sentinel instance on host: {}".format(host)) reset_sentinel( host, sentinel_instance.address, sentinel_instance.port, databaseinfra.name ) return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0021) workflow_dict['exceptions']['traceback'].append(traceback) return False
def do(self, workflow_dict): try: databaseinfra = workflow_dict["databaseinfra"] for index, source_host in enumerate(workflow_dict["source_hosts"]): source_cs_host_attr = CS_HostAttr.objects.get(host=source_host) script = test_bash_script_error() script += build_start_stop_scripts() if index < 2: script += build_stop_database_script() script += build_stop_sentinel_script() script += build_start_http_script() script = build_context_script({}, script) output = {} LOG.info(script) return_code = exec_remote_command( server=source_host.address, username=source_cs_host_attr.vm_user, password=source_cs_host_attr.vm_password, command=script, output=output, ) LOG.info(output) if return_code != 0: raise Exception(str(output)) for source_instance in workflow_dict["source_instances"]: if source_instance.instance_type == source_instance.REDIS_SENTINEL: target_instance = source_instance.future_instance reset_sentinel( host=target_instance.hostname, sentinel_host=target_instance.address, sentinel_port=target_instance.port, service_name=databaseinfra.name, ) sleep(30) return True except Exception: traceback = full_stack() workflow_dict["exceptions"]["error_codes"].append(DBAAS_0020) workflow_dict["exceptions"]["traceback"].append(traceback) return False
def undo(self): self.stop_database() sleep(10) sentinel_instances = self.driver.get_non_database_instances() for sentinel_instance in sentinel_instances: host = sentinel_instance.hostname reset_sentinel( host, sentinel_instance.address, sentinel_instance.port, self.infra.name ) sleep(10) self.start_database()
def do(self, workflow_dict): try: databaseinfra = workflow_dict['databaseinfra'] for index, source_host in enumerate(workflow_dict['source_hosts']): source_cs_host_attr = CS_HostAttr.objects.get(host=source_host) script = test_bash_script_error() script += build_start_stop_scripts() if index < 2: script += build_stop_database_script() script += build_stop_sentinel_script() script += build_start_http_script() script = build_context_script({}, script) output = {} LOG.info(script) return_code = exec_remote_command(server=source_host.address, username=source_cs_host_attr.vm_user, password=source_cs_host_attr.vm_password, command=script, output=output) LOG.info(output) if return_code != 0: raise Exception(str(output)) for source_instance in workflow_dict['source_instances']: if source_instance.instance_type == source_instance.REDIS_SENTINEL: target_instance = source_instance.future_instance reset_sentinel(host=target_instance.hostname, sentinel_host=target_instance.address, sentinel_port=target_instance.port, service_name=databaseinfra.name) sleep(30) return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0020) workflow_dict['exceptions']['traceback'].append(traceback) return False
def undo(self, workflow_dict): LOG.info("Running undo...") try: databaseinfra = workflow_dict['databaseinfra'] for index, source_host in enumerate(workflow_dict['source_hosts']): target_host = source_host.future_host target_cs_host_attr = CS_HostAttr.objects.get(host=target_host) script = test_bash_script_error() script += build_start_stop_scripts() script += build_stop_sentinel_script() if index < 2: script += build_stop_database_script() script = build_context_script({}, script) output = {} exec_remote_command(server=target_host.address, username=target_cs_host_attr.vm_user, password=target_cs_host_attr.vm_password, command=script, output=output) LOG.info(output) for source_instance in workflow_dict['source_instances']: if source_instance.instance_type == source_instance.REDIS_SENTINEL: reset_sentinel(host=source_instance.hostname, sentinel_host=source_instance.address, sentinel_port=source_instance.port, service_name=databaseinfra.name) sleep(30) return True except Exception: traceback = full_stack() workflow_dict['exceptions']['error_codes'].append(DBAAS_0020) workflow_dict['exceptions']['traceback'].append(traceback) return False