def do(self, workflow_dict):
        try:

            target_host_zero = workflow_dict['source_hosts'][0].future_host
            target_host_one = workflow_dict['source_hosts'][1].future_host
            databaseinfra = workflow_dict['databaseinfra']
            cs_host_attr = CS_HostAttr.objects.get(host=target_host_zero)

            context_dict = {
                'MASTERPAIRNAME': databaseinfra.name,
                'HOST01': target_host_zero,
                'HOST02': target_host_one,
            }

            script = test_bash_script_error()
            script += build_set_flipper_ips_script()
            script = build_context_script(context_dict, script)
            output = {}

            return_code = exec_remote_command(
                server=target_host_zero.address,
                username=cs_host_attr.vm_user,
                password=cs_host_attr.vm_password,
                command=script,
                output=output)

            LOG.info(output)
            if return_code != 0:
                raise Exception(str(output))

            databaseinfraattr = workflow_dict[
                'source_secondary_ips'][0].equivalent_dbinfraattr
            databaseinfra = workflow_dict['databaseinfra']
            databaseinfra.endpoint = databaseinfraattr.ip + ":3306"
            databaseinfra.save()

            return True
        except Exception:
            traceback = full_stack()

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

            return False
示例#2
0
    def do(self, workflow_dict):
        try:

            target_host_zero = workflow_dict['source_hosts'][0].future_host
            target_host_one = workflow_dict['source_hosts'][1].future_host
            databaseinfra = workflow_dict['databaseinfra']
            cs_host_attr = CS_HostAttr.objects.get(host=target_host_zero)

            context_dict = {
                'MASTERPAIRNAME': databaseinfra.name,
                'HOST01': target_host_zero,
                'HOST02': target_host_one,
            }

            script = test_bash_script_error()
            script += build_set_flipper_ips_script()
            script = build_context_script(context_dict, script)
            output = {}

            return_code = exec_remote_command(
                server=target_host_zero.address,
                username=cs_host_attr.vm_user,
                password=cs_host_attr.vm_password,
                command=script,
                output=output)

            LOG.info(output)
            if return_code != 0:
                raise Exception(str(output))

            databaseinfraattr = workflow_dict['source_secondary_ips'][
                0].equivalent_dbinfraattr
            databaseinfra = workflow_dict['databaseinfra']
            databaseinfra.endpoint = databaseinfraattr.ip + ":3306"
            databaseinfra.save()

            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 undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:

            source_host_zero = workflow_dict['source_hosts'][0]
            source_host_one = workflow_dict['source_hosts'][1]
            databaseinfra = workflow_dict['databaseinfra']
            cs_host_attr = CS_HostAttr.objects.get(host=source_host_zero)

            context_dict = {
                'MASTERPAIRNAME': databaseinfra.name,
                'HOST01': source_host_zero,
                'HOST02': source_host_one,
            }

            script = test_bash_script_error()
            script += build_set_flipper_ips_script()
            script = build_context_script(context_dict, script)
            output = {}

            return_code = exec_remote_command(
                server=source_host_zero.address,
                username=cs_host_attr.vm_user,
                password=cs_host_attr.vm_password,
                command=script,
                output=output)

            LOG.info(output)
            if return_code != 0:
                raise Exception(str(output))

            return True
        except Exception:
            traceback = full_stack()

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

            return False