コード例 #1
0
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            databaseinfra = workflow_dict['databaseinfra']

            for host in workflow_dict['stoped_hosts']:
                LOG.info('Starting database on host {}'.format(host))
                return_code, output = use_database_initialization_script(databaseinfra=databaseinfra,
                                                                         host=host,
                                                                         option='start')

                if return_code != 0:
                    LOG.warn(str(output))

                instance = host.instance_set.all()[0]
                start_slave(instance=instance)

            LOG.info('Wainting 30 seconds to setting flipper IPs')
            sleep(30)
            LOG.info('Setting read IP on {}'.format(workflow_dict['host']))
            set_infra_read_ip(slave_host=workflow_dict['host'],
                              infra_name=databaseinfra.name)

            LOG.info('Setting write IP on {}'.format(workflow_dict['not_primary_hosts'][0]))
            set_infra_write_ip(master_host=workflow_dict['not_primary_hosts'][0],
                               infra_name=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
コード例 #2
0
    def do(self, workflow_dict):
        try:

            databaseinfra = workflow_dict['databaseinfra']

            master_host = workflow_dict['host']
            master_instance = Instance.objects.get(hostname=master_host)

            secondary_host = workflow_dict['not_primary_hosts'][0]
            secondary_instance = Instance.objects.get(hostname=secondary_host)

            master_log_file, master_log_pos = get_replication_information_from_file(
                host=master_host)

            return_code, output = use_database_initialization_script(
                databaseinfra=databaseinfra, host=master_host, option='start')
            if return_code != 0:
                raise Exception(str(output))

            return_code, output = use_database_initialization_script(
                databaseinfra=databaseinfra,
                host=secondary_host,
                option='start')
            if return_code != 0:
                raise Exception(str(output))

            LOG.info("Waiting 1 minute to continue")
            sleep(60)

            change_master_to(instance=master_instance,
                             master_host=secondary_host.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)

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

            start_slave(instance=master_instance)
            start_slave(instance=secondary_instance)

            LOG.info("Waiting 30 seconds to continue")
            sleep(30)
            set_infra_read_ip(slave_host=workflow_dict['host'],
                              infra_name=databaseinfra.name)

            set_infra_write_ip(
                master_host=workflow_dict['not_primary_hosts'][0],
                infra_name=databaseinfra.name)

            return True
        except Exception:
            traceback = full_stack()

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

            return False
コード例 #3
0
    def do(self, workflow_dict):
        try:

            databaseinfra = workflow_dict['databaseinfra']

            master_host = workflow_dict['host']
            master_instance = Instance.objects.get(hostname=master_host)

            secondary_host = workflow_dict['not_primary_hosts'][0]
            secondary_instance = Instance.objects.get(hostname=secondary_host)

            master_log_file, master_log_pos = get_replication_information_from_file(host=master_host)

            return_code, output = use_database_initialization_script(databaseinfra=databaseinfra,
                                                                     host=master_host,
                                                                     option='start')
            if return_code != 0:
                raise Exception(str(output))

            return_code, output = use_database_initialization_script(databaseinfra=databaseinfra,
                                                                     host=secondary_host,
                                                                     option='start')
            if return_code != 0:
                raise Exception(str(output))

            LOG.info("Waiting 1 minute to continue")
            sleep(60)

            change_master_to(instance=master_instance,
                             master_host=secondary_host.address,
                             bin_log_file=master_log_file,
                             bin_log_position=master_log_pos)

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

            start_slave(instance=master_instance)
            start_slave(instance=secondary_instance)

            LOG.info("Waiting 30 seconds to continue")
            sleep(30)
            set_infra_read_ip(slave_host=workflow_dict['host'],
                              infra_name=databaseinfra.name)

            set_infra_write_ip(master_host=workflow_dict['not_primary_hosts'][0],
                               infra_name=databaseinfra.name)

            return True
        except Exception:
            traceback = full_stack()

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

            return False
コード例 #4
0
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            databaseinfra = workflow_dict['databaseinfra']

            for host in workflow_dict['stoped_hosts']:
                LOG.info('Starting database on host {}'.format(host))
                return_code, output = use_database_initialization_script(
                    databaseinfra=databaseinfra, host=host, option='start')

                if return_code != 0:
                    LOG.warn(str(output))

                instance = host.instances.all()[0]
                start_slave(instance=instance)

            LOG.info('Wainting 30 seconds to setting write/read instances')
            sleep(30)
            driver = databaseinfra.get_driver()
            master_host = workflow_dict['host']
            master_instance = Instance.objects.get(hostname=master_host)
            secondary_host = workflow_dict['not_primary_hosts'][0]
            secondary_instance = Instance.objects.get(hostname=secondary_host)
            LOG.info('Setting read on {}'.format(master_instance))
            driver.set_read_ip(instance=master_instance)
            LOG.info('Setting write on {}'.format(secondary_instance))
            driver.set_master(instance=secondary_instance)

            return True
        except Exception:
            traceback = full_stack()

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

            return False
コード例 #5
0
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            databaseinfra = workflow_dict['databaseinfra']

            for host in workflow_dict['stoped_hosts']:
                LOG.info('Starting database on host {}'.format(host))
                return_code, output = use_database_initialization_script(
                    databaseinfra=databaseinfra, host=host, option='start')

                if return_code != 0:
                    LOG.warn(str(output))

                instance = host.instance_set.all()[0]
                start_slave(instance=instance)

            LOG.info('Wainting 30 seconds to setting flipper IPs')
            sleep(30)
            LOG.info('Setting read IP on {}'.format(workflow_dict['host']))
            set_infra_read_ip(slave_host=workflow_dict['host'],
                              infra_name=databaseinfra.name)

            LOG.info('Setting write IP on {}'.format(
                workflow_dict['not_primary_hosts'][0]))
            set_infra_write_ip(
                master_host=workflow_dict['not_primary_hosts'][0],
                infra_name=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
コード例 #6
0
 def do(self):
     start_slave(self.instance)
コード例 #7
0
 def do(self):
     start_slave(self.instance)