Ejemplo n.º 1
0
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            target_instances = workflow_dict[
                'databaseinfra'].instances.filter(future_instance=None)

            target_instance_zero = target_instances[0]

            source_instance_zero = workflow_dict['source_instances'][0]
            source_instance_one = workflow_dict['source_instances'][1]

            master_log_file, master_log_pos = get_replication_info(
                source_instance_one)
            change_master_to(instance=source_instance_zero,
                             master_host=source_instance_one.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)

            master_log_file, master_log_pos = get_replication_info(
                source_instance_zero)
            change_master_to(instance=target_instance_zero,
                             master_host=source_instance_zero.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)
            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
    def do(self, workflow_dict):
        try:
            master_source_instance = workflow_dict['source_instances'][0]

            master_target_instance = workflow_dict['source_instances'][0].future_instance
            slave_target_instance = workflow_dict['source_instances'][1].future_instance

            master_log_file, master_log_pos = get_replication_info(master_target_instance)

            change_master_to(instance=master_target_instance,
                             master_host=master_source_instance.address,
                             bin_log_file=workflow_dict['binlog_file'],
                             bin_log_position=workflow_dict['binlog_pos'])

            change_master_to(instance=slave_target_instance,
                             master_host=master_target_instance.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
    def do(self, workflow_dict):
        try:
            master_source_instance = workflow_dict['source_instances'][0]

            master_target_instance = workflow_dict['source_instances'][
                0].future_instance
            slave_target_instance = workflow_dict['source_instances'][
                1].future_instance

            master_log_file, master_log_pos = get_replication_info(
                master_target_instance)

            change_master_to(instance=master_target_instance,
                             master_host=master_source_instance.address,
                             bin_log_file=workflow_dict['binlog_file'],
                             bin_log_position=workflow_dict['binlog_pos'])

            change_master_to(instance=slave_target_instance,
                             master_host=master_target_instance.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
Ejemplo n.º 4
0
 def _change_master_to(self, instance, master):
     log_file, log_position = get_replication_info(master)
     change_master_to(instance, master.address, log_file, log_position)